No issue - Replacing location might throw NS_ERROR_UNEXPECTED while the developer tools window is being destroyed

This commit is contained in:
FranklinDM 2024-02-22 09:25:02 +08:00 • committed by roytam1
commit 58525f05f2

View file

@ -2182,14 +2182,16 @@ Toolbox.prototype = {
.then(() => { .then(() => {
this._removeHostListeners(); this._removeHostListeners();
// `location` may already be null if the toolbox document is already // `location` may already be invalid if the toolbox document is
// in process of destruction. Otherwise if it is still around, ensure // already in process of destruction. Otherwise if it is still
// releasing toolbox document and triggering cleanup thanks to unload // around, ensure releasing toolbox document and triggering cleanup
// event. We do that precisely here, before nullifying the target as // thanks to unload event. We do that precisely here, before
// various cleanup code depends on the target attribute to be still // nullifying the target as various cleanup code depends on the
// defined. // target attribute to be still defined.
if (win.location) { try {
win.location.replace("about:blank"); win.location.replace("about:blank");
} catch (e) {
// Do nothing.
} }
// Targets need to be notified that the toolbox is being torn down. // Targets need to be notified that the toolbox is being torn down.