Bug 1485660 - Adapt DebuggerClient._pools to accept Front's and (now) Pool's. r=jdescottes
authorAlexandre Poirot <poirot.alex@gmail.com>
Mon, 15 Oct 2018 08:36:21 +0000
changeset 489607 1c7a643768d1fe54149d93ff17d25b532a794adc
parent 489606 9b5cb8d01b721812b55c3f2d941437bb06081104
child 489608 237852763567335e4134d7510dd1c0c0107e47bc
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersjdescottes
bugs1485660
milestone64.0a1
Bug 1485660 - Adapt DebuggerClient._pools to accept Front's and (now) Pool's. r=jdescottes MozReview-Commit-ID: EWka8fMBcK5 Depends on D7462 Differential Revision: https://phabricator.services.mozilla.com/D8518
devtools/shared/client/debugger-client.js
--- a/devtools/shared/client/debugger-client.js
+++ b/devtools/shared/client/debugger-client.js
@@ -24,16 +24,17 @@ loader.lazyRequireGetter(this, "EventEmi
 loader.lazyRequireGetter(this, "WebConsoleClient", "devtools/shared/webconsole/client", true);
 loader.lazyRequireGetter(this, "AddonClient", "devtools/shared/client/addon-client");
 loader.lazyRequireGetter(this, "RootClient", "devtools/shared/client/root-client");
 loader.lazyRequireGetter(this, "BrowsingContextFront", "devtools/shared/fronts/targets/browsing-context", true);
 loader.lazyRequireGetter(this, "ThreadClient", "devtools/shared/client/thread-client");
 loader.lazyRequireGetter(this, "WorkerClient", "devtools/shared/client/worker-client");
 loader.lazyRequireGetter(this, "ObjectClient", "devtools/shared/client/object-client");
 loader.lazyRequireGetter(this, "Pool", "devtools/shared/protocol", true);
+loader.lazyRequireGetter(this, "Front", "devtools/shared/protocol", true);
 
 // Retrieve the major platform version, i.e. if we are on Firefox 64.0a1, it will be 64.
 const PLATFORM_MAJOR_VERSION = AppConstants.MOZ_APP_VERSION.match(/\d+/)[0];
 
 // Define the minimum officially supported version of Firefox when connecting to a remote
 // runtime. (Use ".0a1" to support the very first nightly version)
 // This matches the release channel's version when we are on nightly,
 // or 2 versions before when we are on other channels.
@@ -1041,17 +1042,21 @@ DebuggerClient.prototype = {
     // Use a Set because some fronts (like domwalker) seem to have multiple parents.
     const fronts = new Set();
     const poolsToVisit = [...this._pools];
 
     // With protocol.js, each front can potentially have it's own pools containing child
     // fronts, forming a tree.  Descend through all the pools to locate all child fronts.
     while (poolsToVisit.length) {
       const pool = poolsToVisit.shift();
-      fronts.add(pool);
+      // `_pools` contains either Front's or Pool's, we only want to collect Fronts here.
+      // Front inherits from Pool which exposes `poolChildren`.
+      if (pool instanceof Front) {
+        fronts.add(pool);
+      }
       for (const child of pool.poolChildren()) {
         poolsToVisit.push(child);
       }
     }
 
     // For each front, wait for its requests to settle
     for (const front of fronts) {
       if (front.hasRequests()) {