Ticket #12183: 0001-remove-obsolete-jshooks-files.patch

File 0001-remove-obsolete-jshooks-files.patch, 30.7 KB (added by arthuredelstein, 6 years ago)
  • deleted file src/chrome/content/jshooks.js

    From f3ad099267ceb4a86c89a8c2baeae2901ed5cc52 Mon Sep 17 00:00:00 2001
    From: Arthur Edelstein <arthuredelstein@gmail.com>
    Date: Mon, 2 Jun 2014 11:14:37 -0700
    Subject: [PATCH] remove obsolete jshooks files
    
    ---
     src/chrome/content/jshooks.js   |  362 ---------------------------------------
     src/chrome/content/jshooks4.js  |  267 -----------------------------
     src/chrome/content/torbutton.js |    1 -
     3 files changed, 630 deletions(-)
     delete mode 100644 src/chrome/content/jshooks.js
     delete mode 100644 src/chrome/content/jshooks4.js
    
    diff --git a/src/chrome/content/jshooks.js b/src/chrome/content/jshooks.js
    deleted file mode 100644
    index a47cb5a..0000000
    + -  
    1 // Bug 1506 P0: These hooks are only relevant to FF 3.5 and below.
    2 
    3 window.__HookObjects = function() {
    4   if (typeof(window.__tb_hooks_ran) === "boolean") {
    5       return false;
    6   }
    7 
    8 
    9   /* For reference/debugging only:
    10   if(false && window.__tb_set_uagent===true) {
    11       var tmp_oscpu = window.__tb_oscpu;
    12       var tmp_platform = window.__tb_platform;
    13       var tmp_productSub = window.__tb_productSub;
    14 
    15       try {
    16           if(!(window.navigator.__proto__ == null) ||
    17                   typeof(window.navigator.__defineGetter__) === "function") {
    18               var cE = window.navigator.cookieEnabled;
    19               var lang = window.navigator.language;
    20               var uA = window.navigator.userAgent;
    21               var v = window.navigator.vendor;
    22               var vS = window.navigator.vendorSub;
    23               var jE = window.navigator.javaEnabled;
    24               var pl = new window.Array();
    25               var mT = new window.Object();
    26               //var pl = window.navigator.plugins;
    27               //var mT = window.navigator.mimeTypes;
    28 
    29               window.navigator.__defineGetter__("appCodeName", function() { return "Mozilla";});
    30               window.navigator.__defineGetter__("appName", function() { return "Netscape";});
    31               window.navigator.__defineGetter__("appVersion", function() { return "5.0";});
    32               window.navigator.__defineGetter__("buildID", function() { return 0;});
    33               window.navigator.__defineGetter__("cookieEnabled", function() { return cE;});
    34               window.navigator.__defineGetter__("language", function() { return lang;});
    35               window.navigator.__defineGetter__("mimeTypes", function() { return mT;});
    36               window.navigator.__defineGetter__("onLine", function() { return true;});
    37               window.navigator.__defineGetter__("oscpu", function() { return tmp_oscpu;});
    38               window.navigator.__defineGetter__("platform", function() { return tmp_platform;});
    39               window.navigator.__defineGetter__("plugins", function() { return pl;});
    40               window.navigator.__defineGetter__("product", function() { return "Gecko";});
    41               window.navigator.__defineGetter__("productSub", function() { return tmp_productSub;});
    42               window.navigator.__defineGetter__("securityPolicy", function() { return "";});
    43               window.navigator.__defineGetter__("userAgent", function() { return uA;});
    44               window.navigator.__defineGetter__("vendor", function() { return v;});
    45               window.navigator.__defineGetter__("vendorSub", function() { return vS;});
    46               window.navigator.__defineGetter__("javaEnabled", function() { return jE;});
    47               window.navigator.__proto__ = null;
    48           }
    49       } catch(e) {
    50       }
    51   } */
    52 
    53 
    54   /* Hrmm.. Is it possible this breaks plugin install or other weird shit
    55      for non-windows OS's? */
    56   if(window.__tb_set_uagent===true) {
    57       var tmp_oscpu = window.__tb_oscpu;
    58       var tmp_platform = window.__tb_platform;
    59       var tmp_productSub = window.__tb_productSub;
    60       var tmp_locale = window.__tb_locale;
    61 
    62       // This is just unreasonable.. Firefox caches
    63       // window.navigator.__proto__ between same-origin loads of a document.
    64       // So this means when we null it out, we lose most of the navigator
    65       // object for subsequent loads. I tried doing the whole-object hooks
    66       // like we do for Date, screen, and history, but it seems to behave
    67       // like Date upon delete, allowing unmasking for that case. Talk about
    68       // rock+hard place.
    69       try {
    70           if(!(window.navigator.__proto__ == null) ||
    71              typeof(window.navigator.__defineGetter__) === "function") {
    72               var tmpNav = new window.Object();
    73               for(var i in window.navigator) {
    74                   tmpNav[i] = window.navigator[i];
    75                  
    76                   // XPCNative objects are special for some reason. So far,
    77                   // all we have are "plugins" and mimeTypes, which
    78                   // are empty anyways. Disable them.
    79                   //if(tmpNav[i].toString().indexOf("XPCNative") != -1) {
    80                   if(i === "plugins" || i === "mimeTypes") {
    81                       tmpNav[i] = new Array();
    82                   }
    83                   (function() { // crazy scope hack to preserve i
    84                       var holder = i;
    85                       window.navigator.__defineGetter__(i, function() { return tmpNav[holder];});
    86                   })();
    87               }
    88 
    89               if(tmp_locale != false) {
    90                   window.navigator.__defineGetter__("language", function() { return tmp_locale;});
    91               }
    92               window.navigator.__defineGetter__("oscpu", function() { return tmp_oscpu;});
    93               window.navigator.__defineGetter__("productSub", function() { return tmp_productSub;});
    94               window.navigator.__defineGetter__("buildID", function() { return 0;});
    95               window.navigator.__proto__ = null;
    96           }
    97       } catch(e) {
    98       }
    99   }
    100 
    101   // No pref for this.. Should be mostly harmless..
    102   if(true) {
    103       var origHeight = window.innerHeight;
    104       var origWidth = window.innerWidth;
    105       window.__proto__.__defineGetter__("innerHeight", function() { return Math.round(origHeight/50.0)*50;});
    106       window.__proto__.__defineGetter__("innerWidth", function() { return Math.round(origWidth/50.0)*50;});
    107       window.__proto__.__defineGetter__("outerWidth", function() { return window.innerWidth;});
    108       window.__proto__.__defineGetter__("outerHeight", function() { return window.innerHeight;});
    109       window.__proto__.__defineGetter__("screenX", function() { return 0;});
    110       window.__proto__.__defineGetter__("screenY", function() { return 0;});
    111       window.__proto__.__defineGetter__("pageXOffset", function() { return 0;});
    112       window.__proto__.__defineGetter__("pageYOffset", function() { return 0;});
    113 
    114       // Wrap in anonymous function to protect scr variables just in case.
    115       (function () {
    116           // We can't define individual getters/setters for window.screen
    117           // for some reason. works in html but not in these hooks.. No idea why
    118 
    119           var scr = new Object();
    120           var origScr = window.screen;
    121           scr.__defineGetter__("height", function() { return window.innerHeight; });
    122           scr.__defineGetter__("width", function() { return window.innerWidth; });
    123 
    124           scr.__defineGetter__("availTop", function() { return 0;});
    125           scr.__defineGetter__("availLeft", function() { return 0;});
    126 
    127           scr.__defineGetter__("top", function() { return 0;});
    128           scr.__defineGetter__("left", function() { return 0;});
    129 
    130           scr.__defineGetter__("availHeight", function() { return window.innerHeight;});
    131           scr.__defineGetter__("availWidth", function() { return window.innerWidth;});
    132 
    133           scr.__defineGetter__("colorDepth", function() { return origScr.colorDepth;});
    134           scr.__defineGetter__("pixelDepth", function() { return origScr.pixelDepth;});
    135 
    136           scr.__defineGetter__("availTop", function() { return 0;});
    137           scr.__defineGetter__("availLeft", function() { return 0;});
    138 
    139           window.__defineGetter__("screen", function() { return scr; });
    140           window.__defineSetter__("screen", function(a) { return; });
    141           window.__proto__.__defineGetter__("screen", function() { return scr; });
    142 
    143           // Needed for Firefox bug 418983:
    144           with(window) {
    145               var screen = scr;
    146           }
    147 
    148       })();
    149 
    150   }
    151  
    152 
    153   if(window.__tb_hook_date == true) { // don't feel like indenting this
    154 
    155   /* Timezone fix for http://gemal.dk/browserspy/css.html */
    156   var reparseDate = function(d, str) {
    157     /* Rules:
    158      *   - If they specify a timezone, it is converted to local
    159      *     time. All getter fucntions then convert properly to
    160      *     UTC. No mod needed.
    161      *   - If they specify UTC timezone, then it is converted
    162      *     to local time. All getter functions then convert back.
    163      *     No mod needed.
    164      *   - If they specify NO timezone, it is local time.
    165      *     The UTC conversion then reveals the offset. Fix.
    166      */
    167    
    168     /* Step 1: Remove everything inside ()'s (they are "comments") */
    169     var s = str.toLowerCase();
    170     var re = new RegExp('\\(.*\\)', "gm");
    171     s = s.replace(re, "");
    172 
    173     /* Step 2: Look for +/-. If found, do nothing */
    174     if(s.indexOf("+") == -1 && s.indexOf("-") == -1) {
    175       /* Step 3: Look for timezone string from
    176        * http://lxr.mozilla.org/seamonkey/source/js/src/jsdate.c
    177        */
    178       if(s.indexOf(" gmt") == -1 && s.indexOf(" ut") == -1 &&
    179          s.indexOf(" est") == -1 && s.indexOf(" edt") == -1 &&
    180          s.indexOf(" cst") == -1 && s.indexOf(" cdt") == -1 &&
    181          s.indexOf(" mst") == -1 && s.indexOf(" mdt") == -1 &&
    182          s.indexOf(" pst") == -1 && s.indexOf(" pdt")) {
    183         /* No timezone specified. Adjust. */
    184         d.setTime(d.getTime()-(d.getTimezoneOffset()*60000));
    185       }
    186     }
    187   }
    188  
    189   var origDate = window.Date;
    190   var newDate = function() {
    191     /* DO NOT make 'd' a member! EvilCode will use it! */
    192     var d;
    193     var a = arguments;
    194     /* apply doesn't seem to work for constructors :( */
    195     if(arguments.length == 0) d=new origDate();
    196     if(arguments.length == 1) d=new origDate(a[0]);
    197     if(arguments.length == 3) d=new origDate(a[0],a[1],a[2]);
    198     if(arguments.length == 4) d=new origDate(a[0],a[1],a[2],a[3]);
    199     if(arguments.length == 5) d=new origDate(a[0],a[1],a[2],a[3],a[4]);
    200     if(arguments.length == 6) d=new origDate(a[0],a[1],a[2],a[3],a[4],a[5]);
    201     if(arguments.length == 7) d=new origDate(a[0],a[1],a[2],a[3],a[4],a[5],a[6]);
    202     if(arguments.length > 7) d=new origDate();
    203 
    204     if(arguments.length > 0) {
    205       if((arguments.length == 1) && typeof(a[0]) == "string") {
    206         reparseDate(d,a[0]);
    207       } else if(arguments.length > 1) {
    208         /* Numerical value. No timezone given, adjust. */
    209         d.setTime(d.getTime()-(d.getTimezoneOffset()*60000));
    210       }
    211     }
    212 
    213     // XXX: the native valueOf seems to sometimes return toString and
    214     // sometimes return getTime depending on context (which we can't detect)
    215     // It seems as though we can't win here..
    216     window.Date.prototype.valueOf=function(){return d.getTime()};
    217     window.Date.prototype.getTime=function(){return d.getTime();} /* UTC already */
    218     window.Date.prototype.getFullYear=function(){return d.getUTCFullYear();} 
    219     window.Date.prototype.getYear=function() {return d.getYear();}
    220     window.Date.prototype.getMonth=function(){return d.getUTCMonth();}
    221     window.Date.prototype.getDate=function() {return d.getUTCDate();}
    222     window.Date.prototype.getDay=function() {return d.getUTCDay();}
    223     window.Date.prototype.getHours=function(){return d.getUTCHours();}
    224     window.Date.prototype.getMinutes=function(){return d.getUTCMinutes();}
    225     window.Date.prototype.getSeconds=function(){return d.getUTCSeconds();}
    226     window.Date.prototype.getMilliseconds=function(){return d.getUTCMilliseconds();}
    227     window.Date.prototype.getTimezoneOffset=function(){return 0;}
    228  
    229     window.Date.prototype.setTime =
    230        function(x) {return d.setTime(x);}
    231     window.Date.prototype.setFullYear=function(x){return d.setUTCFullYear(x);}
    232     window.Date.prototype.setYear=function(x){return d.setYear(x);}
    233     window.Date.prototype.setMonth=function(x){return d.setUTCMonth(x);}
    234     window.Date.prototype.setDate=function(x){return d.setUTCDate(x);}
    235     window.Date.prototype.setDay=function(x){return d.setUTCDay(x);}
    236     window.Date.prototype.setHours=function(x){return d.setUTCHours(x);}
    237     window.Date.prototype.setMinutes=function(x){return d.setUTCMinutes(x);}
    238     window.Date.prototype.setSeconds=function(x){return d.setUTCSeconds(x);}
    239     window.Date.prototype.setMilliseconds=
    240        function(x) {return d.setUTCMilliseconds(x);}
    241  
    242     window.Date.prototype.getUTCFullYear=function(){return d.getUTCFullYear();} 
    243     window.Date.prototype.getUTCMonth=function(){return d.getUTCMonth();}
    244     window.Date.prototype.getUTCDate=function() {return d.getUTCDate();}
    245     window.Date.prototype.getUTCDay=function() {return d.getUTCDay();}
    246     window.Date.prototype.getUTCHours=function(){return d.getUTCHours();}
    247     window.Date.prototype.getUTCMinutes=function(){return d.getUTCMinutes();}
    248     window.Date.prototype.getUTCSeconds=function(){return d.getUTCSeconds();}
    249     window.Date.prototype.getUTCMilliseconds=
    250        function(){return d.getUTCMilliseconds();}
    251      
    252     window.Date.prototype.setUTCFullYear=function(x){return d.setUTCFullYear(x);}
    253     window.Date.prototype.setUTCMonth=function(x){return d.setUTCMonth(x);}
    254     window.Date.prototype.setUTCDate=function(x){return d.setUTCDate(x);}
    255     window.Date.prototype.setUTCDay=function(x){return d.setUTCDay(x);}
    256     window.Date.prototype.setUTCHours=function(x){return d.setUTCHours(x);}
    257     window.Date.prototype.setUTCMinutes=function(x){return d.setUTCMinutes(x);}
    258     window.Date.prototype.setUTCSeconds=function(x){return d.setUTCSeconds(x);}
    259     window.Date.prototype.setUTCMilliseconds=
    260         function(x) {return d.setUTCMilliseconds(x);}
    261  
    262     window.Date.prototype.toUTCString=function(){return d.toUTCString();}
    263     window.Date.prototype.toGMTString=function(){return d.toGMTString();}
    264     window.Date.prototype.toString=function(){return d.toUTCString();}
    265     window.Date.prototype.toLocaleString=function(){return d.toUTCString();}
    266    
    267     /* Fuck 'em if they can't take a joke: */
    268     window.Date.prototype.toLocaleTimeString=function(){return d.toUTCString();}
    269     window.Date.prototype.toLocaleDateString=function(){return d.toUTCString();}
    270     window.Date.prototype.toDateString=function(){return d.toUTCString();}
    271     window.Date.prototype.toTimeString=function(){return d.toUTCString();}
    272    
    273     /* Hack to solve the problem of multiple date objects
    274      * all sharing the same lexically scoped d every time a new one is
    275      * created. This hack creates a fresh new prototype reference for
    276      * the next object to use with a different d binding.
    277      * It doesn't break stuff because at the start of this function,
    278      * the interpreter grabbed a reference to Date.prototype. During
    279      * this function we modified Date.prototype to create the new methods
    280      * with the lexically scoped d reference.
    281      */
    282 
    283     // valueOf gets called for implicit string conversion??
    284     window.Date.prototype = window.eval(window.Object.prototype.toSource());
    285     return d.toUTCString();
    286   }
    287 
    288   // Need to do this madness so that we use the window's notion of Function
    289   // for the constructor. If this is not done, then changes to Function
    290   // and Object in the real window are not propogated to Date (for example,
    291   // to extend the Date class with extra functions via a generic inheritance
    292   // framework added onto Object - this is done by livejournal and others)
    293   var newWrappedDate = window.eval("function() { return newDate(); }");
    294 
    295   newWrappedDate.parse=function(s) {
    296     var d = new origDate(s);
    297     if(typeof(s) == "string") reparseDate(d, s);
    298     return d.getTime();   
    299   }
    300 
    301   newWrappedDate.now=function(){return origDate.now();}
    302   newWrappedDate.UTC=function(){return origDate.apply(origDate, arguments); }
    303 
    304   // d = new Date();
    305   // d.__proto__ === Date.prototype
    306   // d.constructor === Date
    307   // d.__proto__ === d.constructor.prototype
    308   // Date.prototype.__proto__  ===  Date.prototype.constructor.prototype
    309   // window.__proto__ === Window.prototypea
    310  
    311   // XXX: This is still not enough.. But at least we get to claim the
    312   // unmasking is violating ECMA-262 by allowing the deletion of var's
    313   // (FF Bug 419598)
    314   with(window) {
    315     var Date = newWrappedDate;
    316   }
    317 
    318   } // window.__tb_hook_date == true
    319 
    320   with(window) {
    321       XPCNativeWrapper = function(a) { return a; };
    322   }
    323   with(window.__proto__) {
    324       XPCNativeWrapper = function(a) { return a; };
    325   }
    326 
    327   // Gain access to the implict global object (which interestingly claims
    328   // to be a 'Window' but is not the same class as 'window'...) and
    329   // hide XPCNativeWrapper there.
    330   // This seems no longer necessary in FF2.0.0.13+, and may break FF3?
    331   //with(window.valueOf.call().__proto__) {
    332   //    XPCNativeWrapper = function(a) { return a; };
    333   //}
    334 
    335   // FIXME: Commenting this may open us to unmasking, but allows the hooks to
    336   // work on FF4. Since we lost the bulletproof resolution masking battle to
    337   // CSS3 anyways, let's just do what we can.
    338   //window.__proto__ = null; // Prevent delete from unmasking our properties.
    339   return true;
    340 }
    341 
    342 if (typeof(window.__HookObjects) != "undefined") {
    343     var res = 23;
    344 
    345     if(!window.__HookObjects()) {
    346         res = 13;
    347     }
    348 
    349     window.__HookObjects = undefined;
    350     delete window['__HookObjects'];
    351     delete window['__CheckFlag'];
    352     delete window['__tb_set_uagent'];
    353     delete window['__tb_oscpu'];
    354     delete window['__tb_platform'];
    355     delete window['__tb_productSub'];
    356 
    357     window.__tb_hooks_ran = true;
    358 
    359     res; // Secret result code.
    360 } else {
    361     42;
    362 }
  • deleted file src/chrome/content/jshooks4.js

    diff --git a/src/chrome/content/jshooks4.js b/src/chrome/content/jshooks4.js
    deleted file mode 100644
    index c15e5c5..0000000
    + -  
    1 // Bug 1506 P1: We're almost certainly going to replace this stuff with direct
    2 // patches of the JS VM.
    3 
    4 window.__HookObjects = function() {
    5   if (typeof(window.__tb_hooks_ran) === "boolean") {
    6       return false;
    7   }
    8 
    9   // No pref for this.. Should be mostly harmless..
    10   if(true) {
    11       // Wrap in anonymous function to protect scr variables just in case.
    12       (function () {
    13           var origHeight = window.innerHeight;
    14           var origWidth = window.innerWidth;
    15 
    16           Object.defineProperty(window.__proto__, "innerWidth",
    17                           {get: function() { return Math.round(origWidth/50.0)*50;},
    18                           configurable: false});
    19           Object.defineProperty(window.__proto__, "innerHeight",
    20                           {get: function() { return Math.round(origHeight/50.0)*50;},
    21                           configurable: false});
    22           Object.defineProperty(window.__proto__, "outerWidth",
    23                           {get: function() { return Math.round(origWidth/50.0)*50;},
    24                           configurable: false});
    25           Object.defineProperty(window.__proto__, "outerHeight",
    26                           {get: function() { return Math.round(origHeight/50.0)*50;},
    27                           configurable: false});
    28           Object.defineProperty(window.__proto__, "screenX",
    29                           {get: function() { return 0;},
    30                           configurable: false});
    31           Object.defineProperty(window.__proto__, "screenY",
    32                           {get: function() { return 0;},
    33                           configurable: false});
    34           Object.defineProperty(MouseEvent.prototype, "screenX",
    35                           {get: function() { return this.clientX;},
    36                           configurable: false});
    37           Object.defineProperty(MouseEvent.prototype, "screenY",
    38                           {get: function() { return this.clientY;},
    39                           configurable: false});
    40 
    41           // We can't define individual getters/setters for window.screen
    42           // for some reason. works in html but not in these hooks.. No idea why
    43 
    44           var scr = new Object();
    45           var origScr = window.screen;
    46           scr.__defineGetter__("height", function() { return window.innerHeight; });
    47           scr.__defineGetter__("width", function() { return window.innerWidth; });
    48 
    49           scr.__defineGetter__("availTop", function() { return 0;});
    50           scr.__defineGetter__("availLeft", function() { return 0;});
    51 
    52           scr.__defineGetter__("top", function() { return 0;});
    53           scr.__defineGetter__("left", function() { return 0;});
    54 
    55           scr.__defineGetter__("availHeight", function() { return window.innerHeight;});
    56           scr.__defineGetter__("availWidth", function() { return window.innerWidth;});
    57 
    58           scr.__defineGetter__("colorDepth", function() { return origScr.colorDepth;});
    59           scr.__defineGetter__("pixelDepth", function() { return origScr.pixelDepth;});
    60 
    61           scr.__defineGetter__("availTop", function() { return 0;});
    62           scr.__defineGetter__("availLeft", function() { return 0;});
    63 
    64           Object.defineProperty(window.__proto__, "screen",
    65                       {get: function() { return scr;},
    66                       configurable: false});
    67 
    68       })();
    69 
    70   }
    71 
    72   if(window.__tb_hook_date == true) { // don't feel like indenting this
    73   // XXX: events should not have timeStamp, unless they are of type MozBeforePaint?
    74 
    75   /* Timezone fix for http://gemal.dk/browserspy/css.html */
    76   var reparseDate = function(d, str) {
    77     /* Rules:
    78      *   - If they specify a timezone, it is converted to local
    79      *     time. All getter fucntions then convert properly to
    80      *     UTC. No mod needed.
    81      *   - If they specify UTC timezone, then it is converted
    82      *     to local time. All getter functions then convert back.
    83      *     No mod needed.
    84      *   - If they specify NO timezone, it is local time.
    85      *     The UTC conversion then reveals the offset. Fix.
    86      */
    87    
    88     /* Step 1: Remove everything inside ()'s (they are "comments") */
    89     var s = str.toLowerCase();
    90     var re = new RegExp('\\(.*\\)', "gm");
    91     s = s.replace(re, "");
    92 
    93     /* Step 2: Look for +/-. If found, do nothing */
    94     if(s.indexOf("+") == -1 && s.indexOf("-") == -1) {
    95       /* Step 3: Look for timezone string from
    96        * http://lxr.mozilla.org/seamonkey/source/js/src/jsdate.c
    97        */
    98       if(s.indexOf(" gmt") == -1 && s.indexOf(" ut") == -1 &&
    99          s.indexOf(" est") == -1 && s.indexOf(" edt") == -1 &&
    100          s.indexOf(" cst") == -1 && s.indexOf(" cdt") == -1 &&
    101          s.indexOf(" mst") == -1 && s.indexOf(" mdt") == -1 &&
    102          s.indexOf(" pst") == -1 && s.indexOf(" pdt")) {
    103         /* No timezone specified. Adjust. */
    104         d.setTime(d.getTime()-(d.getTimezoneOffset()*60000));
    105       }
    106     }
    107   }
    108  
    109   // XXX: Each origin should have its own unique offset from the real date
    110   // XXX: Subsequent calls to the ms timer should be monotonically increasing, but randomized
    111 
    112   var origDate = window.Date;
    113   var newDate = function() {
    114     /* DO NOT make 'd' a member! EvilCode will use it! */
    115     var d;
    116     var a = arguments;
    117     /* apply doesn't seem to work for constructors :( */
    118     if(arguments.length == 0) d=new origDate();
    119     if(arguments.length == 1) d=new origDate(a[0]);
    120     if(arguments.length == 3) d=new origDate(a[0],a[1],a[2]);
    121     if(arguments.length == 4) d=new origDate(a[0],a[1],a[2],a[3]);
    122     if(arguments.length == 5) d=new origDate(a[0],a[1],a[2],a[3],a[4]);
    123     if(arguments.length == 6) d=new origDate(a[0],a[1],a[2],a[3],a[4],a[5]);
    124     if(arguments.length == 7) d=new origDate(a[0],a[1],a[2],a[3],a[4],a[5],a[6]);
    125     if(arguments.length > 7) d=new origDate();
    126 
    127     if(arguments.length > 0) {
    128       if((arguments.length == 1) && typeof(a[0]) == "string") {
    129         reparseDate(d,a[0]);
    130       } else if(arguments.length > 1) {
    131         /* Numerical value. No timezone given, adjust. */
    132         d.setTime(d.getTime()-(d.getTimezoneOffset()*60000));
    133       }
    134     }
    135 
    136     // XXX: the native valueOf seems to sometimes return toString and
    137     // sometimes return getTime depending on context (which we can't detect)
    138     // It seems as though we can't win here..
    139     window.Date.prototype.valueOf=function(){return d.getTime()};
    140     window.Date.prototype.getTime=function(){return d.getTime();} /* UTC already */
    141     window.Date.prototype.getFullYear=function(){return d.getUTCFullYear();} 
    142     window.Date.prototype.getYear=function() {return d.getYear();}
    143     window.Date.prototype.getMonth=function(){return d.getUTCMonth();}
    144     window.Date.prototype.getDate=function() {return d.getUTCDate();}
    145     window.Date.prototype.getDay=function() {return d.getUTCDay();}
    146     window.Date.prototype.getHours=function(){return d.getUTCHours();}
    147     window.Date.prototype.getMinutes=function(){return d.getUTCMinutes();}
    148     window.Date.prototype.getSeconds=function(){return d.getUTCSeconds();}
    149     window.Date.prototype.getMilliseconds=function(){return d.getUTCMilliseconds();}
    150     window.Date.prototype.getTimezoneOffset=function(){return 0;}
    151  
    152     window.Date.prototype.setTime =
    153        function(x) {return d.setTime(x);}
    154     window.Date.prototype.setFullYear=function(x){return d.setUTCFullYear(x);}
    155     window.Date.prototype.setYear=function(x){return d.setYear(x);}
    156     window.Date.prototype.setMonth=function(x){return d.setUTCMonth(x);}
    157     window.Date.prototype.setDate=function(x){return d.setUTCDate(x);}
    158     window.Date.prototype.setDay=function(x){return d.setUTCDay(x);}
    159     window.Date.prototype.setHours=function(x){return d.setUTCHours(x);}
    160     window.Date.prototype.setMinutes=function(x){return d.setUTCMinutes(x);}
    161     window.Date.prototype.setSeconds=function(x){return d.setUTCSeconds(x);}
    162     window.Date.prototype.setMilliseconds=
    163        function(x) {return d.setUTCMilliseconds(x);}
    164  
    165     window.Date.prototype.getUTCFullYear=function(){return d.getUTCFullYear();} 
    166     window.Date.prototype.getUTCMonth=function(){return d.getUTCMonth();}
    167     window.Date.prototype.getUTCDate=function() {return d.getUTCDate();}
    168     window.Date.prototype.getUTCDay=function() {return d.getUTCDay();}
    169     window.Date.prototype.getUTCHours=function(){return d.getUTCHours();}
    170     window.Date.prototype.getUTCMinutes=function(){return d.getUTCMinutes();}
    171     window.Date.prototype.getUTCSeconds=function(){return d.getUTCSeconds();}
    172     window.Date.prototype.getUTCMilliseconds=
    173        function(){return d.getUTCMilliseconds();}
    174      
    175     window.Date.prototype.setUTCFullYear=function(x){return d.setUTCFullYear(x);}
    176     window.Date.prototype.setUTCMonth=function(x){return d.setUTCMonth(x);}
    177     window.Date.prototype.setUTCDate=function(x){return d.setUTCDate(x);}
    178     window.Date.prototype.setUTCDay=function(x){return d.setUTCDay(x);}
    179     window.Date.prototype.setUTCHours=function(x){return d.setUTCHours(x);}
    180     window.Date.prototype.setUTCMinutes=function(x){return d.setUTCMinutes(x);}
    181     window.Date.prototype.setUTCSeconds=function(x){return d.setUTCSeconds(x);}
    182     window.Date.prototype.setUTCMilliseconds=
    183         function(x) {return d.setUTCMilliseconds(x);}
    184  
    185     window.Date.prototype.toUTCString=function(){return d.toUTCString();}
    186     window.Date.prototype.toGMTString=function(){return d.toGMTString();}
    187     window.Date.prototype.toString=function(){return d.toUTCString();}
    188     window.Date.prototype.toLocaleString=function(){return d.toUTCString();}
    189    
    190     /* Fuck 'em if they can't take a joke: */
    191     window.Date.prototype.toLocaleTimeString=function(){return d.toUTCString();}
    192     window.Date.prototype.toLocaleDateString=function(){return d.toUTCString();}
    193     window.Date.prototype.toDateString=function(){return d.toUTCString();}
    194     window.Date.prototype.toTimeString=function(){return d.toUTCString();}
    195    
    196     /* Hack to solve the problem of multiple date objects
    197      * all sharing the same lexically scoped d every time a new one is
    198      * created. This hack creates a fresh new prototype reference for
    199      * the next object to use with a different d binding.
    200      * It doesn't break stuff because at the start of this function,
    201      * the interpreter grabbed a reference to Date.prototype. During
    202      * this function we modified Date.prototype to create the new methods
    203      * with the lexically scoped d reference.
    204      */
    205 
    206     // valueOf gets called for implicit string conversion??
    207     window.Date.prototype = window.eval(window.Object.prototype.toSource());
    208     return d.toUTCString();
    209   }
    210 
    211   // Need to do this madness so that we use the window's notion of Function
    212   // for the constructor. If this is not done, then changes to Function
    213   // and Object in the real window are not propogated to Date (for example,
    214   // to extend the Date class with extra functions via a generic inheritance
    215   // framework added onto Object - this is done by livejournal and others)
    216   var newWrappedDate = window.eval("function() { return newDate(); }");
    217 
    218   newWrappedDate.parse=function(s) {
    219     var d = new origDate(s);
    220     if(typeof(s) == "string") reparseDate(d, s);
    221     return d.getTime();   
    222   }
    223 
    224   newWrappedDate.now=function(){return origDate.now();}
    225   newWrappedDate.UTC=function(){return origDate.apply(origDate, arguments); }
    226 
    227   // d = new Date();
    228   // d.__proto__ === Date.prototype
    229   // d.constructor === Date
    230   // d.__proto__ === d.constructor.prototype
    231   // Date.prototype.__proto__  ===  Date.prototype.constructor.prototype
    232   // window.__proto__ === Window.prototypea
    233 
    234   Object.defineProperty(window.__proto__, "Date",
    235                       {get: function() { return newWrappedDate;},
    236                       configurable: false});
    237 
    238   } // window.__tb_hook_date == true
    239 
    240   //Object.defineProperty(window.Components.__proto__, "lookupMethod",
    241   //        {get: function() { return function (a,b) { return function() { return a[b]; }; };},
    242   //         configurable: false});
    243 
    244   return true;
    245 }
    246 
    247 if (typeof(window.__HookObjects) != "undefined") {
    248     var res = 23;
    249 
    250     if(!window.__HookObjects()) {
    251         res = 13;
    252     }
    253 
    254     window.__HookObjects = undefined;
    255     delete window['__HookObjects'];
    256     delete window['__CheckFlag'];
    257     delete window['__tb_set_uagent'];
    258     delete window['__tb_oscpu'];
    259     delete window['__tb_platform'];
    260     delete window['__tb_productSub'];
    261 
    262     window.__tb_hooks_ran = true;
    263 
    264     res; // Secret result code.
    265 } else {
    266     42;
    267 }
  • src/chrome/content/torbutton.js

    diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js
    index 6161995..070b1e7 100644
    a b const k_tb_tor_check_failed_topic = "Torbutton:TorCheckFailed"; 
    2121// status
    2222var m_tb_wasinited = false;
    2323var m_tb_prefs = false;
    24 var m_tb_jshooks = false;
    2524var m_tb_plugin_string = false;
    2625var m_tb_is_main_window = false;
    2726var m_tb_hidden_browser = false;