[tbb-commits] [torbutton/master] Bug 19459.2: Don't let Cu.import pollute namespaces
gk at torproject.org
gk at torproject.org
Fri Nov 11 08:47:45 UTC 2016
commit e33d7c3ae6752ca7b4d5a266a3424f59f483b26f
Author: Arthur Edelstein <arthuredelstein at gmail.com>
Date: Thu Nov 10 16:48:31 2016 -0800
Bug 19459.2: Don't let Cu.import pollute namespaces
---
src/chrome/content/content-sizer.js | 3 ++-
src/chrome/content/preferences.js | 2 +-
src/chrome/content/tor-circuit-display.js | 4 ++--
src/chrome/content/torbutton.js | 10 +++++-----
src/modules/security-prefs.js | 6 +++---
src/modules/tor-control-port.js | 2 +-
6 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/src/chrome/content/content-sizer.js b/src/chrome/content/content-sizer.js
index ded06d7..bd657b8 100644
--- a/src/chrome/content/content-sizer.js
+++ b/src/chrome/content/content-sizer.js
@@ -41,7 +41,8 @@ let torbuttonBundle = Services.strings.createBundle(
"chrome://torbutton/locale/torbutton.properties");
// Import utility functions
-let { bindPrefAndInit, getEnv } = Cu.import("resource://torbutton/modules/utils.js");
+let { bindPrefAndInit, getEnv, observe } =
+ Cu.import("resource://torbutton/modules/utils.js", {});
// __windowUtils(window)__.
// See nsIDOMWindowUtils on MDN.
diff --git a/src/chrome/content/preferences.js b/src/chrome/content/preferences.js
index 3bb6c0c..1f94dbb 100644
--- a/src/chrome/content/preferences.js
+++ b/src/chrome/content/preferences.js
@@ -3,7 +3,7 @@
// Utilities
let { utils: Cu } = Components;
let { getBoolPref, getIntPref, setBoolPref, setIntPref } =
- Cu.import("resource://gre/modules/Services.jsm").Services.prefs;
+ Cu.import("resource://gre/modules/Services.jsm", {}).Services.prefs;
// Description elements have the follow names.
const descNames =
diff --git a/src/chrome/content/tor-circuit-display.js b/src/chrome/content/tor-circuit-display.js
index c58c6d7..14e5e8e 100644
--- a/src/chrome/content/tor-circuit-display.js
+++ b/src/chrome/content/tor-circuit-display.js
@@ -31,10 +31,10 @@ Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/Task.jsm");
// Import the controller code.
-let { controller } = Cu.import("resource://torbutton/modules/tor-control-port.js");
+let { controller } = Cu.import("resource://torbutton/modules/tor-control-port.js", {});
// Utility functions
-let { bindPrefAndInit } = Cu.import("resource://torbutton/modules/utils.js");
+let { bindPrefAndInit } = Cu.import("resource://torbutton/modules/utils.js", {});
// Make the TorButton logger available.
let logger = Cc["@torproject.org/torbutton-logger;1"]
diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js
index 53e5479..7de599d 100644
--- a/src/chrome/content/torbutton.js
+++ b/src/chrome/content/torbutton.js
@@ -7,11 +7,11 @@
// TODO: Double-check there are no strange exploits to defeat:
// http://kb.mozillazine.org/Links_to_local_pages_don%27t_work
-let { LoadContextInfo } = Cu.import('resource://gre/modules/LoadContextInfo.jsm');
-let { Services } = Cu.import("resource://gre/modules/Services.jsm");
-let { showDialog } = Cu.import("resource://torbutton/modules/utils.js");
-let { unescapeTorString } = Cu.import("resource://torbutton/modules/utils.js");
-let SecurityPrefs = Cu.import("resource://torbutton/modules/security-prefs.js");
+let { LoadContextInfo } = Cu.import('resource://gre/modules/LoadContextInfo.jsm', {});
+let { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
+let { showDialog } = Cu.import("resource://torbutton/modules/utils.js", {});
+let { unescapeTorString } = Cu.import("resource://torbutton/modules/utils.js", {});
+let SecurityPrefs = Cu.import("resource://torbutton/modules/security-prefs.js", {});
const k_tb_last_browser_version_pref = "extensions.torbutton.lastBrowserVersion";
const k_tb_browser_update_needed_pref = "extensions.torbutton.updateNeeded";
diff --git a/src/modules/security-prefs.js b/src/modules/security-prefs.js
index e6a888c..4a39ca8 100644
--- a/src/modules/security-prefs.js
+++ b/src/modules/security-prefs.js
@@ -4,9 +4,9 @@
let {classes: Cc, utils: Cu } = Components;
let { getBoolPref, setBoolPref, getIntPref, setIntPref } =
- Cu.import("resource://gre/modules/Services.jsm").Services.prefs;
-let { bindPref } =
- Cu.import("resource://torbutton/modules/utils.js");
+ Cu.import("resource://gre/modules/Services.jsm", {}).Services.prefs;
+let { bindPref, bindPrefAndInit } =
+ Cu.import("resource://torbutton/modules/utils.js", {});
let logger = Components.classes["@torproject.org/torbutton-logger;1"]
.getService(Components.interfaces.nsISupports).wrappedJSObject;
let log = (level, msg) => logger.log(level, msg);
diff --git a/src/modules/tor-control-port.js b/src/modules/tor-control-port.js
index a7f0434..b3d431a 100644
--- a/src/modules/tor-control-port.js
+++ b/src/modules/tor-control-port.js
@@ -7,7 +7,7 @@
//
// To import the module, use
//
-// let { controller } = Components.utils.import("path/to/tor-control-port.js");
+// let { controller } = Components.utils.import("path/to/tor-control-port.js", {});
//
// See the last function defined in this file:
// controller(ipcFile, host, port, password, onError)
More information about the tbb-commits
mailing list