From e3b12b0a0d079cf7d31b6c7f6dd39ac66f84b6a1 Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Mon, 2 Nov 2020 17:29:54 -0800 Subject: [PATCH] browser(firefox): fix closing browser contexts with beforeunload (#4314) References #4021 --- browser_patches/firefox/BUILD_NUMBER | 4 ++-- browser_patches/firefox/juggler/TargetRegistry.js | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/browser_patches/firefox/BUILD_NUMBER b/browser_patches/firefox/BUILD_NUMBER index cb074bfc0d..26ae34194f 100644 --- a/browser_patches/firefox/BUILD_NUMBER +++ b/browser_patches/firefox/BUILD_NUMBER @@ -1,2 +1,2 @@ -1199 -Changed: lushnikov@chromium.org Mon 02 Nov 2020 04:10:47 PM PST +1200 +Changed: lushnikov@chromium.org Mon 02 Nov 2020 05:18:01 PM PST diff --git a/browser_patches/firefox/juggler/TargetRegistry.js b/browser_patches/firefox/juggler/TargetRegistry.js index c4893382e5..46d1f4a5c2 100644 --- a/browser_patches/firefox/juggler/TargetRegistry.js +++ b/browser_patches/firefox/juggler/TargetRegistry.js @@ -417,8 +417,8 @@ class PageTarget { await this.updateViewportSize(); } - async close(runBeforeUnload = false) { - await this._gBrowser.removeTab(this._tab, { + close(runBeforeUnload = false) { + this._gBrowser.removeTab(this._tab, { skipPermitUnload: !runBeforeUnload, }); } @@ -562,7 +562,8 @@ class BrowserContext { async destroy() { if (this.userContextId !== 0) { ContextualIdentityService.remove(this.userContextId); - ContextualIdentityService.closeContainerTabs(this.userContextId); + for (const page of this.pages) + page.close(); if (this.pages.size) { await new Promise(f => { const listener = helper.on(this._registry, TargetRegistry.Events.TargetDestroyed, () => {