Backed out 2 changesets (bug 1451513) for likely causing frequent mochitest suite hangs (bug 1414495). a=backout
authorSebastian Hengst <archaeopteryx@coole-files.de>
Wed, 25 Jul 2018 17:19:14 +0300
changeset 822631 befd4afd29bf9c145701853d308a59b7fc37e6a4
parent 822630 fa78cd1a688077dd1b3f5fb87be24c0b63d37ed6
child 822632 72a6ee705c3f2194f863aefb2d7053164e4c1ea8
child 822648 4c4abe35d80851590954b52eabf828c763104696
child 822694 ddf6b39546209b52fb73623f27660902ff1e43a6
child 822703 8983fdbc6f3e8d09047a41294cced31c6e0b3140
child 822877 4532a813d8005f9550a6f04cd80eb4b966b0c279
child 823006 53036c7d56c532d58fe4db0c97d789bd6b61c680
child 823108 3df15b95d29c7af203bc1ddc877ab53b10c2029d
child 823109 c1495212f564f35072693526f9f660e0fd5e156a
child 823206 5786d46747030d9e83fccf72a8b0c79599b3079e
child 823267 b69b11428b0b416a83df5bf5d065f42246f75edb
child 823575 2d021ac109132149802bffe2442a1371ae03caf6
child 823695 52cf41e3d8b6fff225345ddcad9a9ff4ac0b847d
push id117413
push userbmo:andrei.a.lazar@softvision.ro
push dateWed, 25 Jul 2018 14:42:19 +0000
reviewersbackout
bugs1451513, 1414495
milestone63.0a1
backs out604167986098726b86ea0f9252a63abab36d35c4
afc5c4bd60da7d08b90b46c70af3f59a4db9fb35
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)
testing/mochitest/api.js
testing/mochitest/bootstrap.js
testing/mochitest/jar.mn
testing/mochitest/manifest.json
testing/mochitest/moz.build
testing/mochitest/redirect.html
testing/mochitest/schema.json
toolkit/mozapps/extensions/AddonManagerStartup.cpp
toolkit/mozapps/extensions/test/xpcshell/test_registerchrome.js
rename from testing/mochitest/api.js
rename to testing/mochitest/bootstrap.js
--- a/testing/mochitest/api.js
+++ b/testing/mochitest/bootstrap.js
@@ -1,14 +1,12 @@
 /* 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/. */
 
-/* globals ExtensionAPI */
-
 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);
@@ -35,30 +33,20 @@ const windowTracker = {
       if (documentURI !== "chrome://browser/content/browser.xul") {
         return;
       }
       loadChromeScripts(window);
     }
   },
 };
 
-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();
   }
 }
 
 // ///// Desktop ///////
 
 var WindowListener = {
   // browser-test.js is only loaded into the first window. Setup that
@@ -101,43 +89,34 @@ function loadMochitest(e) {
   }
 
   WindowListener.setupWindow(win);
   Services.wm.addListener(WindowListener);
 
   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],
-    ]);
+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);
+  }
+}
 
-    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);
-    }
-  }
-
-  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) {}
+
new file mode 100644
--- /dev/null
+++ b/testing/mochitest/jar.mn
@@ -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)
+
deleted file mode 100644
--- a/testing/mochitest/manifest.json
+++ /dev/null
@@ -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"]
-      }
-    }
-  }
-}
--- a/testing/mochitest/moz.build
+++ b/testing/mochitest/moz.build
@@ -8,77 +8,23 @@ DIRS += [
     'manifests',
     'tests',
     'ssltunnel',
     'BrowserTestUtils',
 ]
 
 XPI_NAME = 'mochijar'
 
+JAR_MANIFESTS += ['jar.mn']
+
 USE_EXTENSION_MANIFEST = True
 
-FINAL_TARGET_FILES += [
-    'api.js',
-    'manifest.json',
-    'schema.json',
-]
-
-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_PP_FILES += ['install.rdf']
 
-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',
     'tests/MochiKit-1.4.2/tests/mochitest.ini',
 ]
 
 MOCHITEST_CHROME_MANIFESTS += [
     'baselinecoverage/chrome/chrome.ini',
--- a/testing/mochitest/redirect.html
+++ b/testing/mochitest/redirect.html
@@ -20,19 +20,18 @@
       redirect("chrome://mochikit/content/harness.xul");
     }
 
     function onLoad() {
       // Wait for MozAfterPaint, since the listener in browser-test.js is not
       // 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});
 
     }
   </script>
 </head>
 
 <body onload="onLoad();">
 redirecting...
