Bug 1507125 - Stop destroying DebuggerServer when moving from This Firefox runtime page;r=daisuke
authorJulian Descottes <jdescottes@mozilla.com>
Thu, 29 Nov 2018 06:29:41 +0000
changeset 448702 0f93bf2d53ebd04b56f2cc6fa66c9028b7e08db3
parent 448701 42cc52da72dccf71d107d2d675c69649dcac204d
child 448703 dcec04522fb6d455270c8fe5059660e83574712c
push id35123
push userdvarga@mozilla.com
push dateThu, 29 Nov 2018 16:53:13 +0000
treeherdermozilla-central@85dab0b93689 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdaisuke
bugs1507125
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 1507125 - Stop destroying DebuggerServer when moving from This Firefox runtime page;r=daisuke Differential Revision: https://phabricator.services.mozilla.com/D13137
devtools/client/aboutdebugging-new/src/actions/runtimes.js
devtools/client/aboutdebugging-new/test/browser/browser.ini
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_devtools.js
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_navigate.js
devtools/client/aboutdebugging-new/test/browser/head.js
--- a/devtools/client/aboutdebugging-new/src/actions/runtimes.js
+++ b/devtools/client/aboutdebugging-new/src/actions/runtimes.js
@@ -1,16 +1,14 @@
 /* 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/. */
 
 "use strict";
 
-const { DebuggerServer } = require("devtools/server/main");
-
 const Actions = require("./index");
 
 const {
   getCurrentRuntime,
   findRuntimeById,
 } = require("../modules/runtimes-state-helper");
 const { isSupportedDebugTarget } = require("../modules/debug-target-support");
 
