diff --git a/devtools/client/inspector/inspector.js b/devtools/client/inspector/inspector.js index 4c38f413b7d8..b9430937e153 100644 --- a/devtools/client/inspector/inspector.js +++ b/devtools/client/inspector/inspector.js @@ -1302,7 +1302,11 @@ Inspector.prototype = { onResourceAvailable: function(resources) { for (const resource of resources) { if ( - resource.resourceType === this.toolbox.resourceWatcher.TYPES.ROOT_NODE + resource.resourceType === + this.toolbox.resourceWatcher.TYPES.ROOT_NODE && + // It might happen that the ROOT_NODE resource (which is a Front) is already + // destroyed, and in such case we want to ignore it. + !resource.isDestroyed() ) { const rootNodeFront = resource; const isTopLevelTarget = !!resource.targetFront.isTopLevel; diff --git a/devtools/client/inspector/markup/markup.js b/devtools/client/inspector/markup/markup.js index 1e117d26f01b..be3e0877979a 100644 --- a/devtools/client/inspector/markup/markup.js +++ b/devtools/client/inspector/markup/markup.js @@ -1442,8 +1442,11 @@ MarkupView.prototype = { _onResourceAvailable: async function(resources) { for (const resource of resources) { - if (resource.resourceType !== this.resourceWatcher.TYPES.ROOT_NODE) { - // Only handle root-node resources + if ( + resource.resourceType !== this.resourceWatcher.TYPES.ROOT_NODE || + resource.isDestroyed() + ) { + // Only handle alive root-node resources continue; } diff --git a/devtools/client/inspector/shared/highlighters-overlay.js b/devtools/client/inspector/shared/highlighters-overlay.js index 161bfd4da063..9aa50b3ceaad 100644 --- a/devtools/client/inspector/shared/highlighters-overlay.js +++ b/devtools/client/inspector/shared/highlighters-overlay.js @@ -1741,7 +1741,12 @@ class HighlightersOverlay { */ async _onResourceAvailable(resources) { for (const resource of resources) { - if (resource.resourceType !== this.resourceWatcher.TYPES.ROOT_NODE) { + if ( + resource.resourceType !== this.resourceWatcher.TYPES.ROOT_NODE || + // It might happen that the ROOT_NODE resource (which is a Front) is already + // destroyed, and in such case we want to ignore it. + resource.isDestroyed() + ) { // Only handle root-node resources. // Note that we could replace this with DOCUMENT_EVENT resources, since // the actual root-node resource is not used here.