]> git.donarmstrong.com Git - dactyl.git/blobdiff - common/content/disable-acr.jsm
Import r6948 from upstream hg supporting Firefox up to 24.*
[dactyl.git] / common / content / disable-acr.jsm
index 80b9032f5231ec9faee0de6a41491783ad272577..86e55c4a4a05021f1131e2a5a175ea98e6c1b376 100644 (file)
@@ -8,22 +8,23 @@ const OVERLAY_URLS = [
     "chrome://mozapps/content/extensions/extensions.xul"
 ];
 
-const Ci = Components.interfaces;
-const Cu = Components.utils;
+let { interfaces: Ci, utils: Cu } = Components;
 
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
+const TOPIC = "chrome-document-global-created";
+
 function observe(window, topic, url) {
-    if (topic === "chrome-document-global-created")
+    if (topic === TOPIC)
         checkDocument(window.document);
 }
 function init(id) {
     if (id)
         ADDON_ID = id;
 
-    Services.obs[id ? "addObserver" : "removeObserver"](observe, "chrome-document-global-created", false);
-    for (let doc in chromeDocuments)
+    Services.obs[id ? "addObserver" : "removeObserver"](observe, TOPIC, false);
+    for (let doc in chromeDocuments())
         checkDocument(doc, !id);
 }
 function cleanup() { init(null); }
@@ -55,18 +56,21 @@ function checkDocument(doc, disable, force) {
 }
 
 function chromeDocuments() {
-    let windows = services.windowMediator.getXULWindowEnumerator(null);
+    let windows = Services.wm.getXULWindowEnumerator(null);
     while (windows.hasMoreElements()) {
         let window = windows.getNext().QueryInterface(Ci.nsIXULWindow);
         for each (let type in ["typeChrome", "typeContent"]) {
             let docShells = window.docShell.getDocShellEnumerator(Ci.nsIDocShellTreeItem[type],
                                                                   Ci.nsIDocShell.ENUMERATE_FORWARDS);
             while (docShells.hasMoreElements())
-                yield docShells.getNext().QueryInterface(Ci.nsIDocShell).contentViewer.DOMDocument;
+                try {
+                    yield docShells.getNext().QueryInterface(Ci.nsIDocShell).contentViewer.DOMDocument;
+                }
+                catch (e) {}
         }
     }
 }
 
 var EXPORTED_SYMBOLS = ["cleanup", "init"];
 
-// vim: set fdm=marker sw=4 ts=4 et ft=javascript:
+// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: