UNPKG

slimerjs-firefox

Version:

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

16 lines (15 loc) 8.91 kB
function(){return function(){var l=this; function n(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}function aa(a){var b=n(a);return"array"==b||"object"==b&&"number"==typeof a.length}function ba(a){var b=typeof a;return"object"==b&&null!=a||"function"==b}function ca(a,b){var c=Array.prototype.slice.call(arguments,1);return function(){var b=Array.prototype.slice.call(arguments);b.unshift.apply(b,c);return a.apply(this,b)}}var p=Date.now||function(){return+new Date};var q=0,r=13;function s(a,b){this.code=a;this.state=u[a]||da;this.message=b||"";var c=this.state.replace(/((?:^|\s+)[a-z])/g,function(a){return a.toUpperCase().replace(/^[\s\xa0]+/g,"")}),e=c.length-5;if(0>e||c.indexOf("Error",e)!=e)c+="Error";this.name=c;c=Error(this.message);c.name=this.name;this.stack=c.stack||""}(function(){var a=s,b=Error;function c(){}c.prototype=b.prototype;a.d=b.prototype;a.prototype=new c})(); var da="unknown error",u={15:"element not selectable",11:"element not visible",31:"ime engine activation failed",30:"ime not available",24:"invalid cookie domain",29:"invalid element coordinates",12:"invalid element state",32:"invalid selector",51:"invalid selector",52:"invalid selector",17:"javascript error",405:"unsupported operation",34:"move target out of bounds",27:"no such alert",7:"no such element",8:"no such frame",23:"no such window",28:"script timeout",33:"session not created",10:"stale element reference"}; u[q]="success";u[21]="timeout";u[25]="unable to set cookie";u[26]="unexpected alert open";u[r]=da;u[9]="unknown command";s.prototype.toString=function(){return this.name+": "+this.message};function v(a,b){for(var c=0,e=String(a).replace(/^[\s\xa0]+|[\s\xa0]+$/g,"").split("."),f=String(b).replace(/^[\s\xa0]+|[\s\xa0]+$/g,"").split("."),d=Math.max(e.length,f.length),m=0;0==c&&m<d;m++){var t=e[m]||"",g=f[m]||"",I=RegExp("(\\d*)(\\D*)","g"),J=RegExp("(\\d*)(\\D*)","g");do{var k=I.exec(t)||["","",""],h=J.exec(g)||["","",""];if(0==k[0].length&&0==h[0].length)break;c=((0==k[1].length?0:parseInt(k[1],10))<(0==h[1].length?0:parseInt(h[1],10))?-1:(0==k[1].length?0:parseInt(k[1],10))>(0==h[1].length? 0:parseInt(h[1],10))?1:0)||((0==k[2].length)<(0==h[2].length)?-1:(0==k[2].length)>(0==h[2].length)?1:0)||(k[2]<h[2]?-1:k[2]>h[2]?1:0)}while(0==c)}return c};var w,x,y,z;function A(){return l.navigator?l.navigator.userAgent:null}z=y=x=w=!1;var B;if(B=A()){var ea=l.navigator;w=0==B.indexOf("Opera");x=!w&&-1!=B.indexOf("MSIE");y=!w&&-1!=B.indexOf("WebKit");z=!w&&!y&&"Gecko"==ea.product}var C=w,D=x,E=z,fa=y;function ga(){var a=l.document;return a?a.documentMode:void 0}var F; a:{var G="",H;if(C&&l.opera)var K=l.opera.version,G="function"==typeof K?K():K;else if(E?H=/rv\:([^\);]+)(\)|;)/:D?H=/MSIE\s+([^\);]+)(\)|;)/:fa&&(H=/WebKit\/(\S+)/),H)var ha=H.exec(A()),G=ha?ha[1]:"";if(D){var ia=ga();if(ia>parseFloat(G)){F=String(ia);break a}}F=G}var ja={};function L(a){return ja[a]||(ja[a]=0<=v(F,a))}var ka=l.document,M=ka&&D?ga()||("CSS1Compat"==ka.compatMode?parseInt(F,10):5):void 0;var N,O,P,Q,R,S,T;T=S=R=Q=P=O=N=!1;var U=A();U&&(-1!=U.indexOf("Firefox")?N=!0:-1!=U.indexOf("Camino")?O=!0:-1!=U.indexOf("iPhone")||-1!=U.indexOf("iPod")?P=!0:-1!=U.indexOf("iPad")?Q=!0:-1!=U.indexOf("Android")?R=!0:-1!=U.indexOf("Chrome")?S=!0:-1!=U.indexOf("Safari")&&(T=!0));var la=N,ma=O,na=P,oa=Q,V=R,pa=S,qa=T;function W(a){return(a=a.exec(A()))?a[1]:""}var ra=function(){if(la)return W(/Firefox\/([0-9.]+)/);if(D||C)return F;if(pa)return W(/Chrome\/([0-9.]+)/);if(qa)return W(/Version\/([0-9.]+)/);if(na||oa){var a=/Version\/(\S+).*Mobile\/(\S+)/.exec(A());if(a)return a[1]+"."+a[2]}else{if(V)return(a=W(/Android\s+([0-9.]+)/))?a:W(/Version\/([0-9.]+)/);if(ma)return W(/Camino\/([0-9.]+)/)}return""}();var sa,ta;function ua(a){va?ta(a):V?v(wa,a):v(ra,a)}var va=function(){if(!E)return!1;var a=l.Components;if(!a)return!1;try{if(!a.classes)return!1}catch(b){return!1}var c=a.classes,a=a.interfaces,e=c["@mozilla.org/xpcom/version-comparator;1"].getService(a.nsIVersionComparator),c=c["@mozilla.org/xre/app-info;1"].getService(a.nsIXULAppInfo),f=c.platformVersion,d=c.version;sa=function(a){return 0<=e.c(f,""+a)};ta=function(a){e.c(d,""+a)};return!0}(),xa; if(V){var ya=/Android\s+([0-9\.]+)/.exec(A());xa=ya?ya[1]:"0"}else xa="0";var wa=xa;V&&ua(2.3);V&&ua(4);qa&&ua(6);function za(){this.a=void 0} function Aa(a,b,c){switch(typeof b){case "string":Ba(b,c);break;case "number":c.push(isFinite(b)&&!isNaN(b)?b:"null");break;case "boolean":c.push(b);break;case "undefined":c.push("null");break;case "object":if(null==b){c.push("null");break}if("array"==n(b)){var e=b.length;c.push("[");for(var f="",d=0;d<e;d++)c.push(f),f=b[d],Aa(a,a.a?a.a.call(b,String(d),f):f,c),f=",";c.push("]");break}c.push("{");e="";for(d in b)Object.prototype.hasOwnProperty.call(b,d)&&(f=b[d],"function"!=typeof f&&(c.push(e), Ba(d,c),c.push(":"),Aa(a,a.a?a.a.call(b,d,f):f,c),e=","));c.push("}");break;case "function":break;default:throw Error("Unknown type: "+typeof b);}}var Ca={'"':'\\"',"\\":"\\\\","/":"\\/","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\x0B":"\\u000b"},Da=/\uffff/.test("\uffff")?/[\\\"\x00-\x1f\x7f-\uffff]/g:/[\\\"\x00-\x1f\x7f-\xff]/g; function Ba(a,b){b.push('"',a.replace(Da,function(a){if(a in Ca)return Ca[a];var b=a.charCodeAt(0),f="\\u";16>b?f+="000":256>b?f+="00":4096>b&&(f+="0");return Ca[a]=f+b.toString(16)}),'"')};fa||C||E&&(va?sa(3.5):D?0<=v(M,3.5):L(3.5))||D&&(va?sa(8):D?v(M,8):L(8));function Ea(a,b){for(var c=a.length,e=Array(c),f="string"==typeof a?a.split(""):a,d=0;d<c;d++)d in f&&(e[d]=b.call(void 0,f[d],d,a));return e};if(E||D){var Fa;if(Fa=D)Fa=D&&9<=M;Fa||E&&L("1.9.1")}D&&L("9");function Ga(a,b){var c={},e;for(e in a)b.call(void 0,a[e],e,a)&&(c[e]=a[e]);return c}function Ha(a,b){var c={},e;for(e in a)c[e]=b.call(void 0,a[e],e,a);return c}function Ia(a,b){for(var c in a)if(b.call(void 0,a[c],c,a))return c};function X(a){switch(n(a)){case "string":case "number":case "boolean":return a;case "function":return a.toString();case "array":return Ea(a,X);case "object":if("nodeType"in a&&(1==a.nodeType||9==a.nodeType)){var b={};b.ELEMENT=Ja(a);return b}if("document"in a)return b={},b.WINDOW=Ja(a),b;if(aa(a))return Ea(a,X);a=Ga(a,function(a,b){return"number"==typeof b||"string"==typeof b});return Ha(a,X);default:return null}} function Ka(a,b){return"array"==n(a)?Ea(a,function(a){return Ka(a,b)}):ba(a)?"function"==typeof a?a:"ELEMENT"in a?La(a.ELEMENT,b):"WINDOW"in a?La(a.WINDOW,b):Ha(a,function(a){return Ka(a,b)}):a}function Ma(a){a=a||document;var b=a.$wdc_;b||(b=a.$wdc_={},b.b=p());b.b||(b.b=p());return b}function Ja(a){var b=Ma(a.ownerDocument),c=Ia(b,function(b){return b==a});c||(c=":wdc:"+b.b++,b[c]=a);return c} function La(a,b){a=decodeURIComponent(a);var c=b||document,e=Ma(c);if(!(a in e))throw new s(10,"Element does not exist in cache");var f=e[a];if("setInterval"in f){if(f.closed)throw delete e[a],new s(23,"Window has been closed.");return f}for(var d=f;d;){if(d==c.documentElement)return f;d=d.parentNode}delete e[a];throw new s(10,"Element is no longer attached to the DOM");};function Na(a,b,c,e,f,d){function m(a,b){if(!J){g.removeEventListener?g.removeEventListener("unload",t,!0):g.detachEvent("onunload",t);g.clearTimeout(I);if(a!=q){var c=new s(a,b.message||b+"");c.stack=b.stack;b={status:"code"in c?c.code:r,value:{message:c.message}}}else b={status:q,value:X(b)};var c=e,d;f?(d=[],Aa(new za,b,d),d=d.join("")):d=b;c(d);J=!0}}function t(){m(r,Error("Detected a page unload event; asynchronous script execution does not work across page loads."))}var g=d||window,I,J=!1;d= ca(m,r);if(g.closed)d("Unable to execute script; the target window is closed.");else{a="string"==typeof a?new g.Function(a):g==window?a:new g.Function("return ("+a+").apply(null,arguments);");b=Ka(b,g.document);b.push(ca(m,q));g.addEventListener?g.addEventListener("unload",t,!0):g.attachEvent("onunload",t);var k=p();try{a.apply(g,b),I=g.setTimeout(function(){m(28,Error("Timed out waiting for asyncrhonous script result after "+(p()-k)+" ms"))},Math.max(0,c))}catch(h){m(h.code||r,h)}}} var Y=["_"],Z=l;Y[0]in Z||!Z.execScript||Z.execScript("var "+Y[0]);for(var $;Y.length&&($=Y.shift());)Y.length||void 0===Na?Z=Z[$]?Z[$]:Z[$]={}:Z[$]=Na;; return this._.apply(null,arguments);}.apply({navigator:typeof window!=undefined?window.navigator:null,document:typeof window!=undefined?window.document:null}, arguments);}