@@ -110,20 +108,16 @@ function disconnectRuntime(id) {
       const { clientWrapper } = runtime.runtimeDetails;
 
       if (runtime.type === RUNTIMES.USB) {
         clientWrapper.removeListener("closed", onUSBDebuggerClientClosed);
       }
 
       await clientWrapper.close();
 
-      if (runtime.type === RUNTIMES.THIS_FIREFOX) {
-        DebuggerServer.destroy();
-      }
-
       dispatch({
         type: DISCONNECT_RUNTIME_SUCCESS,
         runtime: {
           id,
           type: runtime.type,
         },
       });
     } catch (e) {
--- a/devtools/client/aboutdebugging-new/test/browser/browser.ini
+++ b/devtools/client/aboutdebugging-new/test/browser/browser.ini
@@ -21,16 +21,17 @@ support-files =
 [browser_aboutdebugging_connect_networklocations.js]
 [browser_aboutdebugging_connect_toggle_usb_devices.js]
 skip-if = (os == 'linux' && bits == 32) # ADB start() fails on linux 32, see Bug 1499638
 [browser_aboutdebugging_connection_prompt_setting.js]
 [browser_aboutdebugging_debug-target-pane_collapsibilities_interaction.js]
 [browser_aboutdebugging_debug-target-pane_collapsibilities_preference.js]
 [browser_aboutdebugging_debug-target-pane_empty.js]
 [browser_aboutdebugging_debug-target-pane_usb_runtime.js]
+[browser_aboutdebugging_devtools.js]
 [browser_aboutdebugging_navigate.js]
 [browser_aboutdebugging_persist_connection.js]
 [browser_aboutdebugging_routes.js]
 [browser_aboutdebugging_sidebar_network_runtimes.js]
 [browser_aboutdebugging_sidebar_usb_runtime.js]
 [browser_aboutdebugging_sidebar_usb_runtime_connect.js]
 [browser_aboutdebugging_sidebar_usb_runtime_refresh.js]
 [browser_aboutdebugging_sidebar_usb_status.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_devtools.js
@@ -0,0 +1,40 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+/**
+ * Check that DevTools are not closed when leaving This Firefox runtime page.
+ */
+
+add_task(async function() {
+  info("Force all debug target panes to be expanded");
+  prepareCollapsibilitiesTest();
+
+  const { document, tab, window } = await openAboutDebugging();
+
+  const connectSidebarItem = findSidebarItemByText("Connect", document);
+  const connectLink = connectSidebarItem.querySelector(".js-sidebar-link");
+  ok(connectSidebarItem, "Found the Connect sidebar item");
+
+  info("Open devtools on the current about:debugging tab");
+  const toolbox = await openToolboxForTab(tab, "inspector");
+  const inspector = toolbox.getPanel("inspector");
+
+  info("DevTools starts workers, wait for requests to settle");
+  const store = window.AboutDebugging.store;
+  await waitForDispatch(store, "REQUEST_WORKERS_SUCCESS");
+  await waitForRequestsToSettle(store);
+
+  info("Click on the Connect item in the sidebar");
+  connectLink.click();
+  await waitForDispatch(store, "UNWATCH_RUNTIME_SUCCESS");
+
+  info("Wait until Connect page is displayed");
+  await waitUntil(() => document.querySelector(".js-connect-page"));
+
+  const markupViewElement = inspector.panelDoc.getElementById("markup-box");
+  ok(markupViewElement, "Inspector is still rendered");
+
+  await removeTab(tab);
+});
--- a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_navigate.js
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_navigate.js
@@ -44,18 +44,22 @@ add_task(async function() {
   info("Wait until Connect sidebar item is selected");
   await waitUntil(() => isSidebarItemSelected(connectSidebarItem));
   ok(!document.querySelector(".js-runtime-page"), "Runtime page no longer rendered");
 
   info("Open a new tab which should be listed when we go back to This Firefox");
   const backgroundTab2 = await addTab(TAB_URL_2, { background: true });
 
   info("Click on the ThisFirefox item in the sidebar");
+  const requestsSuccess = waitForRequestsSuccess(window);
   thisFirefoxLink.click();
 
+  info("Wait for all target requests to complete");
+  await requestsSuccess;
+
   info("Wait until ThisFirefox page is displayed");
   await waitUntil(() => document.querySelector(".js-runtime-page"));
   ok(isSidebarItemSelected(thisFirefoxSidebarItem),
     "ThisFirefox sidebar item is selected again");
   ok(!document.querySelector(".js-connect-page"), "Connect page no longer rendered");
 
   info("TAB2 should already be displayed in the debug targets");
   await waitUntil(() => findDebugTargetByText("TAB2", document));
--- a/devtools/client/aboutdebugging-new/test/browser/head.js
+++ b/devtools/client/aboutdebugging-new/test/browser/head.js
@@ -50,36 +50,39 @@ async function openAboutDebugging(page, 
   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;
-  await waitForInitialDispatch(window);
+  info("wait for the initial about:debugging requests to be successful");
+  await waitForRequestsSuccess(window);
 
   return { tab, document, window };
 }
 
 async function reloadAboutDebugging(tab) {
   info("reload about:debugging");
 
   await refreshTab(tab);
   const browser = tab.linkedBrowser;
   const document = browser.contentDocument;
   const window = browser.contentWindow;
-  await waitForInitialDispatch(window);
+  info("wait for the initial about:debugging requests to be successful");
+  await waitForRequestsSuccess(window);
 
   return document;
 }
 
-function waitForInitialDispatch(win) {
-  info("wait for the initial about debugging actions to be dispatched");
-
+// Wait for all about:debugging target request actions to succeed.
+// They will typically be triggered after watching a new runtime or loading
+// about:debugging.
+function waitForRequestsSuccess(win) {
   const { AboutDebugging } = win;
   return Promise.all([
     waitForDispatch(AboutDebugging.store, "REQUEST_EXTENSIONS_SUCCESS"),
     waitForDispatch(AboutDebugging.store, "REQUEST_TABS_SUCCESS"),
     waitForDispatch(AboutDebugging.store, "REQUEST_WORKERS_SUCCESS"),
   ]);
 }