deleted file mode 100644
--- a/testing/mochitest/schema.json
+++ /dev/null
@@ -1,1 +0,0 @@
-[]
--- a/toolkit/mozapps/extensions/AddonManagerStartup.cpp
+++ b/toolkit/mozapps/extensions/AddonManagerStartup.cpp
@@ -665,38 +665,35 @@ static bool sObserverRegistered;
 class RegistryEntries final : public nsIJSRAIIHelper
                             , public LinkedListElement<RegistryEntries>
 {
 public:
   NS_DECL_ISUPPORTS
   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))
   {}
 
   void Register();
 
 protected:
   virtual ~RegistryEntries()
   {
     Unused << Destruct();
   }
 
 private:
   FileLocation mLocation;
   const nsTArray<Override> mOverrides;
-  const nsTArray<Content> mContent;
   const nsTArray<Locale> mLocales;
 };
 
 NS_IMPL_ISUPPORTS(RegistryEntries, nsIJSRAIIHelper)
 
 void
 RegistryEntries::Register()
 {
@@ -704,21 +701,16 @@ RegistryEntries::Register()
 
   nsChromeRegistry::ManifestProcessingContext context(NS_EXTENSION_LOCATION, mLocation);
 
   for (auto& override : mOverrides) {
     const char* args[] = {override[0].get(), override[1].get()};
     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);
   }
 }
 
 NS_IMETHODIMP
 RegistryEntries::Destruct()
@@ -754,17 +746,16 @@ AddonManagerStartup::RegisterChrome(nsIU
   NS_ENSURE_ARG_POINTER(manifestURI);
   NS_ENSURE_TRUE(IsArray(locations), NS_ERROR_INVALID_ARG);
 
   FileLocation location;
   MOZ_TRY_VAR(location, GetFileLocation(manifestURI));
 
 
   nsTArray<RegistryEntries::Locale> locales;
-  nsTArray<RegistryEntries::Content> content;
   nsTArray<RegistryEntries::Override> overrides;
 
   JS::RootedObject locs(cx, &locations.toObject());
   JS::RootedValue arrayVal(cx);
   JS::RootedObject array(cx);
 
   for (auto elem : ArrayIter(cx, locs)) {
     arrayVal = elem.Value();
@@ -782,19 +773,16 @@ AddonManagerStartup::RegisterChrome(nsIU
     NS_ENSURE_TRUE(vals.Length() > 0, NS_ERROR_INVALID_ARG);
 
     nsCString type = vals[0];
     vals.RemoveElementAt(0);
 
     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);
     } else {
       return NS_ERROR_INVALID_ARG;
     }
   }
 
@@ -803,17 +791,16 @@ AddonManagerStartup::RegisterChrome(nsIU
     NS_ENSURE_TRUE(obs, NS_ERROR_UNEXPECTED);
     obs->AddObserver(this, "chrome-manifests-loaded", false);
 
     sObserverRegistered = true;
   }
 
   auto entry = MakeRefPtr<RegistryEntries>(location,
                                            std::move(overrides),
-                                           std::move(content),
                                            std::move(locales));
 
   entry->Register();
   GetRegistryEntries().insertBack(entry);
 
   entry.forget(result);
   return NS_OK;
 }
--- a/toolkit/mozapps/extensions/test/xpcshell/test_registerchrome.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_registerchrome.js
@@ -11,68 +11,59 @@ add_task(async function() {
 
   let file1 = getFileURI("file1");
   let file2 = getFileURI("file2");
 
   let uri1 = getFileURI("chrome.manifest");
   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);
   let origLocaleURL = registry.convertChromeURL(localeURL);
 
   // 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.
   entry1 = null;
   Cu.forceGC();
   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() {
   const INVALID_VALUES = [
     {},
     "foo",
     ["foo"],
     [{}],
     [[]],
+    [["content", "foo", "bar"]],
     [["locale", "global"]],
     [["locale", "global", "en", "foo", "foo"]],
     [["override", "en"]],
     [["override", "en", "US", "OR"]],
   ];
 
   let uri = getFileURI("chrome.manifest");
   for (let arg of INVALID_VALUES) {