Bug 1444973 - Remove browser-test-overlay.xul. r?ahal
On desktop use sub script loader during bootstrap instead of the overlay.
On android use a component that listens for browser windows to be created
and then use a sub script loader.
MozReview-Commit-ID: Knj5OdVNEMA
--- a/testing/mochitest/bootstrap.js
+++ b/testing/mochitest/bootstrap.js
@@ -2,77 +2,52 @@
* 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://gre/modules/AppConstants.jsm");
ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+function loadChromeScripts(win) {
+ Services.scriptloader.loadSubScript("chrome://mochikit/content/chrome-harness.js", win);
+ Services.scriptloader.loadSubScript("chrome://mochikit/content/mochitest-e10s-utils.js", win);
+ Services.scriptloader.loadSubScript("chrome://mochikit/content/browser-test.js", win);
+}
+
/////// Android ///////
Cu.importGlobalProperties(["TextDecoder"]);
-class DefaultMap extends Map {
- constructor(defaultConstructor = undefined, init = undefined) {
- super(init);
- if (defaultConstructor) {
- this.defaultConstructor = defaultConstructor;
- }
- }
-
- get(key) {
- let value = super.get(key);
- if (value === undefined && !this.has(key)) {
- value = this.defaultConstructor(key);
- this.set(key, value);
- }
- return value;
- }
-}
-
const windowTracker = {
init() {
Services.obs.addObserver(this, "chrome-document-global-created");
},
- overlays: new DefaultMap(() => new Set()),
-
async observe(window, topic, data) {
if (topic === "chrome-document-global-created") {
await new Promise(resolve =>
window.addEventListener("DOMContentLoaded", resolve, {once: true}));
let {document} = window;
let {documentURI} = document;
- if (this.overlays.has(documentURI)) {
- for (let overlay of this.overlays.get(documentURI)) {
- document.loadOverlay(overlay, null);
- }
+ if (documentURI !== "chrome://browser/content/browser.xul") {
+ return;
}
+ loadChromeScripts(window);
}
},
};
-function readSync(uri) {
- let channel = NetUtil.newChannel({uri, loadUsingSystemPrincipal: true});
- let buffer = NetUtil.readInputStream(channel.open2());
- return new TextDecoder().decode(buffer);
-}
-
function androidStartup(data, reason) {
- windowTracker.init();
-
- for (let line of readSync(data.resourceURI.resolve("chrome.manifest")).split("\n")) {
- let [directive, ...args] = line.trim().split(/\s+/);
- if (directive === "overlay") {
- let [url, overlay] = args;
- windowTracker.overlays.get(url).add(overlay);
- }
+ // Only browser chrome tests need help starting.
+ let testRoot = Services.prefs.getStringPref("mochitest.testRoot", "");
+ if (testRoot.endsWith("/chrome")) {
+ windowTracker.init();
}
}
/////// Desktop ///////
var WindowListener = {
// browser-test.js is only loaded into the first window. Setup that
// needs to happen in all navigator:browser windows should go here.
@@ -111,18 +86,17 @@ function loadMochitest(e) {
win.loadURI(url);
if (flavor == "mochitest") {
return;
}
WindowListener.setupWindow(win);
Services.wm.addListener(WindowListener);
- let overlay = "chrome://mochikit/content/browser-test-overlay.xul";
- win.document.loadOverlay(overlay, null);
+ loadChromeScripts(win);
}
function startup(data, reason) {
if (AppConstants.platform == "android") {
androidStartup(data, reason);
} else {
let win = Services.wm.getMostRecentWindow("navigator:browser");
// wait for event fired from start_desktop.js containing the
deleted file mode 100644
--- a/testing/mochitest/browser-test-overlay.xul
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0"?>
-<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
-<!-- 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/. -->
-
-<overlay id="browserTestOverlay"
- xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
- <script type="application/javascript" src="chrome://mochikit/content/chrome-harness.js"/>
- <script type="application/javascript" src="chrome://mochikit/content/mochitest-e10s-utils.js"/>
- <script type="application/javascript" src="chrome://mochikit/content/browser-test.js"/>
-</overlay>
--- a/testing/mochitest/jar.mn
+++ b/testing/mochitest/jar.mn
@@ -1,13 +1,12 @@
mochikit.jar:
% content mochikit %content/
content/browser-harness.xul (browser-harness.xul)
content/browser-test.js (browser-test.js)
- content/browser-test-overlay.xul (browser-test-overlay.xul)
content/chrome-harness.js (chrome-harness.js)
content/mochitest-e10s-utils.js (mochitest-e10s-utils.js)
content/shutdown-leaks-collector.js (shutdown-leaks-collector.js)
content/ShutdownLeaksCollector.jsm (ShutdownLeaksCollector.jsm)
content/harness.xul (harness.xul)
content/redirect.html (redirect.html)
content/server.js (server.js)
content/chunkifyTests.js (chunkifyTests.js)
--- a/testing/mochitest/moz.build
+++ b/testing/mochitest/moz.build
@@ -37,17 +37,16 @@ TEST_HARNESS_FILES.testing.mochitest +=
'/build/sanitizers/lsan_suppressions.txt',
'/build/sanitizers/ubsan_suppressions.txt',
'/build/valgrind/cross-architecture.sup',
'/build/valgrind/i386-pc-linux-gnu.sup',
'/build/valgrind/x86_64-pc-linux-gnu.sup',
'/netwerk/test/httpserver/httpd.js',
'bisection.py',
'browser-harness.xul',
- 'browser-test-overlay.xul',
'browser-test.js',
'chrome-harness.js',
'chunkifyTests.js',
'gen_template.pl',
'harness.xul',
'leaks.py',
'mach_test_package_commands.py',
'manifest.webapp',
--- a/testing/mochitest/runtestsremote.py
+++ b/testing/mochitest/runtestsremote.py
@@ -193,30 +193,16 @@ class MochiRemote(MochitestDesktop):
if savedTestingModulesDir:
options.testingModulesDir = savedTestingModulesDir
self.localProfile = options.profilePath
restoreRemotePaths()
options.profilePath = self.remoteProfile
return manifest
- def addChromeToProfile(self, options):
- manifest = MochitestDesktop.addChromeToProfile(self, options)
-
- # Support Firefox (browser), SeaMonkey (navigator), and Webapp Runtime (webapp).
- if options.flavor == 'chrome':
- # append overlay to chrome.manifest
- chrome = ("overlay chrome://browser/content/browser.xul "
- "chrome://mochikit/content/browser-test-overlay.xul")
- path = os.path.join(options.profilePath, 'extensions', 'staged',
- 'mochikit@mozilla.org', 'chrome.manifest')
- with open(path, "a") as f:
- f.write(chrome)
- return manifest
-
def buildURLOptions(self, options, env):
self.localLog = options.logFile
options.logFile = self.remoteLog
options.fileLevel = 'INFO'
options.profilePath = self.localProfile
env["MOZ_HIDE_RESULTS_TABLE"] = "1"
retVal = MochitestDesktop.buildURLOptions(self, options, env)