Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Commit

Permalink
Fix issue that would cause loading tabs not to close
Browse files Browse the repository at this point in the history
  • Loading branch information
pfrazee committed Mar 17, 2019
1 parent d433154 commit 69f7d5a
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions app/background-process/ui/view-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -1148,11 +1148,18 @@ function addToNoRedirects (url) {
}

async function fireBeforeUnloadEvent (wc) {
return wc.executeJavaScript(`
(function () {
let unloadEvent = new Event('beforeunload', {bubbles: false, cancelable: true})
unloadEvent.returnValue = false
return window.dispatchEvent(unloadEvent)
})()
`)
try {
if (wc.isWaitingForResponse()) {
return // dont bother
}
return await wc.executeJavaScript(`
(function () {
let unloadEvent = new Event('beforeunload', {bubbles: false, cancelable: true})
unloadEvent.returnValue = false
return window.dispatchEvent(unloadEvent)
})()
`)
} catch (e) {
// ignore
}
}

0 comments on commit 69f7d5a

Please sign in to comment.