From 58525f05f2548ece5c066f56b178df5a23786b97 Mon Sep 17 00:00:00 2001 From: FranklinDM Date: Thu, 22 Feb 2024 09:25:02 +0800 Subject: [PATCH] No issue - Replacing location might throw NS_ERROR_UNEXPECTED while the developer tools window is being destroyed --- devtools/client/framework/toolbox.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/devtools/client/framework/toolbox.js b/devtools/client/framework/toolbox.js index 9b9fa66330..fae3602622 100644 --- a/devtools/client/framework/toolbox.js +++ b/devtools/client/framework/toolbox.js @@ -2182,14 +2182,16 @@ Toolbox.prototype = { .then(() => { this._removeHostListeners(); - // `location` may already be null if the toolbox document is already - // in process of destruction. Otherwise if it is still around, ensure - // releasing toolbox document and triggering cleanup thanks to unload - // event. We do that precisely here, before nullifying the target as - // various cleanup code depends on the target attribute to be still - // defined. - if (win.location) { + // `location` may already be invalid if the toolbox document is + // already in process of destruction. Otherwise if it is still + // around, ensure releasing toolbox document and triggering cleanup + // thanks to unload event. We do that precisely here, before + // nullifying the target as various cleanup code depends on the + // target attribute to be still defined. + try { win.location.replace("about:blank"); + } catch (e) { + // Do nothing. } // Targets need to be notified that the toolbox is being torn down.