Bug 1489219 - Wait until runtime page is ready;r=daisuke,ladybenko
authorJulian Descottes <jdescottes@mozilla.com>
Fri, 07 Sep 2018 17:41:44 +0200
changeset 484463 483b0f400100966c231429c3a9a50b726216a64d
parent 484462 77fdbbe9e2dfb42801149f3a20aa9b5e8ce52710
child 484464 e6d62c43b35566b3fc782594b74878e2bacc4205
push id241
push userfmarier@mozilla.com
push dateMon, 24 Sep 2018 21:48:02 +0000
reviewersdaisuke, ladybenko
bugs1489219
milestone64.0a1
Bug 1489219 - Wait until runtime page is ready;r=daisuke,ladybenko
devtools/client/aboutdebugging-new/src/actions/ui.js
devtools/client/aboutdebugging-new/src/components/RuntimePage.js
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_thisfirefox.js
--- a/devtools/client/aboutdebugging-new/src/actions/ui.js
+++ b/devtools/client/aboutdebugging-new/src/actions/ui.js
@@ -16,23 +16,23 @@ const Actions = require("./index");
 function selectPage(page) {
   return async (dispatch, getState) => {
     const currentPage = getState().ui.selectedPage;
     if (page === currentPage) {
       // Nothing to dispatch if the page is the same as the current page.
       return;
     }
 
-    dispatch({ type: PAGE_SELECTED, page });
+    if (page === PAGES.THIS_FIREFOX) {
+      await dispatch(Actions.connectRuntime());
+    } else {
+      await dispatch(Actions.disconnectRuntime());
+    }
 
-    if (page === PAGES.THIS_FIREFOX) {
-      dispatch(Actions.connectRuntime());
-    } else {
-      dispatch(Actions.disconnectRuntime());
-    }
+    dispatch({ type: PAGE_SELECTED, page });
   };
 }
 
 function updateDebugTargetCollapsibility(key, isCollapsed) {
   return { type: DEBUG_TARGET_COLLAPSIBILITY_UPDATED, key, isCollapsed };
 }
 
 function updateNetworkLocations(locations) {
--- a/devtools/client/aboutdebugging-new/src/components/RuntimePage.js
+++ b/devtools/client/aboutdebugging-new/src/components/RuntimePage.js
@@ -49,17 +49,17 @@ class RuntimePage extends PureComponent 
       serviceWorkers,
       sharedWorkers,
       tabs,
       temporaryExtensions,
     } = this.props;
 
     return dom.article(
       {
-        className: "page",
+        className: "page js-runtime-page",
       },
       RuntimeInfo({
         icon: "chrome://branding/content/icon64.png",
         name: Services.appinfo.name,
         version: Services.appinfo.version,
       }),
       TemporaryExtensionInstaller({ dispatch }),
       Localized(
--- a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_thisfirefox.js
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_thisfirefox.js
@@ -13,17 +13,20 @@ const EXPECTED_TARGET_PANES = [
   "Extensions",
   "Tabs",
   "Service Workers",
   "Shared Workers",
   "Other Workers",
 ];
 
 add_task(async function() {
-  const { document } = await openAboutDebugging();
+  const { document, tab } = await openAboutDebugging();
+
+  // Wait until the client connection was established.
+  await waitUntil(() => document.querySelector(".js-runtime-page"));
 
   // Check that the selected sidebar item is "This Firefox"
   const selectedSidebarItem = document.querySelector(".js-sidebar-item-selected");
   ok(selectedSidebarItem, "An item is selected in the sidebar");
   is(selectedSidebarItem.textContent, "This Firefox",
     "The selected sidebar item is This Firefox");
 
   const paneTitlesEls = document.querySelectorAll(".js-debug-target-pane-title");
@@ -31,9 +34,11 @@ add_task(async function() {
     "This Firefox has the expecte number of debug target categories");
 
   const paneTitles = [...paneTitlesEls].map(el => el.textContent);
 
   EXPECTED_TARGET_PANES.forEach(expectedPane => {
     ok(paneTitles.includes(expectedPane),
       "Expected debug target category found: " + expectedPane);
   });
+
+  await removeTab(tab);
 });