UNPKG

slimerjs-firefox

Version:

This repo includes slimerjs as well as downloads a local copy of Firefox.

16 lines (15 loc) 7.42 kB
function(){return function(){var h=this; function ba(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null";else if("function"== b&&"undefined"==typeof a.call)return"object";return b};var k,l,p,q;function r(){return h.navigator?h.navigator.userAgent:null}q=p=l=k=!1;var s;if(s=r()){var ca=h.navigator;k=0==s.indexOf("Opera");l=!k&&-1!=s.indexOf("MSIE");p=!k&&-1!=s.indexOf("WebKit");q=!k&&!p&&"Gecko"==ca.product}var t=k,u=l,v=q,w=p;function x(){var a=h.document;return a?a.documentMode:void 0}var y; a:{var z="",A;if(t&&h.opera)var B=h.opera.version,z="function"==typeof B?B():B;else if(v?A=/rv\:([^\);]+)(\)|;)/:u?A=/MSIE\s+([^\);]+)(\)|;)/:w&&(A=/WebKit\/(\S+)/),A)var C=A.exec(r()),z=C?C[1]:"";if(u){var D=x();if(D>parseFloat(z)){y=String(D);break a}}y=z}var E={}; function F(a){var b;if(!(b=E[a])){b=0;for(var c=String(y).replace(/^[\s\xa0]+|[\s\xa0]+$/g,"").split("."),d=String(a).replace(/^[\s\xa0]+|[\s\xa0]+$/g,"").split("."),f=Math.max(c.length,d.length),e=0;0==b&&e<f;e++){var g=c[e]||"",ea=d[e]||"",fa=RegExp("(\\d*)(\\D*)","g"),ga=RegExp("(\\d*)(\\D*)","g");do{var m=fa.exec(g)||["","",""],n=ga.exec(ea)||["","",""];if(0==m[0].length&&0==n[0].length)break;b=((0==m[1].length?0:parseInt(m[1],10))<(0==n[1].length?0:parseInt(n[1],10))?-1:(0==m[1].length?0:parseInt(m[1], 10))>(0==n[1].length?0:parseInt(n[1],10))?1:0)||((0==m[2].length)<(0==n[2].length)?-1:(0==m[2].length)>(0==n[2].length)?1:0)||(m[2]<n[2]?-1:m[2]>n[2]?1:0)}while(0==b)}b=E[a]=0<=b}return b}var G=h.document,H=G&&u?x()||("CSS1Compat"==G.compatMode?parseInt(y,10):5):void 0;var I;!v&&!u||u&&u&&9<=H||v&&F("1.9.1");u&&F("9");function J(a,b){this.x=void 0!==a?a:0;this.y=void 0!==b?b:0}J.prototype.toString=function(){return"("+this.x+", "+this.y+")"};function K(a,b){this.width=a;this.height=b}K.prototype.toString=function(){return"("+this.width+" x "+this.height+")"};function L(a){return a?new M(N(a)):I||(I=new M)}function N(a){return 9==a.nodeType?a:a.ownerDocument||a.document}function M(a){this.a=a||h.document||document}function da(a){a=(a.a.parentWindow||a.a.defaultView||window).document;a="CSS1Compat"==a.compatMode?a.documentElement:a.body;return new K(a.clientWidth,a.clientHeight)} function O(a){var b=a.a;a=w||"CSS1Compat"!=b.compatMode?b.body||b.documentElement:b.documentElement;b=b.parentWindow||b.defaultView;return u&&F("10")&&b.pageYOffset!=a.scrollTop?new J(a.scrollLeft,a.scrollTop):new J(b.pageXOffset||a.scrollLeft,b.pageYOffset||a.scrollTop)};function P(a,b,c,d){this.top=a;this.right=b;this.bottom=c;this.left=d}P.prototype.toString=function(){return"("+this.top+"t, "+this.right+"r, "+this.bottom+"b, "+this.left+"l)"};function Q(a,b,c,d){this.left=a;this.top=b;this.width=c;this.height=d}Q.prototype.toString=function(){return"("+this.left+", "+this.top+" - "+this.width+"w x "+this.height+"h)"};function R(a,b){var c=N(a);return c.defaultView&&c.defaultView.getComputedStyle&&(c=c.defaultView.getComputedStyle(a,null))?c[b]||c.getPropertyValue(b)||"":""}function S(a,b){return R(a,b)||(a.currentStyle?a.currentStyle[b]:null)||a.style&&a.style[b]} function T(a){var b;try{b=a.getBoundingClientRect()}catch(c){return{left:0,top:0,right:0,bottom:0}}u&&a.ownerDocument.body&&(a=a.ownerDocument,b.left-=a.documentElement.clientLeft+a.body.clientLeft,b.top-=a.documentElement.clientTop+a.body.clientTop);return b} function ha(a){if(u&&!(u&&8<=H))return a.offsetParent;var b=N(a),c=S(a,"position"),d="fixed"==c||"absolute"==c;for(a=a.parentNode;a&&a!=b;a=a.parentNode)if(c=S(a,"position"),d=d&&"static"==c&&a!=b.documentElement&&a!=b.body,!d&&(a.scrollWidth>a.clientWidth||a.scrollHeight>a.clientHeight||"fixed"==c||"absolute"==c||"relative"==c))return a;return null} function U(a){var b,c=N(a),d=S(a,"position"),f=v&&c.getBoxObjectFor&&!a.getBoundingClientRect&&"absolute"==d&&(b=c.getBoxObjectFor(a))&&(0>b.screenX||0>b.screenY),e=new J(0,0),g;b=c?N(c):document;(g=!u)||(g=u&&9<=H)||(g="CSS1Compat"==L(b).a.compatMode);g=g?b.documentElement:b.body;if(a==g)return e;if(a.getBoundingClientRect)b=T(a),a=O(L(c)),e.x=b.left+a.x,e.y=b.top+a.y;else if(c.getBoxObjectFor&&!f)b=c.getBoxObjectFor(a),a=c.getBoxObjectFor(g),e.x=b.screenX-a.screenX,e.y=b.screenY-a.screenY;else{f= a;do{e.x+=f.offsetLeft;e.y+=f.offsetTop;f!=a&&(e.x+=f.clientLeft||0,e.y+=f.clientTop||0);if(w&&"fixed"==S(f,"position")){e.x+=c.body.scrollLeft;e.y+=c.body.scrollTop;break}f=f.offsetParent}while(f&&f!=a);if(t||w&&"absolute"==d)e.y-=c.body.offsetTop;for(f=a;(f=ha(f))&&f!=c.body&&f!=g;)e.x-=f.scrollLeft,t&&"TR"==f.tagName||(e.y-=f.scrollTop)}return e} function V(a){if(1==a.nodeType){var b;if(a.getBoundingClientRect)b=T(a),b=new J(b.left,b.top);else{b=O(L(a));var c=U(a);b=new J(c.x-b.x,c.y-b.y)}if(v&&!F(12)){var d;u?d="-ms-transform":w?d="-webkit-transform":t?d="-o-transform":v&&(d="-moz-transform");var f;d&&(f=S(a,d));f||(f=S(a,"transform"));a=f?(a=f.match(ia))?new J(parseFloat(a[1]),parseFloat(a[2])):new J(0,0):new J(0,0);a=new J(b.x+a.x,b.y+a.y)}else a=b;return a}d="function"==ba(a.b);f=a;a.targetTouches?f=a.targetTouches[0]:d&&a.b().targetTouches&& (f=a.b().targetTouches[0]);return new J(f.clientX,f.clientY)}var W={thin:2,medium:4,thick:6};function X(a,b){if("none"==(a.currentStyle?a.currentStyle[b+"Style"]:null))return 0;var c=a.currentStyle?a.currentStyle[b+"Width"]:null,d;if(c in W)d=W[c];else if(/^\d+px?$/.test(c))d=parseInt(c,10);else{d=a.style.left;var f=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;a.style.left=c;c=a.style.pixelLeft;a.style.left=d;a.runtimeStyle.left=f;d=c}return d}var ia=/matrix\([0-9\.\-]+, [0-9\.\-]+, [0-9\.\-]+, [0-9\.\-]+, ([0-9\.\-]+)p?x?, ([0-9\.\-]+)p?x?\)/;function ja(a,b){var c;c=U(b);var d=U(a);c=new J(c.x-d.x,c.y-d.y);if(!u||u&&9<=H)d=R(a,"borderLeftWidth"),f=R(a,"borderRightWidth"),e=R(a,"borderTopWidth"),g=R(a,"borderBottomWidth"),d=new P(parseFloat(e),parseFloat(f),parseFloat(g),parseFloat(d));else var d=X(a,"borderLeft"),f=X(a,"borderRight"),e=X(a,"borderTop"),g=X(a,"borderBottom"),d=new P(e,f,g,d);c.x-=d.left;c.y-=d.top;return c} function ka(a,b,c){function d(a,b,c,d,f){d=new Q(c.x+d.left,c.y+d.top,d.width,d.height);c=[0,0];b=[b.width,b.height];var e=[d.left,d.top];d=[d.width,d.height];for(var g=0;2>g;g++)if(d[g]>b[g])c[g]=f?e[g]+d[g]/2-b[g]/2:e[g];else{var aa=e[g]-b[g]+d[g];0<aa?c[g]=aa:0>e[g]&&(c[g]=e[g])}f=new J(c[0],c[1]);a.scrollLeft+=f.x;a.scrollTop+=f.y}for(var f=N(a),e=a.parentNode,g;e&&e!=f.documentElement&&e!=f.body;)g=ja(e,a),d(e,new K(e.clientWidth,e.clientHeight),g,b,c),e=e.parentNode;g=V(a);a=da(L(a));d(f.body, a,g,b,c)};function la(a,b,c){c||(c=new Q(0,0,a.offsetWidth,a.offsetHeight));ka(a,c,b);a=V(a);return new J(a.x+c.left,a.y+c.top)}var Y=["_"],Z=h;Y[0]in Z||!Z.execScript||Z.execScript("var "+Y[0]);for(var $;Y.length&&($=Y.shift());)Y.length||void 0===la?Z=Z[$]?Z[$]:Z[$]={}:Z[$]=la;; return this._.apply(null,arguments);}.apply({navigator:typeof window!=undefined?window.navigator:null,document:typeof window!=undefined?window.document:null}, arguments);}