Bug 1697747 - [devtools] Ignore already destroyed root node resources in onResourceAvailable callback. r=jdescottes.

It looks like this reduces the number of failures in browser_toolbox_backward_forward_navigation.js.

Differential Revision: https://phabricator.services.mozilla.com/D107980
This commit is contained in:
Nicolas Chevobbe 2021-03-18 16:53:55 +00:00
Родитель 55e5804632
Коммит 8469f542e0
3 изменённых файлов: 16 добавлений и 4 удалений

Просмотреть файл

@ -1302,7 +1302,11 @@ Inspector.prototype = {
onResourceAvailable: function(resources) { onResourceAvailable: function(resources) {
for (const resource of resources) { for (const resource of resources) {
if ( 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 rootNodeFront = resource;
const isTopLevelTarget = !!resource.targetFront.isTopLevel; const isTopLevelTarget = !!resource.targetFront.isTopLevel;

Просмотреть файл

@ -1442,8 +1442,11 @@ MarkupView.prototype = {
_onResourceAvailable: async function(resources) { _onResourceAvailable: async function(resources) {
for (const resource of resources) { for (const resource of resources) {
if (resource.resourceType !== this.resourceWatcher.TYPES.ROOT_NODE) { if (
// Only handle root-node resources resource.resourceType !== this.resourceWatcher.TYPES.ROOT_NODE ||
resource.isDestroyed()
) {
// Only handle alive root-node resources
continue; continue;
} }

Просмотреть файл

@ -1741,7 +1741,12 @@ class HighlightersOverlay {
*/ */
async _onResourceAvailable(resources) { async _onResourceAvailable(resources) {
for (const resource of 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. // Only handle root-node resources.
// Note that we could replace this with DOCUMENT_EVENT resources, since // Note that we could replace this with DOCUMENT_EVENT resources, since
// the actual root-node resource is not used here. // the actual root-node resource is not used here.