Bug 1558298: Part 3 - Always load specialpowers.js as a JSM. r=nika
authorKris Maglione <maglione.k@gmail.com>
Mon, 10 Jun 2019 13:31:19 -0700
changeset 544097 c95e6e5998364d70a97651dea785d0ad5c31eff5
parent 544096 9b1a9d80243437eb87d63a10b62d7b25eb2a6664
child 544098 ca88016511bb3f7aa335ee6531b17e75c08477a6
push id2131
push userffxbld-merge
push dateMon, 26 Aug 2019 18:30:20 +0000
treeherdermozilla-release@b19ffb3ca153 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnika
bugs1558298
milestone69.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 1558298: Part 3 - Always load specialpowers.js as a JSM. r=nika Differential Revision: https://phabricator.services.mozilla.com/D34592
browser/base/content/test/performance/browser_startup_content.js
docshell/test/chrome/bug89419_window.xul
testing/mochitest/moz.build
testing/specialpowers/content/MozillaLogger.js
testing/specialpowers/content/SpecialPowers.jsm
testing/specialpowers/content/specialpowers.js
testing/specialpowers/content/specialpowersFrameScript.js
testing/specialpowers/moz.build
--- a/browser/base/content/test/performance/browser_startup_content.js
+++ b/browser/base/content/test/performance/browser_startup_content.js
@@ -15,17 +15,17 @@
 "use strict";
 
 /* Set this to true only for debugging purpose; it makes the output noisy. */
 const kDumpAllStacks = false;
 
 const whitelist = {
   modules: new Set([
     "chrome://mochikit/content/ShutdownLeaksCollector.jsm",
-    "resource://specialpowers/specialpowers.js",
+    "resource://specialpowers/SpecialPowers.jsm",
     "resource://specialpowers/SpecialPowersAPI.jsm",
     "resource://specialpowers/WrapPrivileged.jsm",
 
     "resource://gre/modules/ContentProcessSingleton.jsm",
 
     // General utilities
     "resource://gre/modules/AppConstants.jsm",
     "resource://gre/modules/AsyncShutdown.jsm",
--- a/docshell/test/chrome/bug89419_window.xul
+++ b/docshell/test/chrome/bug89419_window.xul
@@ -4,18 +4,23 @@
 <window id="89419Test"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         width="600"
         height="600"
         onload="setTimeout(nextTest, 0);"
         title="bug 89419 test">
 
   <script type="application/javascript" src= "chrome://mochikit/content/chrome-harness.js" />
-  <script src="chrome://mochikit/content/tests/SimpleTest/SpecialPowersObserverAPI.js"/>
-  <script src="chrome://mochikit/content/tests/SimpleTest/specialpowers.js"/>
+  <script>
+    ChromeUtils.import("resource://specialpowers/SpecialPowers.jsm", this);
+
+    window.addMessageListener = function() {};
+    window.removeMessageListener = function() {};
+    window.SpecialPowers = new SpecialPowers(window, window);
+  </script>
   <script type="application/javascript" src="docshell_helpers.js" />
   <script src="chrome://mochikit/content/tests/SimpleTest/WindowSnapshot.js"></script>
 
   <script type="application/javascript"><![CDATA[
     // Define the generator-iterator for the tests.
     var tests = testIterator();
 
     ////
--- a/testing/mochitest/moz.build
+++ b/testing/mochitest/moz.build
@@ -43,17 +43,16 @@ FINAL_TARGET_FILES.content.dynamic += [
 FINAL_TARGET_FILES.content.static += [
     'static/harness.css',
 ]
 
 FINAL_TARGET_FILES.content.tests.SimpleTest += [
     '../../docshell/test/chrome/docshell_helpers.js',
     '../modules/StructuredLog.jsm',
     '../specialpowers/content/MozillaLogger.js',
-    '../specialpowers/content/specialpowers.js',
     '../specialpowers/content/SpecialPowersObserverAPI.js',
     'tests/SimpleTest/AsyncUtilsContent.js',
     'tests/SimpleTest/ChromePowers.js',
     'tests/SimpleTest/EventUtils.js',
     'tests/SimpleTest/ExtensionTestUtils.js',
     'tests/SimpleTest/iframe-between-tests.html',
     'tests/SimpleTest/LogController.js',
     'tests/SimpleTest/MemoryStats.js',
--- a/testing/specialpowers/content/MozillaLogger.js
+++ b/testing/specialpowers/content/MozillaLogger.js
@@ -1,15 +1,15 @@
 /**
  * MozillaLogger, a base class logger that just logs to stdout.
  */
 
 "use strict";
 
-/* import-globals-from specialpowers.js */
+/* import-globals-from SpecialPowers.jsm */
 
 function MozillaLogger(aPath) {
 }
 
 function formatLogMessage(msg) {
     return msg.info.join(" ") + "\n";
 }
 
rename from testing/specialpowers/content/specialpowers.js
rename to testing/specialpowers/content/SpecialPowers.jsm
--- a/testing/specialpowers/content/specialpowers.js
+++ b/testing/specialpowers/content/SpecialPowers.jsm
@@ -1,24 +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/. */
 /* This code is loaded in every child process that is started by mochitest in
  * order to be used as a replacement for UniversalXPConnect
  */
 
-/* globals bindDOMWindowUtils, SpecialPowersAPI */
-
 var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 Services.scriptloader.loadSubScript("resource://specialpowers/MozillaLogger.js", this);
 
 var EXPORTED_SYMBOLS = ["SpecialPowers", "attachSpecialPowersToWindow"];
 
-ChromeUtils.import("resource://specialpowers/SpecialPowersAPI.jsm", this);
+const {bindDOMWindowUtils, SpecialPowersAPI} = ChromeUtils.import("resource://specialpowers/SpecialPowersAPI.jsm");
 
 Cu.forcePermissiveCOWs();
 
 function SpecialPowers(window, mm) {
   this.mm = mm;
 
   this.window = Cu.getWeakReference(window);
   this._windowID = window.windowUtils.currentInnerWindowID;
@@ -313,16 +311,8 @@ function attachSpecialPowersToWindow(aWi
     }
   } catch (ex) {
     dump("TEST-INFO | specialpowers.js |  Failed to attach specialpowers to window exception: " + ex + "\n");
   }
 }
 
 this.SpecialPowers = SpecialPowers;
 this.attachSpecialPowersToWindow = attachSpecialPowersToWindow;
-
-// In the case of Chrome mochitests that inject specialpowers.js as
-// a regular content script
-if (typeof window != "undefined") {
-  window.addMessageListener = function() {};
-  window.removeMessageListener = function() {};
-  window.wrappedJSObject.SpecialPowers = new SpecialPowers(window, window);
-}
--- a/testing/specialpowers/content/specialpowersFrameScript.js
+++ b/testing/specialpowers/content/specialpowersFrameScript.js
@@ -1,16 +1,16 @@
 "use strict";
 
 /* globals attachSpecialPowersToWindow */
 
 let mm = this;
 
 ChromeUtils.import("resource://specialpowers/SpecialPowersAPI.jsm", this);
-ChromeUtils.import("resource://specialpowers/specialpowers.js", this);
+ChromeUtils.import("resource://specialpowers/SpecialPowers.jsm", this);
 
 // This is a frame script, so it may be running in a content process.
 // In any event, it is targeted at a specific "tab", so we listen for
 // the DOMWindowCreated event to be notified about content windows
 // being created in this context.
 
 function SpecialPowersManager() {
   addEventListener("DOMWindowCreated", this, false);
--- a/testing/specialpowers/moz.build
+++ b/testing/specialpowers/moz.build
@@ -15,17 +15,17 @@ FINAL_TARGET_FILES += [
 ]
 
 FINAL_TARGET_FILES.content += [
     '../modules/Assert.jsm',
     'content/MockColorPicker.jsm',
     'content/MockFilePicker.jsm',
     'content/MockPermissionPrompt.jsm',
     'content/MozillaLogger.js',
-    'content/specialpowers.js',
+    'content/SpecialPowers.jsm',
     'content/SpecialPowersAPI.jsm',
     'content/specialpowersFrameScript.js',
     'content/SpecialPowersObserver.jsm',
     'content/SpecialPowersObserverAPI.js',
     'content/WrapPrivileged.jsm',
 ]
 
 with Files("**"):