Bug 1304941 - reconnect onTabChanged listener before fetching the tablist;r=jryans a=gchang
authorJulian Descottes <jdescottes@mozilla.com>
Wed, 08 Feb 2017 17:08:42 +0100
changeset 378594 fd1161d3089e8f8fcdab7e9081de268dcb9b2f4b
parent 378593 53189303b53dbf20ca068c9081232b7ae7ec01d4
child 378595 df611c3e7160259bd1dbed3363e7d0b3e6ed34b4
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjryans, gchang
bugs1304941
milestone53.0a2
Bug 1304941 - reconnect onTabChanged listener before fetching the tablist;r=jryans a=gchang MozReview-Commit-ID: FZYDKH3F21O
devtools/client/aboutdebugging/test/browser_tabs.js
devtools/server/actors/root.js
--- a/devtools/client/aboutdebugging/test/browser_tabs.js
+++ b/devtools/client/aboutdebugging/test/browser_tabs.js
@@ -37,16 +37,20 @@ add_task(function* () {
   let newTabTarget = newNames[0];
 
   // Then wait for title update, but on slow test runner, the title may already
   // be set to the expected value
   if (newTabTarget.textContent != "foo") {
     yield waitForContentMutation(newTabTarget);
   }
 
+  // Then wait for title update, but on slow test runner, the title may already
+  // be set to the expected value
+  yield waitUntil(() => newTabTarget.title === TAB_URL);
+
   // Check that the new tab appears in the UI
   is(newTabTarget.textContent, "foo", "The tab title got updated");
   is(newTabTarget.title, TAB_URL, "The tab tooltip is the url");
 
   // Finally, close the tab
   let onTabsUpdate = waitForMutation(tabsElement, { childList: true });
   yield removeTab(newTab);
   yield onTabsUpdate;
--- a/devtools/server/actors/root.js
+++ b/devtools/server/actors/root.js
@@ -246,16 +246,22 @@ RootActor.prototype = {
   onListTabs: function () {
     let tabList = this._parameters.tabList;
     if (!tabList) {
       return { from: this.actorID, error: "noTabs",
                message: "This root actor has no browser tabs." };
     }
 
     /*
+     * Now that a client has requested the list of tabs, we reattach the onListChanged
+     * listener in order to be notified if the list of tabs changes again in the future.
+     */
+    tabList.onListChanged = this._onTabListChanged;
+
+    /*
      * Walk the tab list, accumulating the array of tab actors for the
      * reply, and moving all the actors to a new ActorPool. We'll
      * replace the old tab actor pool with the one we build here, thus
      * retiring any actors that didn't get listed again, and preparing any
      * new actors to receive packets.
      */
     let newActorPool = new ActorPool(this.conn);
     let tabActorList = [];
@@ -295,23 +301,16 @@ RootActor.prototype = {
       /* If a root window is accessible, include its URL. */
       if (this.url) {
         reply.url = this.url;
       }
 
       /* DebuggerServer.addGlobalActor support: name actors in 'listTabs' reply. */
       this._appendExtraActors(reply);
 
-      /*
-       * Now that we're actually going to report the contents of tabList to
-       * the client, we're responsible for letting the client know if it
-       * changes.
-       */
-      tabList.onListChanged = this._onTabListChanged;
-
       return reply;
     });
   },
 
   onGetTab: function (options) {
     let tabList = this._parameters.tabList;
     if (!tabList) {
       return { error: "noTabs",