Skip to content

Commit

Permalink
Close correct assignment window on confirmation page. Fixes #606
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanKingston committed Jun 22, 2017
1 parent 6292d9b commit 83e8340
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions webextension/js/confirm-page.js
Expand Up @@ -56,8 +56,15 @@ function confirmSubmit(redirectUrl, cookieStoreId) {
openInContainer(redirectUrl, cookieStoreId);
}

function getCurrentTab() {
return browser.tabs.query({
active: true,
windowId: browser.windows.WINDOW_ID_CURRENT
});
}

async function denySubmit(redirectUrl) {
const tab = await browser.tabs.query({active: true});
const tab = await getCurrentTab();
await browser.runtime.sendMessage({
method: "exemptContainerAssignment",
tabId: tab[0].id,
Expand All @@ -73,12 +80,12 @@ async function denySubmit(redirectUrl) {
load();

async function openInContainer(redirectUrl, cookieStoreId) {
const tabs = await browser.tabs.query({active: true});
const tab = await getCurrentTab();
await browser.tabs.create({
cookieStoreId,
url: redirectUrl
});
if (tabs.length > 0) {
browser.tabs.remove(tabs[0].id);
if (tab.length > 0) {
browser.tabs.remove(tab[0].id);
}
}

0 comments on commit 83e8340

Please sign in to comment.