mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 16:25:38 +00:00
Backed out 2 changesets (bug 1451513) for likely causing frequent mochitest suite hangs (bug 1414495). a=backout
Backed out changeset 604167986098 (bug 1451513) Backed out changeset afc5c4bd60da (bug 1451513) --HG-- rename : testing/mochitest/api.js => testing/mochitest/bootstrap.js
This commit is contained in:
parent
bd900ee36a
commit
068e4b1bfe
@ -2,8 +2,6 @@
|
||||
* 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/. */
|
||||
|
||||
/* globals ExtensionAPI */
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
@ -40,20 +38,10 @@ const windowTracker = {
|
||||
},
|
||||
};
|
||||
|
||||
function androidStartup() {
|
||||
function androidStartup(data, reason) {
|
||||
// Only browser chrome tests need help starting.
|
||||
let testRoot = Services.prefs.getStringPref("mochitest.testRoot", "");
|
||||
if (testRoot.endsWith("/chrome")) {
|
||||
// The initial window is created from browser startup, which races
|
||||
// against extension initialization. If it has already been created,
|
||||
// inject the test scripts now, otherwise wait for the browser window
|
||||
// to show up.
|
||||
let win = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
if (win) {
|
||||
loadChromeScripts(win);
|
||||
return;
|
||||
}
|
||||
|
||||
windowTracker.init();
|
||||
}
|
||||
}
|
||||
@ -106,38 +94,29 @@ function loadMochitest(e) {
|
||||
loadChromeScripts(win);
|
||||
}
|
||||
|
||||
this.mochikit = class extends ExtensionAPI {
|
||||
onStartup() {
|
||||
let aomStartup = Cc["@mozilla.org/addons/addon-manager-startup;1"]
|
||||
.getService(Ci.amIAddonManagerStartup);
|
||||
const manifestURI = Services.io.newURI("manifest.json", null, this.extension.rootURI);
|
||||
const targetURL = this.extension.rootURI.resolve("content/");
|
||||
this.chromeHandle = aomStartup.registerChrome(manifestURI, [
|
||||
["content", "mochikit", targetURL],
|
||||
]);
|
||||
|
||||
if (AppConstants.platform == "android") {
|
||||
androidStartup();
|
||||
} else {
|
||||
let win = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
// wait for event fired from start_desktop.js containing the
|
||||
// suite and url to load
|
||||
win.addEventListener("mochitest-load", loadMochitest);
|
||||
}
|
||||
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
|
||||
// suite and url to load
|
||||
win.addEventListener("mochitest-load", loadMochitest);
|
||||
}
|
||||
}
|
||||
|
||||
onShutdown() {
|
||||
if (AppConstants.platform != "android") {
|
||||
let windows = Services.wm.getEnumerator("navigator:browser");
|
||||
while (windows.hasMoreElements()) {
|
||||
let win = windows.getNext().QueryInterface(Ci.nsIDOMWindow);
|
||||
WindowListener.tearDownWindow(win);
|
||||
}
|
||||
|
||||
Services.wm.removeListener(WindowListener);
|
||||
function shutdown(data, reason) {
|
||||
if (AppConstants.platform != "android") {
|
||||
let windows = Services.wm.getEnumerator("navigator:browser");
|
||||
while (windows.hasMoreElements()) {
|
||||
let win = windows.getNext().QueryInterface(Ci.nsIDOMWindow);
|
||||
WindowListener.tearDownWindow(win);
|
||||
}
|
||||
|
||||
this.chromeHandle.destruct();
|
||||
this.chromeHandle = null;
|
||||
Services.wm.removeListener(WindowListener);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function install(data, reason) {}
|
||||
function uninstall(data, reason) {}
|
||||
|
42
testing/mochitest/jar.mn
Normal file
42
testing/mochitest/jar.mn
Normal file
@ -0,0 +1,42 @@
|
||||
mochikit.jar:
|
||||
% content mochikit %content/
|
||||
content/browser-harness.xul (browser-harness.xul)
|
||||
content/browser-test.js (browser-test.js)
|
||||
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)
|
||||
content/manifestLibrary.js (manifestLibrary.js)
|
||||
content/nested_setup.js (nested_setup.js)
|
||||
content/dynamic/getMyDirectory.sjs (dynamic/getMyDirectory.sjs)
|
||||
content/static/harness.css (static/harness.css)
|
||||
content/tests/SimpleTest/ChromePowers.js (tests/SimpleTest/ChromePowers.js)
|
||||
content/tests/SimpleTest/EventUtils.js (tests/SimpleTest/EventUtils.js)
|
||||
content/tests/SimpleTest/ExtensionTestUtils.js (tests/SimpleTest/ExtensionTestUtils.js)
|
||||
content/tests/SimpleTest/AddTask.js (tests/SimpleTest/AddTask.js)
|
||||
content/tests/SimpleTest/AsyncUtilsContent.js (tests/SimpleTest/AsyncUtilsContent.js)
|
||||
content/tests/SimpleTest/LogController.js (tests/SimpleTest/LogController.js)
|
||||
content/tests/SimpleTest/MemoryStats.js (tests/SimpleTest/MemoryStats.js)
|
||||
content/tests/SimpleTest/MozillaLogger.js (../specialpowers/content/MozillaLogger.js)
|
||||
content/tests/SimpleTest/specialpowers.js (../specialpowers/content/specialpowers.js)
|
||||
content/tests/SimpleTest/SpecialPowersObserverAPI.js (../specialpowers/content/SpecialPowersObserverAPI.js)
|
||||
content/tests/SimpleTest/specialpowersAPI.js (../specialpowers/content/specialpowersAPI.js)
|
||||
content/tests/SimpleTest/setup.js (tests/SimpleTest/setup.js)
|
||||
content/tests/SimpleTest/SimpleTest.js (tests/SimpleTest/SimpleTest.js)
|
||||
content/tests/SimpleTest/StructuredLog.jsm (../modules/StructuredLog.jsm)
|
||||
content/tests/SimpleTest/test.css (tests/SimpleTest/test.css)
|
||||
content/tests/SimpleTest/TestRunner.js (tests/SimpleTest/TestRunner.js)
|
||||
content/tests/SimpleTest/iframe-between-tests.html (tests/SimpleTest/iframe-between-tests.html)
|
||||
content/tests/SimpleTest/WindowSnapshot.js (tests/SimpleTest/WindowSnapshot.js)
|
||||
content/tests/SimpleTest/MockObjects.js (tests/SimpleTest/MockObjects.js)
|
||||
content/tests/SimpleTest/NativeKeyCodes.js (tests/SimpleTest/NativeKeyCodes.js)
|
||||
content/tests/SimpleTest/paint_listener.js (tests/SimpleTest/paint_listener.js)
|
||||
content/tests/SimpleTest/docshell_helpers.js (../../docshell/test/chrome/docshell_helpers.js)
|
||||
content/tests/BrowserTestUtils/content-task.js (BrowserTestUtils/content/content-task.js)
|
||||
content/tests/BrowserTestUtils/content-about-page-utils.js (BrowserTestUtils/content/content-about-page-utils.js)
|
||||
content/tests/BrowserTestUtils/content-utils.js (BrowserTestUtils/content/content-utils.js)
|
||||
|
@ -1,22 +0,0 @@
|
||||
{
|
||||
"manifest_version": 2,
|
||||
"name": "Mochitest",
|
||||
"version": "2.0",
|
||||
|
||||
"applications": {
|
||||
"gecko": {
|
||||
"id": "mochikit@mozilla.org"
|
||||
}
|
||||
},
|
||||
|
||||
"experiment_apis": {
|
||||
"mochikit": {
|
||||
"schema": "schema.json",
|
||||
"parent": {
|
||||
"scopes": ["addon_parent"],
|
||||
"script": "api.js",
|
||||
"events": ["startup"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -13,67 +13,13 @@ DIRS += [
|
||||
|
||||
XPI_NAME = 'mochijar'
|
||||
|
||||
JAR_MANIFESTS += ['jar.mn']
|
||||
|
||||
USE_EXTENSION_MANIFEST = True
|
||||
|
||||
FINAL_TARGET_FILES += [
|
||||
'api.js',
|
||||
'manifest.json',
|
||||
'schema.json',
|
||||
]
|
||||
FINAL_TARGET_PP_FILES += ['install.rdf']
|
||||
|
||||
FINAL_TARGET_FILES.content += [
|
||||
'browser-harness.xul',
|
||||
'browser-test.js',
|
||||
'chrome-harness.js',
|
||||
'chunkifyTests.js',
|
||||
'harness.xul',
|
||||
'manifestLibrary.js',
|
||||
'mochitest-e10s-utils.js',
|
||||
'nested_setup.js',
|
||||
'redirect.html',
|
||||
'server.js',
|
||||
'shutdown-leaks-collector.js',
|
||||
'ShutdownLeaksCollector.jsm',
|
||||
]
|
||||
|
||||
FINAL_TARGET_FILES.content.dynamic += [
|
||||
'dynamic/getMyDirectory.sjs',
|
||||
]
|
||||
|
||||
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/specialpowersAPI.js',
|
||||
'../specialpowers/content/SpecialPowersObserverAPI.js',
|
||||
'tests/SimpleTest/AddTask.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',
|
||||
'tests/SimpleTest/NativeKeyCodes.js',
|
||||
'tests/SimpleTest/paint_listener.js',
|
||||
'tests/SimpleTest/setup.js',
|
||||
'tests/SimpleTest/SimpleTest.js',
|
||||
'tests/SimpleTest/test.css',
|
||||
'tests/SimpleTest/TestRunner.js',
|
||||
'tests/SimpleTest/WindowSnapshot.js',
|
||||
]
|
||||
|
||||
FINAL_TARGET_FILES.content.tests.BrowserTestUtils += [
|
||||
'BrowserTestUtils/content/content-about-page-utils.js',
|
||||
'BrowserTestUtils/content/content-task.js',
|
||||
'BrowserTestUtils/content/content-utils.js',
|
||||
]
|
||||
FINAL_TARGET_FILES += ['bootstrap.js']
|
||||
|
||||
MOCHITEST_MANIFESTS += [
|
||||
'baselinecoverage/plain/mochitest.ini',
|
||||
|
@ -25,9 +25,8 @@
|
||||
// added until then.
|
||||
window.addEventListener("MozAfterPaint", function() {
|
||||
setTimeout(redirectToHarness, 0);
|
||||
|
||||
// In case the listener is not ready, re-try periodically
|
||||
setInterval(redirectToHarness, 5000);
|
||||
// In case the listener was not ready, try again after a few seconds.
|
||||
setTimeout(redirectToHarness, 5000);
|
||||
}, {once: true});
|
||||
|
||||
}
|
||||
|
@ -1 +0,0 @@
|
||||
[]
|
@ -670,13 +670,11 @@ public:
|
||||
NS_DECL_NSIJSRAIIHELPER
|
||||
|
||||
using Override = AutoTArray<nsCString, 2>;
|
||||
using Content = AutoTArray<nsCString, 2>;
|
||||
using Locale = AutoTArray<nsCString, 3>;
|
||||
|
||||
RegistryEntries(FileLocation& location, nsTArray<Override>&& overrides, nsTArray<Content>&& content, nsTArray<Locale>&& locales)
|
||||
RegistryEntries(FileLocation& location, nsTArray<Override>&& overrides, nsTArray<Locale>&& locales)
|
||||
: mLocation(location)
|
||||
, mOverrides(std::move(overrides))
|
||||
, mContent(std::move(content))
|
||||
, mLocales(std::move(locales))
|
||||
{}
|
||||
|
||||
@ -691,7 +689,6 @@ protected:
|
||||
private:
|
||||
FileLocation mLocation;
|
||||
const nsTArray<Override> mOverrides;
|
||||
const nsTArray<Content> mContent;
|
||||
const nsTArray<Locale> mLocales;
|
||||
};
|
||||
|
||||
@ -709,11 +706,6 @@ RegistryEntries::Register()
|
||||
cr->ManifestOverride(context, 0, const_cast<char**>(args), 0);
|
||||
}
|
||||
|
||||
for (auto& content: mContent) {
|
||||
const char* args[] = {content[0].get(), content[1].get()};
|
||||
cr->ManifestContent(context, 0, const_cast<char**>(args), 0);
|
||||
}
|
||||
|
||||
for (auto& locale : mLocales) {
|
||||
const char* args[] = {locale[0].get(), locale[1].get(), locale[2].get()};
|
||||
cr->ManifestLocale(context, 0, const_cast<char**>(args), 0);
|
||||
@ -759,7 +751,6 @@ AddonManagerStartup::RegisterChrome(nsIURI* manifestURI, JS::HandleValue locatio
|
||||
|
||||
|
||||
nsTArray<RegistryEntries::Locale> locales;
|
||||
nsTArray<RegistryEntries::Content> content;
|
||||
nsTArray<RegistryEntries::Override> overrides;
|
||||
|
||||
JS::RootedObject locs(cx, &locations.toObject());
|
||||
@ -787,9 +778,6 @@ AddonManagerStartup::RegisterChrome(nsIURI* manifestURI, JS::HandleValue locatio
|
||||
if (type.EqualsLiteral("override")) {
|
||||
NS_ENSURE_TRUE(vals.Length() == 2, NS_ERROR_INVALID_ARG);
|
||||
overrides.AppendElement(vals);
|
||||
} else if (type.EqualsLiteral("content")) {
|
||||
NS_ENSURE_TRUE(vals.Length() == 2, NS_ERROR_INVALID_ARG);
|
||||
content.AppendElement(vals);
|
||||
} else if (type.EqualsLiteral("locale")) {
|
||||
NS_ENSURE_TRUE(vals.Length() == 3, NS_ERROR_INVALID_ARG);
|
||||
locales.AppendElement(vals);
|
||||
@ -808,7 +796,6 @@ AddonManagerStartup::RegisterChrome(nsIURI* manifestURI, JS::HandleValue locatio
|
||||
|
||||
auto entry = MakeRefPtr<RegistryEntries>(location,
|
||||
std::move(overrides),
|
||||
std::move(content),
|
||||
std::move(locales));
|
||||
|
||||
entry->Register();
|
||||
|
@ -16,7 +16,6 @@ add_task(async function() {
|
||||
let uri2 = getFileURI("manifest.json");
|
||||
|
||||
let overrideURL = Services.io.newURI("chrome://global/content/foo");
|
||||
let contentURL = Services.io.newURI("chrome://test/content/foo");
|
||||
let localeURL = Services.io.newURI("chrome://global/locale/foo");
|
||||
|
||||
let origOverrideURL = registry.convertChromeURL(overrideURL);
|
||||
@ -25,29 +24,23 @@ add_task(async function() {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
let entry1 = aomStartup.registerChrome(uri1, [
|
||||
["override", "chrome://global/content/foo", file1.spec],
|
||||
["content", "test", file2.spec + "/"],
|
||||
["locale", "global", "en-US", file2.spec + "/"],
|
||||
]);
|
||||
|
||||
let entry2 = aomStartup.registerChrome(uri2, [
|
||||
["override", "chrome://global/content/foo", file2.spec],
|
||||
["content", "test", file1.spec + "/"],
|
||||
["locale", "global", "en-US", file1.spec + "/"],
|
||||
]);
|
||||
|
||||
// Initially, the second entry should override the first.
|
||||
equal(registry.convertChromeURL(overrideURL).spec, file2.spec);
|
||||
let file = file1.spec + "/foo";
|
||||
equal(registry.convertChromeURL(contentURL).spec, file);
|
||||
equal(registry.convertChromeURL(localeURL).spec, file);
|
||||
equal(registry.convertChromeURL(localeURL).spec, file1.spec + "/foo");
|
||||
|
||||
// After destroying the second entry, the first entry should now take
|
||||
// After destroying the second entry, the first entry should not take
|
||||
// precedence.
|
||||
entry2.destruct();
|
||||
equal(registry.convertChromeURL(overrideURL).spec, file1.spec);
|
||||
file = file2.spec + "/foo";
|
||||
equal(registry.convertChromeURL(contentURL).spec, file);
|
||||
equal(registry.convertChromeURL(localeURL).spec, file);
|
||||
equal(registry.convertChromeURL(localeURL).spec, file2.spec + "/foo");
|
||||
|
||||
// After dropping the reference to the first entry and allowing it to
|
||||
// be GCed, we should be back to the original entries.
|
||||
@ -56,9 +49,6 @@ add_task(async function() {
|
||||
Cu.forceCC();
|
||||
equal(registry.convertChromeURL(overrideURL).spec, origOverrideURL.spec);
|
||||
equal(registry.convertChromeURL(localeURL).spec, origLocaleURL.spec);
|
||||
Assert.throws(() => registry.convertChromeURL(contentURL),
|
||||
e => e.result == Cr.NS_ERROR_FILE_NOT_FOUND,
|
||||
"chrome://test/ should no longer be registered");
|
||||
});
|
||||
|
||||
add_task(async function() {
|
||||
@ -68,6 +58,7 @@ add_task(async function() {
|
||||
["foo"],
|
||||
[{}],
|
||||
[[]],
|
||||
[["content", "foo", "bar"]],
|
||||
[["locale", "global"]],
|
||||
[["locale", "global", "en", "foo", "foo"]],
|
||||
[["override", "en"]],
|
||||
|
Loading…
Reference in New Issue
Block a user