Bug 1423425 Stop reading the Extension.jsm module object in specialpowers r=kmag
authorAndrew Swan <aswan@mozilla.com>
Mon, 18 Dec 2017 10:32:23 -0800
changeset 396768 a92c9a459eeb04d713d5459a6ae08ba1ac4b2c12
parent 396767 da4fe391303b1f8eeb5e72ef3f88a92ab6afb3e1
child 396769 7d5aebbafcf786b177a942f1a5fbaa107158ad09
push id33111
push userdluca@mozilla.com
push dateTue, 19 Dec 2017 10:06:26 +0000
treeherdermozilla-central@c76ff8b1c4d4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag
bugs1423425
milestone59.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 1423425 Stop reading the Extension.jsm module object in specialpowers r=kmag The return value from Cu.import() does not include lexically scoped symbols so stop using it here. Also stop using Extension.generate() while we're here. MozReview-Commit-ID: HnX3RGgDHbR
browser/components/extensions/test/browser/browser_ext_runtime_setUninstallURL.js
testing/specialpowers/content/SpecialPowersObserverAPI.js
toolkit/mozapps/extensions/test/browser/browser_inlinesettings_browser.js
--- a/browser/components/extensions/test/browser/browser_ext_runtime_setUninstallURL.js
+++ b/browser/components/extensions/test/browser/browser_ext_runtime_setUninstallURL.js
@@ -1,15 +1,15 @@
 "use strict";
 
 let {AddonManager} = Components.utils.import("resource://gre/modules/AddonManager.jsm", {});
-let {Extension} = Components.utils.import("resource://gre/modules/Extension.jsm", {});
+let {ExtensionTestCommon} = Components.utils.import("resource://testing-common/ExtensionTestCommon.jsm", {});
 
 async function makeAndInstallXPI(id, backgroundScript, loadedURL) {
-  let xpi = Extension.generateXPI({
+  let xpi = ExtensionTestCommon.generateXPI({
     manifest: {applications: {gecko: {id}}},
     background: backgroundScript,
   });
   SimpleTest.registerCleanupFunction(function cleanupXPI() {
     Services.obs.notifyObservers(xpi, "flush-cache-entry");
     xpi.remove(false);
   });
 
--- a/testing/specialpowers/content/SpecialPowersObserverAPI.js
+++ b/testing/specialpowers/content/SpecialPowersObserverAPI.js
@@ -1,16 +1,22 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
-Components.utils.import("resource://gre/modules/Services.jsm");
-Components.utils.import("resource://gre/modules/NetUtil.jsm");
+Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
+
+XPCOMUtils.defineLazyModuleGetters(this, {
+  ExtensionData: "resource://gre/modules/Extension.jsm",
+  ExtensionTestCommon: "resource://testing-common/ExtensionTestCommon.jsm",
+  NetUtil: "resource://gre/modules/NetUtil.jsm",
+  Services: "resource://gre/modules/Services.jsm",
+});
 
 if (typeof(Ci) == "undefined") {
   var Ci = Components.interfaces;
 }
 
 if (typeof(Cc) == "undefined") {
   var Cc = Components.classes;
 }
@@ -567,21 +573,19 @@ SpecialPowersObserverAPI.prototype = {
       case "SPRequestResetCoverageCounters": {
         let codeCoverage = Cc["@mozilla.org/tools/code-coverage;1"].
                            getService(Ci.nsICodeCoverage);
         codeCoverage.resetCounters();
         return undefined; // See comment at the beginning of this function.
       }
 
       case "SPLoadExtension": {
-        let {Extension} = Components.utils.import("resource://gre/modules/Extension.jsm", {});
-
         let id = aMessage.data.id;
         let ext = aMessage.data.ext;
-        let extension = Extension.generate(ext);
+        let extension = ExtensionTestCommon.generate(ext);
 
         let resultListener = (...args) => {
           this._sendReply(aMessage, "SPExtensionMessage", {id, type: "testResult", args});
         };
 
         let messageListener = (...args) => {
           args.shift();
           this._sendReply(aMessage, "SPExtensionMessage", {id, type: "testMessage", args});
@@ -595,18 +599,16 @@ SpecialPowersObserverAPI.prototype = {
 
         extension.on("test-message", messageListener);
 
         this._extensions.set(id, extension);
         return undefined;
       }
 
       case "SPStartupExtension": {
-        let {ExtensionData} = Components.utils.import("resource://gre/modules/Extension.jsm", {});
-
         let id = aMessage.data.id;
         let extension = this._extensions.get(id);
         extension.on("startup", () => {
           this._sendReply(aMessage, "SPExtensionMessage", {id, type: "extensionSetId", args: [extension.id, extension.uuid]});
         });
 
         // Make sure the extension passes the packaging checks when
         // they're run on a bare archive rather than a running instance,
--- a/toolkit/mozapps/extensions/test/browser/browser_inlinesettings_browser.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_inlinesettings_browser.js
@@ -1,32 +1,32 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 /* eslint-disable mozilla/no-arbitrary-setTimeout */
 
 /* globals TestUtils */
 
-var {Extension} = Components.utils.import("resource://gre/modules/Extension.jsm", {});
+let {ExtensionTestCommon} = Components.utils.import("resource://testing-common/ExtensionTestCommon.jsm", {});
 
 Components.utils.import("resource://testing-common/ContentTask.jsm", {});
 
 var gAddon;
 var gOtherAddon;
 var gManagerWindow;
 var gCategoryUtilities;
 
 function installAddon(details) {
   let id = Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator)
                                               .generateUUID().number;
   if (!details.manifest) {
     details.manifest = {};
   }
   details.manifest.applications = {gecko: {id}};
-  let xpi = Extension.generateXPI(details);
+  let xpi = ExtensionTestCommon.generateXPI(details);
 
   return AddonManager.installTemporaryAddon(xpi).then(addon => {
     SimpleTest.registerCleanupFunction(function() {
       addon.uninstall();
 
       Services.obs.notifyObservers(xpi, "flush-cache-entry");
       xpi.remove(false);
     });