Handle dismissal of extension prompt

- When user dismissed the window without choosing any option, it will now gracefully handle it.
- This has only been tested on Chromium.
- Closes #6
This commit is contained in:
SondreB
2022-07-25 13:43:25 +02:00
committed by fiatjaf
parent 1a4038a625
commit 43f4ee2785

View File

@@ -30,6 +30,12 @@ browser.runtime.onMessageExternal.addListener(
} }
) )
browser.windows.onRemoved.addListener((windowId) => {
if (openPrompt) {
handlePromptMessage({ condition: 'no' }, null);
}
})
async function handleContentScriptMessage({type, params, host}) { async function handleContentScriptMessage({type, params, host}) {
let level = await readPermissionLevel(host) let level = await readPermissionLevel(host)
@@ -108,7 +114,10 @@ function handlePromptMessage({id, condition, host, level}, sender) {
openPrompt = null openPrompt = null
releasePromptMutex() releasePromptMutex()
browser.windows.remove(sender.tab.windowId)
if (sender) {
browser.windows.remove(sender.tab.windowId)
}
} }
async function promptPermission(host, level, params) { async function promptPermission(host, level, params) {