UNPKG

slimerjs-firefox

Version:

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

14 lines (13 loc) 8.63 kB
function(){return function(){var g=this; function h(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=h(a);return"array"==b||"object"==b&&"number"==typeof a.length}function ba(a){var b=typeof a;return"object"==b&&null!=a||"function"==b}var ca=Date.now||function(){return+new Date};function n(a,b){this.code=a;this.state=p[a]||da;this.message=b||"";var c=this.state.replace(/((?:^|\s+)[a-z])/g,function(a){return a.toUpperCase().replace(/^[\s\xa0]+/g,"")}),d=c.length-5;if(0>d||c.indexOf("Error",d)!=d)c+="Error";this.name=c;c=Error(this.message);c.name=this.name;this.stack=c.stack||""}(function(){var a=Error;function b(){}b.prototype=a.prototype;n.d=a.prototype;n.prototype=new b})(); var da="unknown error",p={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", 0:"success",21:"timeout",25:"unable to set cookie",26:"unexpected alert open"};p[13]=da;p[9]="unknown command";n.prototype.toString=function(){return this.name+": "+this.message};var ea=window;function fa(a,b,c,d,e){function f(a,c){var b=new ga(c);d(a,b)}var k;try{k=ea.openDatabase(a,"",a+"name",5242880)}catch(r){throw new n(13,r.message);}k.transaction(function(a){a.executeSql(b,c,f,void 0)},e,void 0)}function ga(a){this.rows=[];for(var b=0;b<a.rows.length;b++)this.rows[b]=a.rows.item(b);this.rowsAffected=a.rowsAffected;this.insertId=-1;try{this.insertId=a.insertId}catch(c){}};function q(a,b){for(var c=0,d=String(a).replace(/^[\s\xa0]+|[\s\xa0]+$/g,"").split("."),e=String(b).replace(/^[\s\xa0]+|[\s\xa0]+$/g,"").split("."),f=Math.max(d.length,e.length),k=0;0==c&&k<f;k++){var r=d[k]||"",za=e[k]||"",Aa=RegExp("(\\d*)(\\D*)","g"),Ca=RegExp("(\\d*)(\\D*)","g");do{var l=Aa.exec(r)||["","",""],m=Ca.exec(za)||["","",""];if(0==l[0].length&&0==m[0].length)break;c=((0==l[1].length?0:parseInt(l[1],10))<(0==m[1].length?0:parseInt(m[1],10))?-1:(0==l[1].length?0:parseInt(l[1],10))>(0== m[1].length?0:parseInt(m[1],10))?1:0)||((0==l[2].length)<(0==m[2].length)?-1:(0==l[2].length)>(0==m[2].length)?1:0)||(l[2]<m[2]?-1:l[2]>m[2]?1:0)}while(0==c)}return c};var s,t,u,v;function w(){return g.navigator?g.navigator.userAgent:null}v=u=t=s=!1;var x;if(x=w()){var ha=g.navigator;s=0==x.indexOf("Opera");t=!s&&-1!=x.indexOf("MSIE");u=!s&&-1!=x.indexOf("WebKit");v=!s&&!u&&"Gecko"==ha.product}var y=s,z=t,A=v,ia=u;function ja(){var a=g.document;return a?a.documentMode:void 0}var B; a:{var C="",D;if(y&&g.opera)var E=g.opera.version,C="function"==typeof E?E():E;else if(A?D=/rv\:([^\);]+)(\)|;)/:z?D=/MSIE\s+([^\);]+)(\)|;)/:ia&&(D=/WebKit\/(\S+)/),D)var ka=D.exec(w()),C=ka?ka[1]:"";if(z){var la=ja();if(la>parseFloat(C)){B=String(la);break a}}B=C}var ma={};function F(a){return ma[a]||(ma[a]=0<=q(B,a))}var na=g.document,G=na&&z?ja()||("CSS1Compat"==na.compatMode?parseInt(B,10):5):void 0;var H,I,J,K,L,M,N;N=M=L=K=J=I=H=!1;var O=w();O&&(-1!=O.indexOf("Firefox")?H=!0:-1!=O.indexOf("Camino")?I=!0:-1!=O.indexOf("iPhone")||-1!=O.indexOf("iPod")?J=!0:-1!=O.indexOf("iPad")?K=!0:-1!=O.indexOf("Android")?L=!0:-1!=O.indexOf("Chrome")?M=!0:-1!=O.indexOf("Safari")&&(N=!0));var oa=H,pa=I,qa=J,ra=K,P=L,sa=M,ta=N;function Q(a){return(a=a.exec(w()))?a[1]:""}var ua=function(){if(oa)return Q(/Firefox\/([0-9.]+)/);if(z||y)return B;if(sa)return Q(/Chrome\/([0-9.]+)/);if(ta)return Q(/Version\/([0-9.]+)/);if(qa||ra){var a=/Version\/(\S+).*Mobile\/(\S+)/.exec(w());if(a)return a[1]+"."+a[2]}else{if(P)return(a=Q(/Android\s+([0-9.]+)/))?a:Q(/Version\/([0-9.]+)/);if(pa)return Q(/Camino\/([0-9.]+)/)}return""}();var R,va;function S(a){T?va(a):P?q(wa,a):q(ua,a)}var T=function(){if(!A)return!1;var a=g.Components;if(!a)return!1;try{if(!a.classes)return!1}catch(b){return!1}var c=a.classes,a=a.interfaces,d=c["@mozilla.org/xpcom/version-comparator;1"].getService(a.nsIVersionComparator),c=c["@mozilla.org/xre/app-info;1"].getService(a.nsIXULAppInfo),e=c.platformVersion,f=c.version;R=function(a){return 0<=d.c(e,""+a)};va=function(a){d.c(f,""+a)};return!0}(),U; if(P){var xa=/Android\s+([0-9\.]+)/.exec(w());U=xa?xa[1]:"0"}else U="0";var wa=U;P&&S(2.3);P&&S(4);ta&&S(6);function ya(){this.a=void 0} function V(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"==h(b)){var d=b.length;c.push("[");for(var e="",f=0;f<d;f++)c.push(e),e=b[f],V(a,a.a?a.a.call(b,String(f),e):e,c),e=",";c.push("]");break}c.push("{");d="";for(f in b)Object.prototype.hasOwnProperty.call(b,f)&&(e=b[f],"function"!=typeof e&&(c.push(d),Ba(f, c),c.push(":"),V(a,a.a?a.a.call(b,f,e):e,c),d=","));c.push("}");break;case "function":break;default:throw Error("Unknown type: "+typeof b);}}var W={'"':'\\"',"\\":"\\\\","/":"\\/","\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 W)return W[a];var b=a.charCodeAt(0),e="\\u";16>b?e+="000":256>b?e+="00":4096>b&&(e+="0");return W[a]=e+b.toString(16)}),'"')};ia||y||A&&(T?R(3.5):z?0<=q(G,3.5):F(3.5))||z&&(T?R(8):z?q(G,8):F(8));function Ea(a,b){for(var c=a.length,d=Array(c),e="string"==typeof a?a.split(""):a,f=0;f<c;f++)f in e&&(d[f]=b.call(void 0,e[f],f,a));return d};if(A||z){var Fa;if(Fa=z)Fa=z&&9<=G;Fa||A&&F("1.9.1")}z&&F("9");function Ga(a,b){var c={},d;for(d in a)b.call(void 0,a[d],d,a)&&(c[d]=a[d]);return c}function Ha(a,b){var c={},d;for(d in a)c[d]=b.call(void 0,a[d],d,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(h(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"==h(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=ca());b.b||(b.b=ca());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,d=Ma(c);if(!(a in d))throw new n(10,"Element does not exist in cache");var e=d[a];if("setInterval"in e){if(e.closed)throw delete d[a],new n(23,"Window has been closed.");return e}for(var f=e;f;){if(f==c.documentElement)return e;f=f.parentNode}delete d[a];throw new n(10,"Element is no longer attached to the DOM");};function Na(a,b){var c=a,d=window||ea,e;try{var c="string"==typeof c?new d.Function(c):d==window?c:new d.Function("return ("+c+").apply(null,arguments);"),f=Ka(b,d.document),k=c.apply(null,f);e={status:0,value:X(k)}}catch(r){e={status:"code"in r?r.code:13,value:{message:r.message}}}c=[];V(new ya,e,c);return c.join("")};function Oa(a,b,c,d){fa(a,b,c,function(a,b){d(Na(function(){return b},[b]))},function(a){d(Na(function(){throw new n(35,"SQL Error Code: "+a.code+". SQL Error Message: "+a.message);},[]))})}var Y=["_"],Z=g;Y[0]in Z||!Z.execScript||Z.execScript("var "+Y[0]);for(var $;Y.length&&($=Y.shift());)Y.length||void 0===Oa?Z=Z[$]?Z[$]:Z[$]={}:Z[$]=Oa;; return this._.apply(null,arguments);}.apply({navigator:typeof window!=undefined?window.navigator:null,document:typeof window!=undefined?window.document:null}, arguments);}