Bug 1500079 - Ensure that new about:debugging tests wait for initial load requests before proceeding with the tests. r=jdescottes
authorAlexandre Poirot <poirot.alex@gmail.com>
Mon, 29 Oct 2018 16:10:46 +0000
changeset 443355 e732689cf7e797420d24b5a7c4248100ecb3c63e
parent 443354 1e422e5034f1e301eafbe65d27d9f26ba5f08ac1
child 443356 469e083ccd18793bec63a26b3ffd6dd47d78c810
push id34954
push userrgurzau@mozilla.com
push dateMon, 29 Oct 2018 22:00:12 +0000
treeherdermozilla-central@b851d42e2620 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes
bugs1500079
milestone65.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 1500079 - Ensure that new about:debugging tests wait for initial load requests before proceeding with the tests. r=jdescottes MozReview-Commit-ID: 9ClZ2lkdq01 Depends on D8868 Differential Revision: https://phabricator.services.mozilla.com/D9084
devtools/client/aboutdebugging-new/aboutdebugging.js
devtools/client/aboutdebugging-new/test/browser/head.js
--- a/devtools/client/aboutdebugging-new/aboutdebugging.js
+++ b/devtools/client/aboutdebugging-new/aboutdebugging.js
@@ -135,8 +135,11 @@ const AboutDebugging = {
 
 window.addEventListener("DOMContentLoaded", () => {
   AboutDebugging.init();
 }, { once: true });
 
 window.addEventListener("unload", () => {
   AboutDebugging.destroy();
 }, {once: true});
+
+// Expose AboutDebugging to tests so that they can access to the store.
+window.AboutDebugging = AboutDebugging;
--- a/devtools/client/aboutdebugging-new/test/browser/head.js
+++ b/devtools/client/aboutdebugging-new/test/browser/head.js
@@ -8,16 +8,21 @@
 
 "use strict";
 
 // Load the shared-head file first.
 Services.scriptloader.loadSubScript(
   "chrome://mochitests/content/browser/devtools/client/shared/test/shared-head.js",
   this);
 
+// Load the shared Redux helpers into this compartment.
+Services.scriptloader.loadSubScript(
+  "chrome://mochitests/content/browser/devtools/client/shared/test/shared-redux-head.js",
+  this);
+
 // Load collapsibilities helpers
 Services.scriptloader.loadSubScript(
   CHROME_URL_ROOT + "debug-target-pane_collapsibilities_head.js", this);
 
 // Make sure the ADB addon is removed and ADB is stopped when the test ends.
 registerCleanupFunction(async function() {
   try {
     const { adbAddon } = require("devtools/shared/adb/adb-addon");
@@ -40,28 +45,42 @@ async function enableNewAboutDebugging()
 async function openAboutDebugging(page, win) {
   await enableNewAboutDebugging();
 
   info("opening about:debugging");
   const tab = await addTab("about:debugging", { window: win });
   const browser = tab.linkedBrowser;
   const document = browser.contentDocument;
   const window = browser.contentWindow;
+  const { AboutDebugging } = window;
 
   info("Wait until the main about debugging container is available");
   await waitUntil(() => document.querySelector(".app"));
 
   info("Wait until the client connection was established");
   await waitUntil(() => document.querySelector(".js-runtime-page"));
 
   // Wait until the about:debugging target is visible in the tab list
   // Otherwise, we might have a race condition where TAB1 is discovered by the initial
   // listTabs from the watchRuntime action, instead of being discovered after the
   // TAB_UPDATED event. See analysis in Bug 1493968.
-  await waitUntil(() => findDebugTargetByText("about:debugging", document));
+  info("Wait until tabs are displayed");
+  await waitUntilState(AboutDebugging.store, state => {
+    return state.debugTargets.tabs.length > 0;
+  });
+
+  info("Wait until pre-installed add-ons are displayed");
+  await waitUntilState(AboutDebugging.store, state => {
+    return state.debugTargets.installedExtensions.length > 0;
+  });
+
+  info("Wait until internal 'other workers' are displayed");
+  await waitUntilState(AboutDebugging.store, state => {
+    return state.debugTargets.otherWorkers.length > 0;
+  });
 
   return { tab, document, window };
 }
 
 /**
  * Navigate to the Connect page. Resolves when the Connect page is rendered.
  */
 async function selectConnectPage(doc) {