Bug 1358914: Avoid calling evalInSandbox when creating bootstrap scopes. r=rhelmer
☠☠ backed out by 7a2841383525 ☠ ☠
authorKris Maglione <maglione.k@gmail.com>
Sat, 15 Apr 2017 20:13:07 -0700
changeset 358532 e12dcb4be8551c14073c891a4c9f790e0d790215
parent 358531 8068fb1cc45e8af91a58c2a37565536b25bcf615
child 358533 ba0f4d2877263ffea0f71f5311ae8c780606b0fc
push id90352
push usercbook@mozilla.com
push dateTue, 16 May 2017 13:09:14 +0000
treeherdermozilla-inbound@8f89d291e303 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrhelmer
bugs1358914
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1358914: Avoid calling evalInSandbox when creating bootstrap scopes. r=rhelmer MozReview-Commit-ID: GDxnEdxe1bu
toolkit/mozapps/extensions/internal/XPIProvider.jsm
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
@@ -5212,25 +5212,17 @@ this.XPIProvider = {
       // Add other stuff that extensions want.
       Object.assign(activeAddon.bootstrapScope, {Worker, ChromeWorker});
 
       // Define a console for the add-on
       XPCOMUtils.defineLazyGetter(
         activeAddon.bootstrapScope, "console",
         () => new ConsoleAPI({ consoleID: "addon/" + aId }));
 
-      // As we don't want our caller to control the JS version used for the
-      // bootstrap file, we run loadSubScript within the context of the
-      // sandbox with the latest JS version set explicitly.
-      activeAddon.bootstrapScope.__SCRIPT_URI_SPEC__ = uri;
-      Components.utils.evalInSandbox(
-        "Components.classes['@mozilla.org/moz/jssubscript-loader;1'] \
-                   .getService(Components.interfaces.mozIJSSubScriptLoader) \
-                   .loadSubScript(__SCRIPT_URI_SPEC__);",
-                   activeAddon.bootstrapScope, "ECMAv5");
+      Services.scriptloader.loadSubScript(uri, activeAddon.bootstrapScope);
     } catch (e) {
       logger.warn("Error loading bootstrap.js for " + aId, e);
     }
 
     // Only access BrowserToolboxProcess if ToolboxProcess.jsm has been
     // initialized as otherwise, when it will be initialized, all addons'
     // globals will be added anyways
     if (this._toolboxProcessLoaded) {
@@ -5312,18 +5304,18 @@ this.XPIProvider = {
       }
 
       // Nothing to call for locales
       if (aAddon.type == "locale")
         return;
 
       let method = undefined;
       try {
-        method = Components.utils.evalInSandbox(`${aMethod};`,
-          activeAddon.bootstrapScope, "ECMAv5");
+        let scope = activeAddon.bootstrapScope;
+        method = scope[aMethod] || Cu.evalInSandbox(`${aMethod};`, scope);
       } catch (e) {
         // An exception will be caught if the expected method is not defined.
         // That will be logged below.
       }
 
       // Extensions are automatically deinitialized in the correct order at shutdown.
       if (aMethod == "shutdown" && aReason != BOOTSTRAP_REASONS.APP_SHUTDOWN) {
         activeAddon.disable = true;