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

[or-cvs] [torbutton/master 01/30] 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: c59c9d0c6adb713b90a06339338bad5c3457806f

---
 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 961d7e6..293c817 100644
--- a/src/chrome/content/torbutton.js
+++ b/src/chrome/content/torbutton.js
@@ -2064,6 +2064,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);
@@ -2076,10 +2077,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