Bug 1558298: Part 5 - Let ChromePowers.js handle its own SpecialPowers imports. r=nika
authorKris Maglione <maglione.k@gmail.com>
Mon, 10 Jun 2019 14:15:47 -0700
changeset 540910 ba24251835fbbd7348e96b7f2956f32811d3577e
parent 540909 ca88016511bb3f7aa335ee6531b17e75c08477a6
child 540911 edd1cc6badf788f950ee68168aed0a14aa191411
push id11533
push userarchaeopteryx@coole-files.de
push dateMon, 08 Jul 2019 18:18:03 +0000
treeherdermozilla-beta@f4452e031aed [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 5 - Let ChromePowers.js handle its own SpecialPowers imports. r=nika Differential Revision: https://phabricator.services.mozilla.com/D34594
docshell/test/chrome/bug293235_window.xul
docshell/test/chrome/bug396649_window.xul
testing/mochitest/browser-test.js
testing/mochitest/moz.build
testing/mochitest/tests/SimpleTest/ChromePowers.js
--- a/docshell/test/chrome/bug293235_window.xul
+++ b/docshell/test/chrome/bug293235_window.xul
@@ -3,20 +3,16 @@
 
 <window id="293235Test"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         width="600"
         height="600"
         onload="setTimeout(nextTest, 0);"
         title="bug 293235 test">
 
-  <script>
-    ChromeUtils.import("resource://specialpowers/SpecialPowersAPI.jsm", this);
-  </script>
-  <script src="chrome://mochikit/content/tests/SimpleTest/SpecialPowersObserverAPI.js"/>
   <script src="chrome://mochikit/content/tests/SimpleTest/ChromePowers.js"/>
   <script type="application/javascript" src= "chrome://mochikit/content/chrome-harness.js" />
   <script type="application/javascript" src="docshell_helpers.js" />
   <script src="chrome://mochikit/content/tests/SimpleTest/WindowSnapshot.js"></script>
 
   <script type="application/javascript"><![CDATA[
     var {NetUtil} = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
 
--- a/docshell/test/chrome/bug396649_window.xul
+++ b/docshell/test/chrome/bug396649_window.xul
@@ -3,20 +3,16 @@
 
 <window id="396649Test"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         width="600"
         height="600"
         onload="setTimeout(nextTest, 0);"
         title="bug 396649 test">
 
-  <script>
-    ChromeUtils.import("resource://specialpowers/SpecialPowersAPI.jsm", this);
-  </script>
-  <script src="chrome://mochikit/content/tests/SimpleTest/SpecialPowersObserverAPI.js"/>
   <script src="chrome://mochikit/content/tests/SimpleTest/ChromePowers.js"/>
   <script type="application/javascript" src= "chrome://mochikit/content/chrome-harness.js" />
   <script type="application/javascript" src="docshell_helpers.js" />
   <script type="application/javascript"><![CDATA[
   
     // Define the generator-iterator for the tests.
     var tests = testIterator();
     
--- a/testing/mochitest/browser-test.js
+++ b/testing/mochitest/browser-test.js
@@ -391,18 +391,16 @@ function Tester(aTests, structuredLogger
     sandboxPrototype: window,
   });
   Cu.permitCPOWsInScope(this.cpowSandbox);
 
   this.cpowEventUtils = new this.cpowSandbox.Object();
   this._scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/EventUtils.js", this.cpowEventUtils);
 
   var simpleTestScope = {};
-  ChromeUtils.import("resource://specialpowers/SpecialPowersAPI.jsm", simpleTestScope);
-  this._scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/SpecialPowersObserverAPI.js", simpleTestScope);
   this._scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/ChromePowers.js", simpleTestScope);
   this._scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/SimpleTest.js", simpleTestScope);
   this._scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/MemoryStats.js", simpleTestScope);
   this._scriptLoader.loadSubScript("chrome://mochikit/content/chrome-harness.js", simpleTestScope);
   this.SimpleTest = simpleTestScope.SimpleTest;
 
   var extensionUtilsScope = {
     registerCleanupFunction: (fn) => {
--- 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/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',
     'tests/SimpleTest/MockObjects.js',
--- a/testing/mochitest/tests/SimpleTest/ChromePowers.js
+++ b/testing/mochitest/tests/SimpleTest/ChromePowers.js
@@ -1,12 +1,14 @@
 /* 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/. */
 
+ChromeUtils.import("resource://specialpowers/SpecialPowersAPI.jsm", this);
+
 function ChromePowers(window) {
   this.window = Cu.getWeakReference(window);
 
   this.chromeWindow = window;
 
   if (typeof(window) == "ChromeWindow" && typeof(content.window) == "Window") {
     this.DOMWindowUtils = bindDOMWindowUtils(content.window);
     this.window = Cu.getWeakReference(content.window);
@@ -105,11 +107,14 @@ ChromePowers.prototype.executeAfterFlush
 };
 
 if ((window.parent !== null) &&
     (window.parent !== undefined) &&
     (window.parent.wrappedJSObject.SpecialPowers) &&
     !(window.wrappedJSObject.SpecialPowers)) {
   window.wrappedJSObject.SpecialPowers = window.parent.SpecialPowers;
 } else {
+  const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
+  Services.scriptloader.loadSubScript("resource://specialpowers/SpecialPowersObserverAPI.js", this);
+
   window.wrappedJSObject.SpecialPowers = new ChromePowers(window);
 }