browser(firefox): fix closing browser contexts with beforeunload (#4314)

References #4021
This commit is contained in:
Andrey Lushnikov 2020-11-02 17:29:54 -08:00 committed by GitHub
parent 3d3ce135f5
commit e3b12b0a0d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View file

@ -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

View file

@ -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, () => {