diff --git a/devtools/server/actors/reflow.js b/devtools/server/actors/reflow.js index 94ee7e395a27..8b53e39f2d3f 100644 --- a/devtools/server/actors/reflow.js +++ b/devtools/server/actors/reflow.js @@ -144,8 +144,8 @@ Observable.prototype = { } this.isObserving = false; - if (this.targetActor.attached && this.targetActor.docShell) { - // It's only worth stopping if the targetActor is still attached + if (!this.targetActor.isDestroyed() && this.targetActor.docShell) { + // It's only worth stopping if the targetActor is still active this._stopListeners(this.targetActor.windows); } }, diff --git a/devtools/server/actors/targets/parent-process.js b/devtools/server/actors/targets/parent-process.js index d26f0eddb523..d6fa8ed10d3b 100644 --- a/devtools/server/actors/targets/parent-process.js +++ b/devtools/server/actors/targets/parent-process.js @@ -124,7 +124,7 @@ Object.defineProperty(parentProcessTargetPrototype, "docShells", { parentProcessTargetPrototype.observe = function(subject, topic, data) { WindowGlobalTargetActor.prototype.observe.call(this, subject, topic, data); - if (!this.attached) { + if (this.isDestroyed()) { return; } @@ -138,7 +138,7 @@ parentProcessTargetPrototype.observe = function(subject, topic, data) { }; parentProcessTargetPrototype._detach = function() { - if (!this.attached) { + if (this.isDestroyed()) { return false; } diff --git a/devtools/server/actors/targets/webextension.js b/devtools/server/actors/targets/webextension.js index a51ddc3b5629..71316bfc8ec1 100644 --- a/devtools/server/actors/targets/webextension.js +++ b/devtools/server/actors/targets/webextension.js @@ -234,8 +234,8 @@ webExtensionTargetPrototype._onDocShellDestroy = function(docShell) { this._notifyDocShellDestroy(webProgress); // If the destroyed docShell was the current docShell and the actor is - // currently attached, switch to the fallback window - if (this.attached && docShell == this.docShell) { + // not destroyed, switch to the fallback window + if (!this.isDestroyed() && docShell == this.docShell) { this._changeTopLevelDocument(this._searchForExtensionWindow()); } }; diff --git a/devtools/server/actors/targets/window-global.js b/devtools/server/actors/targets/window-global.js index d3d42a8e5cad..2f2f511958b7 100644 --- a/devtools/server/actors/targets/window-global.js +++ b/devtools/server/actors/targets/window-global.js @@ -338,8 +338,6 @@ const windowGlobalTargetPrototype = { // (This is also probably meant to disappear once EFT is the only supported codepath) this._docShellsObserved = false; DevToolsUtils.executeSoon(() => this._watchDocshells()); - - this._attached = true; }, // Optional console API listener options (e.g. used by the WebExtensionActor to @@ -352,10 +350,6 @@ const windowGlobalTargetPrototype = { return true; }, - get attached() { - return !!this._attached; - }, - /* * Return a Debugger instance or create one if there is none yet */ @@ -663,10 +657,8 @@ const windowGlobalTargetPrototype = { } // Tell the thread actor that the window global is closed, so that it may terminate // instead of resuming the debuggee script. - if (this._attached) { - // TODO: Bug 997119: Remove this coupling with thread actor - this.threadActor._parentClosed = true; - } + // TODO: Bug 997119: Remove this coupling with thread actor + this.threadActor._parentClosed = true; if (this._touchSimulator) { this._touchSimulator.stop(); @@ -806,12 +798,6 @@ const windowGlobalTargetPrototype = { }, listWorkers(request) { - if (!this.attached) { - throw { - error: "wrongState", - }; - } - return this.ensureWorkerDescriptorActorList() .getList() .then(actors => { @@ -882,7 +868,7 @@ const windowGlobalTargetPrototype = { observe(subject, topic, data) { // Ignore any event that comes before/after the actor is attached. // That typically happens during Firefox shutdown. - if (!this.attached) { + if (this.isDestroyed()) { return; } @@ -1090,7 +1076,7 @@ const windowGlobalTargetPrototype = { * @returns false if the actor wasn't attached or true of detaching succeeds. */ _detach({ isTargetSwitching } = {}) { - if (!this.attached) { + if (this.isDestroyed()) { return false; } @@ -1133,8 +1119,6 @@ const windowGlobalTargetPrototype = { this._dbg = null; } - this._attached = false; - // When the target actor acts as a WindowGlobalTarget, the actor will be destroyed // without having to send an RDP event. The parent process will receive a window-global-destroyed // and report the target actor as destroyed via the Watcher actor. @@ -1428,9 +1412,9 @@ const windowGlobalTargetPrototype = { this._setWindow(window); DevToolsUtils.executeSoon(() => { - // No need to do anything more if the actor is not attached anymore + // No need to do anything more if the actor is destroyed. // e.g. the client has been closed and the actors destroyed in the meantime. - if (!this.attached) { + if (this.isDestroyed()) { return; } @@ -1822,7 +1806,7 @@ DebuggerProgressListener.prototype = { }, onWindowCreated: DevToolsUtils.makeInfallible(function(evt) { - if (!this._targetActor.attached) { + if (this._targetActor.isDestroyed()) { return; } @@ -1860,7 +1844,7 @@ DebuggerProgressListener.prototype = { }, "DebuggerProgressListener.prototype.onWindowCreated"), onWindowHidden: DevToolsUtils.makeInfallible(function(evt) { - if (!this._targetActor.attached) { + if (this._targetActor.isDestroyed()) { return; } @@ -1890,7 +1874,7 @@ DebuggerProgressListener.prototype = { }, "DebuggerProgressListener.prototype.onWindowHidden"), observe: DevToolsUtils.makeInfallible(function(subject, topic) { - if (!this._targetActor.attached) { + if (this._targetActor.isDestroyed()) { return; } @@ -1927,7 +1911,7 @@ DebuggerProgressListener.prototype = { flag, status ) { - if (!this._targetActor.attached) { + if (this._targetActor.isDestroyed()) { return; } progress.QueryInterface(Ci.nsIDocShell);