Bug 1312690: Cleanup. r=aswan
authorKris Maglione <maglione.k@gmail.com>
Sun, 30 Oct 2016 19:54:23 -0700
changeset 363670 daeb765e4bf6fa3a16f6382f3a6e33b3282a3948
parent 363669 ce032e762e19150e79ef3e7938c86ae39a40af43
child 363671 533878a315ea839c15f48185dda9c9cd4f3ca2a8
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-beta@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaswan
bugs1312690
milestone52.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 1312690: Cleanup. r=aswan MozReview-Commit-ID: IorfzVPKyIE
toolkit/components/extensions/Extension.jsm
toolkit/components/extensions/ExtensionUtils.jsm
--- a/toolkit/components/extensions/Extension.jsm
+++ b/toolkit/components/extensions/Extension.jsm
@@ -375,29 +375,16 @@ class ExtensionChildProxyContext extends
   shutdown() {
     Management.emit("page-shutdown", this);
     super.shutdown();
   }
 }
 
 function findPathInObject(obj, path, printErrors = true) {
   for (let elt of path.split(".")) {
-    // If we get a null object before reaching the requested path
-    // (e.g. the API object is returned only on particular kind of contexts instead
-    // of based on WebExtensions permissions, like it happens for the devtools APIs),
-    // stop searching and return undefined.
-    // TODO(robwu): This should never be reached. If an API is not available for
-    // a context, it should be declared as such in the schema and enforced by
-    // `shouldInject`, for instance using the same logic that is used to opt-in
-    // to APIs in content scripts.
-    // If this check is kept, then there is a discrepancy between APIs depending
-    // on whether it is generated locally or remotely: Non-existing local APIs
-    // are excluded in `shouldInject` by this check, but remote APIs do not have
-    // this information and will therefore cause the schema API generator to
-    // create an API that proxies to a non-existing API implementation.
     if (!obj || !(elt in obj)) {
       if (printErrors) {
         Cu.reportError(`WebExtension API ${path} not found (it may be unimplemented by Firefox).`);
       }
       return null;
     }
 
     obj = obj[elt];
--- a/toolkit/components/extensions/ExtensionUtils.jsm
+++ b/toolkit/components/extensions/ExtensionUtils.jsm
@@ -2037,26 +2037,24 @@ class SchemaAPIManager extends EventEmit
    *
    * @returns {object} A sandbox that is used as the global by `loadScript`.
    */
   _createExtGlobal() {
     let global = Cu.Sandbox(Services.scriptSecurityManager.getSystemPrincipal(), {
       wantXrays: false,
       sandboxName: `Namespace of ext-*.js scripts for ${this.processType}`,
     });
-    Object.defineProperty(global, "console", {get() { return console; }});
-    global.extensions = this;
-    global.global = global;
-    global.Cc = Cc;
-    global.Ci = Ci;
-    global.Cu = Cu;
-    global.Cr = Cr;
+
+    Object.assign(global, {global, Cc, Ci, Cu, Cr, XPCOMUtils, extensions: this});
+
+    XPCOMUtils.defineLazyGetter(global, "console", getConsole);
+
     XPCOMUtils.defineLazyModuleGetter(global, "require",
                                       "resource://devtools/shared/Loader.jsm");
-    global.XPCOMUtils = XPCOMUtils;
+
     return global;
   }
 
   /**
    * Load an ext-*.js script. The script runs in its own scope, if it wishes to
    * share state with another script it can assign to the `global` variable. If
    * it wishes to communicate with this API manager, use `extensions`.
    *