From 47ab6f9ade82f05a3d5df3c0abce133f66e80538 Mon Sep 17 00:00:00 2001 From: Alexandre Poirot Date: Wed, 12 May 2021 15:08:04 +0000 Subject: [PATCH] Bug 1686748 - [devtools] Fix WalkerActor exception on server side target switching. r=nchevobbe When using JSWindowActor based target, each target actor is destroyed on each reload/navigation. This code in walker actor is registering a DOMContentLoaded listener which only fires after the target is already destroyed. This leads to exceptions. Differential Revision: https://phabricator.services.mozilla.com/D114367 --- devtools/server/actors/inspector/walker.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/devtools/server/actors/inspector/walker.js b/devtools/server/actors/inspector/walker.js index b651ed76eb2d..e430e92d6ed2 100644 --- a/devtools/server/actors/inspector/walker.js +++ b/devtools/server/actors/inspector/walker.js @@ -2472,6 +2472,10 @@ var WalkerActor = protocol.ActorClassWithSpec(walkerSpec, { }, onFrameLoad: function({ window, isTopLevel }) { + // By the time we receive the DOMContentLoaded event, we might have been destroyed + if (this._destroyed) { + return; + } const { readyState } = window.document; if (readyState != "interactive" && readyState != "complete") { // The document is not loaded, so we want to register to fire again when the