commit 0b80394c77f8d3c4f9df7594e692da857300b60f Author: Alex Catarineu acat@torproject.org Date: Thu Jul 30 20:53:07 2020 +0200
Bug 40002: Fix generateNSGetFactory being moved to ComponentUtils
This was changed in https://bugzilla.mozilla.org/show_bug.cgi?id=1649554. --- components/domain-isolator.js | 8 +++++++- components/dragDropFilter.js | 9 ++++++++- components/external-app-blocker.js | 9 ++++++++- components/startup-observer.js | 9 ++++++++- components/torCheckService.js | 9 ++++++++- components/torbutton-logger.js | 16 ++++++++-------- 6 files changed, 47 insertions(+), 13 deletions(-)
diff --git a/components/domain-isolator.js b/components/domain-isolator.js index 38d0abe8..06fe1e2e 100644 --- a/components/domain-isolator.js +++ b/components/domain-isolator.js @@ -11,6 +11,10 @@ const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+XPCOMUtils.defineLazyModuleGetters(this, { + ComponentUtils: "resource://gre/modules/ComponentUtils.jsm", +}); + // Make the logger available. let logger = Cc["@torproject.org/torbutton-logger;1"] .getService(Ci.nsISupports).wrappedJSObject; @@ -199,4 +203,6 @@ DomainIsolator.prototype = { };
// Assign factory to global object. -const NSGetFactory = XPCOMUtils.generateNSGetFactory([DomainIsolator]); +const NSGetFactory = XPCOMUtils.generateNSGetFactory + ? XPCOMUtils.generateNSGetFactory([DomainIsolator]) + : ComponentUtils.generateNSGetFactory([DomainIsolator]); diff --git a/components/dragDropFilter.js b/components/dragDropFilter.js index f48d1b38..361424d1 100644 --- a/components/dragDropFilter.js +++ b/components/dragDropFilter.js @@ -9,6 +9,10 @@ const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
+XPCOMUtils.defineLazyModuleGetters(this, { + ComponentUtils: "resource://gre/modules/ComponentUtils.jsm", +}); + // Module specific constants const kMODULE_NAME = "Torbutton Drag and Drop Handler"; const kCONTRACT_ID = "@torproject.org/torbutton-dragDropFilter;1"; @@ -79,4 +83,7 @@ DragDropFilter.prototype = } };
-var NSGetFactory = XPCOMUtils.generateNSGetFactory([DragDropFilter]); +// Assign factory to global object. +const NSGetFactory = XPCOMUtils.generateNSGetFactory + ? XPCOMUtils.generateNSGetFactory([DragDropFilter]) + : ComponentUtils.generateNSGetFactory([DragDropFilter]); diff --git a/components/external-app-blocker.js b/components/external-app-blocker.js index 89d6d252..2fa80d9d 100644 --- a/components/external-app-blocker.js +++ b/components/external-app-blocker.js @@ -16,6 +16,10 @@ const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); const { PromptUtils } = ChromeUtils.import("resource://gre/modules/SharedPromptUtils.jsm");
+XPCOMUtils.defineLazyModuleGetters(this, { + ComponentUtils: "resource://gre/modules/ComponentUtils.jsm", +}); + let { torbutton_get_property_string } = ChromeUtils.import("resource://torbutton/modules/utils.js", {});
// Module specific constants @@ -131,4 +135,7 @@ ExternalAppBlocker.prototype = }, };
-var NSGetFactory = XPCOMUtils.generateNSGetFactory([ExternalAppBlocker]); +// Assign factory to global object. +const NSGetFactory = XPCOMUtils.generateNSGetFactory + ? XPCOMUtils.generateNSGetFactory([ExternalAppBlocker]) + : ComponentUtils.generateNSGetFactory([ExternalAppBlocker]); diff --git a/components/startup-observer.js b/components/startup-observer.js index d2d1d610..c81eebab 100644 --- a/components/startup-observer.js +++ b/components/startup-observer.js @@ -15,6 +15,10 @@ const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+XPCOMUtils.defineLazyModuleGetters(this, { + ComponentUtils: "resource://gre/modules/ComponentUtils.jsm", +}); + XPCOMUtils.defineLazyModuleGetters(this, { FileUtils: "resource://gre/modules/FileUtils.jsm", FileSource: "resource://gre/modules/L10nRegistry.jsm", @@ -205,4 +209,7 @@ StartupObserver.prototype = { _xpcom_categories: [{category:"profile-after-change"}], };
-var NSGetFactory = XPCOMUtils.generateNSGetFactory([StartupObserver]); +// Assign factory to global object. +const NSGetFactory = XPCOMUtils.generateNSGetFactory + ? XPCOMUtils.generateNSGetFactory([StartupObserver]) + : ComponentUtils.generateNSGetFactory([StartupObserver]); diff --git a/components/torCheckService.js b/components/torCheckService.js index 409cc2c5..07b1aa99 100644 --- a/components/torCheckService.js +++ b/components/torCheckService.js @@ -10,6 +10,10 @@ const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+XPCOMUtils.defineLazyModuleGetters(this, { + ComponentUtils: "resource://gre/modules/ComponentUtils.jsm", +}); + // Module specific constants const kMODULE_NAME = "Torbutton Tor Check Service"; const kMODULE_CONTRACTID = "@torproject.org/torbutton-torCheckService;1"; @@ -131,4 +135,7 @@ TBTorCheckService.prototype = }, };
-var NSGetFactory = XPCOMUtils.generateNSGetFactory([TBTorCheckService]); +// Assign factory to global object. +const NSGetFactory = XPCOMUtils.generateNSGetFactory + ? XPCOMUtils.generateNSGetFactory([TBTorCheckService]) + : ComponentUtils.generateNSGetFactory([TBTorCheckService]); diff --git a/components/torbutton-logger.js b/components/torbutton-logger.js index 1c946fa7..d80d13c4 100644 --- a/components/torbutton-logger.js +++ b/components/torbutton-logger.js @@ -16,6 +16,10 @@ const kMODULE_CID = Components.ID("f36d72c9-9718-4134-b550-e109638331d7"); const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+XPCOMUtils.defineLazyModuleGetters(this, { + ComponentUtils: "resource://gre/modules/ComponentUtils.jsm", +}); + function TorbuttonLogger() { // Register observer Services.prefs.addObserver("extensions.torbutton", this); @@ -154,11 +158,7 @@ TorbuttonLogger.prototype = } }
-/** -* XPCOMUtils.generateNSGetFactory was introduced in Mozilla 2 (Firefox 4). -* XPCOMUtils.generateNSGetModule is for Mozilla 1.9.2 (Firefox 3.6). -*/ -if (XPCOMUtils.generateNSGetFactory) - var NSGetFactory = XPCOMUtils.generateNSGetFactory([TorbuttonLogger]); -else - var NSGetModule = XPCOMUtils.generateNSGetModule([TorbuttonLogger]); +// Assign factory to global object. +const NSGetFactory = XPCOMUtils.generateNSGetFactory + ? XPCOMUtils.generateNSGetFactory([TorbuttonLogger]) + : ComponentUtils.generateNSGetFactory([TorbuttonLogger]);
tbb-commits@lists.torproject.org