Bug 1497348 - Wait for the inspector to be ready after reload; r=yzen
authorPatrick Brosset <pbrosset@mozilla.com>
Thu, 18 Oct 2018 07:57:02 +0000
changeset 490238 125e5170ef3a92d25ad95cf14df1cc564a4e0a52
parent 490237 d3dc7831efa89c4a464ba2aeb4252ce984185cfb
child 490239 d522a86504a76831e59348784c25e81162fe540a
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersyzen
bugs1497348
milestone64.0a1
Bug 1497348 - Wait for the inspector to be ready after reload; r=yzen Depends on D8974 Differential Revision: https://phabricator.services.mozilla.com/D8980
devtools/client/framework/test/browser_toolbox_window_reload_target.js
--- a/devtools/client/framework/test/browser_toolbox_window_reload_target.js
+++ b/devtools/client/framework/test/browser_toolbox_window_reload_target.js
@@ -60,19 +60,16 @@ add_task(async function() {
     await testOneTool(toolbox, toolID);
   }
 
   info("Switch back to docked mode");
   await toolbox.switchHost(Toolbox.HostType.BOTTOM);
 
   gBrowser.selectedBrowser.messageManager.removeMessageListener("devtools:test:load", reloadCounter);
 
-  // If we finish too early, the inspector breaks promises.
-  await toolbox.getPanel("inspector").once("new-root");
-
   await toolbox.destroy();
   gBrowser.removeCurrentTab();
 });
 
 async function testOneTool(toolbox, toolID) {
   info(`Select tool ${toolID}`);
   await toolbox.selectTool(toolID);
 
@@ -83,19 +80,24 @@ async function testOneTool(toolbox, tool
 }
 
 function testReload(shortcut, toolbox, toolID) {
   info(`Reload with ${shortcut}`);
 
   const mm = gBrowser.selectedBrowser.messageManager;
 
   return new Promise(resolve => {
+    // The inspector needs some special care.
+    const toolUpdated = toolID === "inspector"
+      ? toolbox.getPanel("inspector").once("new-root")
+      : Promise.resolve();
+
     const complete = () => {
       mm.removeMessageListener("devtools:test:load", complete);
-      resolve();
+      toolUpdated.then(resolve);
     };
     mm.addMessageListener("devtools:test:load", complete);
 
     toolbox.win.focus();
     synthesizeKeyShortcut(L10N.getStr(shortcut), toolbox.win);
     reloadsSent++;
   });
 }