From ae79f0a30309c2386fbb6e192813c3a1b1588419 Mon Sep 17 00:00:00 2001 From: Jonathan Kingston Date: Thu, 7 Sep 2017 10:12:25 -0700 Subject: [PATCH] Ignore non permissible urls when hiding as we can't open them which causes issues. Fixes #793 --- webextension/js/background/backgroundLogic.js | 14 ++++++++++++-- webextension/js/background/identityState.js | 3 +++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/webextension/js/background/backgroundLogic.js b/webextension/js/background/backgroundLogic.js index c044eb5..f55c5c7 100644 --- a/webextension/js/background/backgroundLogic.js +++ b/webextension/js/background/backgroundLogic.js @@ -63,8 +63,7 @@ const backgroundLogic = { url = undefined; } - // We can't open these we just have to throw them away - if (new URL(url).protocol === "about:") { + if (!this.isPermissibleURL(url)) { return; } @@ -76,6 +75,17 @@ const backgroundLogic = { }); }, + isPermissibleURL(url) { + const protocol = new URL(url).protocol; + // We can't open these we just have to throw them away + if (protocol === "about:" + || protocol === "chrome:" + || protocol === "moz-extension:") { + return false; + } + return true; + }, + checkArgs(requiredArguments, options, methodName) { requiredArguments.forEach((argument) => { if (!(argument in options)) { diff --git a/webextension/js/background/identityState.js b/webextension/js/background/identityState.js index a563d90..fbb0020 100644 --- a/webextension/js/background/identityState.js +++ b/webextension/js/background/identityState.js @@ -41,6 +41,9 @@ const identityState = { const tabsByContainer = await browser.tabs.query({cookieStoreId, windowId}); tabsByContainer.forEach((tab) => { const tabObject = this._createTabObject(tab); + if (!backgroundLogic.isPermissibleURL(tab.url)) { + return; + } // This tab is going to be closed. Let's mark this tabObject as // non-active. tabObject.active = false;