Close correct assignment window on confirmation page. Fixes #606

This commit is contained in:
Jonathan Kingston 2017-06-22 13:45:31 +01:00
parent 6292d9b25d
commit 83e8340a70

View file

@ -56,8 +56,15 @@ function confirmSubmit(redirectUrl, cookieStoreId) {
openInContainer(redirectUrl, cookieStoreId); openInContainer(redirectUrl, cookieStoreId);
} }
function getCurrentTab() {
return browser.tabs.query({
active: true,
windowId: browser.windows.WINDOW_ID_CURRENT
});
}
async function denySubmit(redirectUrl) { async function denySubmit(redirectUrl) {
const tab = await browser.tabs.query({active: true}); const tab = await getCurrentTab();
await browser.runtime.sendMessage({ await browser.runtime.sendMessage({
method: "exemptContainerAssignment", method: "exemptContainerAssignment",
tabId: tab[0].id, tabId: tab[0].id,
@ -73,12 +80,12 @@ async function denySubmit(redirectUrl) {
load(); load();
async function openInContainer(redirectUrl, cookieStoreId) { async function openInContainer(redirectUrl, cookieStoreId) {
const tabs = await browser.tabs.query({active: true}); const tab = await getCurrentTab();
await browser.tabs.create({ await browser.tabs.create({
cookieStoreId, cookieStoreId,
url: redirectUrl url: redirectUrl
}); });
if (tabs.length > 0) { if (tab.length > 0) {
browser.tabs.remove(tabs[0].id); browser.tabs.remove(tab[0].id);
} }
} }