[or-cvs] r11751: Restore doc checking code removed in r11723. Heh, prob shoul (in torbutton/trunk/src: . chrome/content)

mikeperry at seul.org mikeperry at seul.org
Wed Oct 3 05:47:14 UTC 2007


Author: mikeperry
Date: 2007-10-03 01:47:14 -0400 (Wed, 03 Oct 2007)
New Revision: 11751

Modified:
   torbutton/trunk/src/chrome/content/torbutton.js
   torbutton/trunk/src/install.rdf
Log:

Restore doc checking code removed in r11723. Heh, prob
shouldn't have removed this code. Turns out it's needed until
we remove all the self-checks. (The XPCNativeWrapper for the
contentwindow gets cleared on back/forwared, but the
wrappedJSObject does not).  Thanks to Kyle Williams for
finding this bug, among other things.



Modified: torbutton/trunk/src/chrome/content/torbutton.js
===================================================================
--- torbutton/trunk/src/chrome/content/torbutton.js	2007-10-02 20:35:23 UTC (rev 11750)
+++ torbutton/trunk/src/chrome/content/torbutton.js	2007-10-03 05:47:14 UTC (rev 11751)
@@ -1058,6 +1058,28 @@
         return; // Ran already
     }
 
+    if(torbutton_check_flag(doc, "__tb_did_hook")) {
+        torbutton_log(2, "Already did hook " 
+                + torbutton_check_flag(doc, "__tb_did_hook"));
+        /* XXX: Remove this once bug #460 is resolved */
+        var wm = Components.classes["@torproject.org/content-window-mapper;1"]
+            .getService(Components.interfaces.nsISupports)
+            .wrappedJSObject;
+        var browser = wm.getBrowserForContentWindow(win);
+        if(!browser) win.alert("No window found!");
+
+        /* hrmm.. would doc.isSupported("javascript") 
+         * or doc.implementation.hasFeature() work better? */
+        if(doc.contentType.indexOf("text/html") != -1 && 
+                browser.__tb_js_state == false &&
+                !torbutton_check_flag(win.wrappedJSObject, 
+                    "__tb_hooks_ran")) {
+            torbutton_log(5, "FALSE WIN HOOKING. Please report bug+website!");
+            win.alert("False win hooking. Please report bug+website!");
+        }
+        return; // Ran already
+    }
+
     var wm = Components.classes["@torproject.org/content-window-mapper;1"]
         .getService(Components.interfaces.nsISupports)
         .wrappedJSObject;
@@ -1089,6 +1111,7 @@
             || !m_tb_prefs.getBoolPref('extensions.torbutton.kill_bad_js')) {
         torbutton_log(2, "Finished non-hook of: " + doc.location);
         torbutton_set_flag(win, "__tb_did_hook");
+        torbutton_set_flag(doc, "__tb_did_hook");
         return;
     }
 
@@ -1117,6 +1140,7 @@
         var result = Components.utils.evalInSandbox(str2, s);
         if(result == 23) { // secret confirmation result code.
             torbutton_set_flag(win, "__tb_did_hook");
+            torbutton_set_flag(doc, "__tb_did_hook");
         } else {
             win.alert("Sandbox evaluation failed. Date hooks not applied!");
             torbutton_log(4, "Hook evaluation failure at " + doc.location);

Modified: torbutton/trunk/src/install.rdf
===================================================================
--- torbutton/trunk/src/install.rdf	2007-10-02 20:35:23 UTC (rev 11750)
+++ torbutton/trunk/src/install.rdf	2007-10-03 05:47:14 UTC (rev 11751)
@@ -6,7 +6,7 @@
         <em:name>Torbutton</em:name>
         <em:creator>Scott Squires &amp; Mike Perry</em:creator>
         <em:id>{e0204bd5-9d31-402b-a99d-a6aa8ffebdca}</em:id>
-        <em:version>1.1.8-alpha</em:version>
+        <em:version>1.1.8-alpha-dev</em:version>
         <em:homepageURL>http://torbutton.torproject.org/dev/</em:homepageURL>
         <em:optionsURL>chrome://torbutton/content/preferences.xul</em:optionsURL>
         <em:iconURL>chrome://torbutton/skin/tor.png</em:iconURL>



More information about the tor-commits mailing list