[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] [torbutton/maint-1.2 01/37] Fix bug 1283 - Disable JS event handlers on toggle.



Author: Mike Perry <mikeperry-git@xxxxxxxxxx>
Date: Tue, 16 Mar 2010 17:05:19 -0700
Subject: Fix bug 1283 - Disable JS event handlers on toggle.
Commit: 29ac3cbd6654115d01dc109cbc9ca6811fadfe29

---
 src/chrome/content/torbutton.js |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js
index f388d52..6d526a2 100644
--- a/src/chrome/content/torbutton.js
+++ b/src/chrome/content/torbutton.js
@@ -1974,6 +1974,7 @@ function torbutton_jar_certs(mode) {
 // -------------- JS/PLUGIN HANDLING CODE ---------------------
 
 function torbutton_check_js_tag(browser, tor_enabled, js_enabled) {
+    var eventSuppressor = null;
     if (typeof(browser.__tb_tor_fetched) == 'undefined') {
         try {
             torbutton_log(5, "UNTAGGED WINDOW at: "+browser.src);
@@ -1986,10 +1987,26 @@ function torbutton_check_js_tag(browser, tor_enabled, js_enabled) {
         browser.__tb_tor_fetched = !tor_enabled;
     }
 
+    /* Solution from: https://bugzilla.mozilla.org/show_bug.cgi?id=409737 */
+    try {
+        if (!browser.contentWindow)
+            torbutton_log(3, "No content window to disable JS events.");
+        else
+            eventSuppressor = browser.contentWindow.
+                QueryInterface(Components.interfaces.nsIInterfaceRequestor).
+                       getInterface(Ci.nsIDOMWindowUtils);
+    } catch(e) {
+        torbutton_log(4, "Failed to disable JS events: "+e)
+    }
+
     if(browser.__tb_tor_fetched == tor_enabled) { // States match, js ok 
         browser.docShell.allowJavascript = js_enabled;
+        if (eventSuppressor)
+            eventSuppressor.suppressEventHandling(!js_enabled);
     } else { // States differ or undefined, js not ok 
         browser.docShell.allowJavascript = false;
+        if (eventSuppressor)
+            eventSuppressor.suppressEventHandling(true);
     }
 }
 
-- 
1.6.5