Bug 1518777 - add onReload event to navigated action; r=ochameau,jlast
authoryulia <ystartsev@mozilla.com>
Thu, 24 Jan 2019 11:50:32 +0000
changeset 515279 6a565ef5ffe71637d64eda3aeec2c44b41fdf3d7
parent 515278 9c646afb94b2e8b64433cf5ddfb314fee6190f20
child 515280 e7cd613e6bfb2423c7ba506826524bb45c49d462
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau, jlast
bugs1518777
milestone66.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 1518777 - add onReload event to navigated action; r=ochameau,jlast Differential Revision: https://phabricator.services.mozilla.com/D16540
devtools/client/debugger/new/panel.js
devtools/client/debugger/new/src/actions/navigation.js
devtools/client/debugger/new/src/actions/types/index.js
devtools/client/framework/test/browser_toolbox_window_title_changes.js
--- a/devtools/client/debugger/new/panel.js
+++ b/devtools/client/debugger/new/panel.js
@@ -45,17 +45,18 @@ DebuggerPanel.prototype = {
             inspector,
           ] = await Promise.all([onGripNodeToFront, onSelectInspector]);
 
           const onInspectorUpdated = inspector.once("inspector-updated");
           const onNodeFrontSet = this.toolbox.selection
             .setNodeFront(front, { reason: "debugger" });
 
           return Promise.all([onNodeFrontSet, onInspectorUpdated]);
-        }.bind(this)
+        }.bind(this),
+        onReload: this.onReload.bind(this)
       }
     });
 
     this._actions = actions;
     this._store = store;
     this._selectors = selectors;
     this._client = client;
     this.isReady = true;
@@ -119,15 +120,19 @@ DebuggerPanel.prototype = {
   selectSource(url, line) {
     this._actions.selectSourceURL(url, { line });
   },
 
   getSource(sourceURL) {
     return this._selectors.getSourceByURL(this._getState(), sourceURL);
   },
 
+  onReload: function() {
+    this.emit("reloaded");
+  },
+
   destroy: function() {
     this.panelWin.Debugger.destroy();
     this.emit("destroyed");
   }
 };
 
 exports.DebuggerPanel = DebuggerPanel;
--- a/devtools/client/debugger/new/src/actions/navigation.js
+++ b/devtools/client/debugger/new/src/actions/navigation.js
@@ -70,16 +70,20 @@ export function connect(url: string, act
   };
 }
 
 /**
  * @memberof actions/navigation
  * @static
  */
 export function navigated() {
-  return async function({ dispatch, getState, client }: ThunkArgs) {
+  return async function({ dispatch, getState, client, onReload }: ThunkArgs) {
+    // this time out is used to wait for sources. If we have 0 sources, it is likely
+    // that the sources are being loaded from the bfcache, and we should make an explicit
+    // request to the server to load them.
     await waitForMs(100);
     if (Object.keys(getSources(getState())).length == 0) {
       const sources = await client.fetchSources();
       dispatch(newSources(sources));
     }
+    onReload();
   };
 }
--- a/devtools/client/debugger/new/src/actions/types/index.js
+++ b/devtools/client/debugger/new/src/actions/types/index.js
@@ -37,17 +37,18 @@ import type { ASTAction } from "./ASTAct
  */
 export type ThunkArgs = {
   dispatch: (action: any) => Promise<any>,
   getState: () => State,
   client: any,
   sourceMaps: any,
   openLink: (url: string) => void,
   openWorkerToolbox: (worker: Worker) => void,
-  openElementInInspector: (grip: Object) => void
+  openElementInInspector: (grip: Object) => void,
+  onReload: () => void
 };
 
 export type Thunk = ThunkArgs => any;
 
 export type ActionType = Object | Function;
 
 type ProjectTextSearchResult = {
   sourceId: string,
--- a/devtools/client/framework/test/browser_toolbox_window_title_changes.js
+++ b/devtools/client/framework/test/browser_toolbox_window_title_changes.js
@@ -15,16 +15,17 @@ function test() {
   const TOOL_ID_1 = "webconsole";
   const TOOL_ID_2 = "jsdebugger";
 
   const NAME_1 = "";
   const NAME_2 = "";
   const NAME_3 = "Toolbox test for title update";
 
   let toolbox;
+  let panel;
 
   addTab(URL_1).then(async function() {
     let target = await TargetFactory.forTab(gBrowser.selectedTab);
     gDevTools.showToolbox(target, null, Toolbox.HostType.BOTTOM)
       .then(function(aToolbox) {
         toolbox = aToolbox;
       })
       .then(() => toolbox.selectTool(TOOL_ID_1))
@@ -34,35 +35,39 @@ function test() {
         // We have to first switch the host in order to spawn the new top level window
         // on which we are going to listen from title change event
         return toolbox.switchHost(Toolbox.HostType.WINDOW)
           .then(() => waitForTitleChange(toolbox));
       })
       .then(checkTitle.bind(null, NAME_1, URL_1, "toolbox undocked"))
 
     // switch to different tool and check title
-      .then(() => {
+      .then(async () => {
         const onTitleChanged = waitForTitleChange(toolbox);
-        toolbox.selectTool(TOOL_ID_2);
+        panel = await toolbox.selectTool(TOOL_ID_2);
         return onTitleChanged;
       })
       .then(checkTitle.bind(null, NAME_1, URL_1, "tool changed"))
 
     // navigate to different local url and check title
-      .then(function() {
+      .then(async function() {
         const onTitleChanged = waitForTitleChange(toolbox);
+        const waitForReloaded = panel.once("reloaded");
         BrowserTestUtils.loadURI(gBrowser, URL_2);
+        await waitForReloaded;
         return onTitleChanged;
       })
       .then(checkTitle.bind(null, NAME_2, URL_2, "url changed"))
 
     // navigate to a real url and check title
-      .then(() => {
+      .then(async () => {
         const onTitleChanged = waitForTitleChange(toolbox);
+        const waitForReloaded = panel.once("reloaded");
         BrowserTestUtils.loadURI(gBrowser, URL_3);
+        await waitForReloaded;
         return onTitleChanged;
       })
       .then(checkTitle.bind(null, NAME_3, URL_3, "url changed"))
 
     // destroy toolbox, create new one hosted in a window (with a
     // different tool id), and check title
       .then(function() {
         // Give the tools a chance to handle the navigation event before