diff --git a/data/frame.js b/data/frame.js index e3dea49..64c2c9a 100644 --- a/data/frame.js +++ b/data/frame.js @@ -26,6 +26,18 @@ return {type: [], mode: "allow"}; } } + function checkStack(stack){ + if (enabled){ + var status = sendSyncMessage( + "canvasBlocker-checkStack", + stack + ); + return status[0]; + } + else { + return true; + } + } function askWrapper(data){ return ask(data, { _: function(token){ @@ -56,7 +68,7 @@ var window = ev.target.defaultView; intercept( {subject: window}, - {check, ask: askWrapper, notify, prefs} + {check, checkStack, ask: askWrapper, notify, prefs} ); } } diff --git a/lib/check.js b/lib/check.js index e63ce1d..3f9157f 100644 --- a/lib/check.js +++ b/lib/check.js @@ -13,8 +13,7 @@ const {URL} = require("sdk/url"); exports.check = function check({url, errorStack}){ - var callingStack = parseErrorStack(errorStack); - var match = checkBoth(callingStack, url, prefs.blockMode).match(/^(block|allow|fake|ask)(|Readout|Everything|Context|Input)$/); + var match = checkBoth(errorStack, url, prefs.blockMode).match(/^(block|allow|fake|ask)(|Readout|Everything|Context|Input|Internal)$/); if (match){ return { type: (match[2] === "Everything" || match[2] === "")? @@ -32,8 +31,8 @@ }; - function checkBoth(stack, url, blockMode){ - if (prefs.enableStackList && checkStack(stack)){ + function checkBoth(errorStack, url, blockMode){ + if (prefs.enableStackList && errorStack && checkStack(errorStack)){ return "allow"; } else { @@ -42,15 +41,15 @@ } function checkURL(url, blockMode){ - url = new URL(url); + url = new URL(url || "about:blank"); switch (url.protocol){ case "about:": if (url.href === "about:blank"){ break; } - return "allow"; + return "allowInternal"; case "chrome:": - return "allow"; + return "allowInternal"; } var mode = "block"; @@ -93,7 +92,9 @@ return mode; } - function checkStack(stack){ - return lists.get("stack").match(stack); + function checkStack(errorStack){ + var callingStack = parseErrorStack(errorStack); + return lists.get("stack").match(callingStack); } + exports.checkStack = checkStack; }()); \ No newline at end of file diff --git a/lib/main.js b/lib/main.js index 0380951..af46504 100644 --- a/lib/main.js +++ b/lib/main.js @@ -8,7 +8,7 @@ const {when: unload} = require("sdk/system/unload"); - const {check} = require("./check.js"); + const {check, checkStack} = require("./check.js"); const {notify} = require("./notifications"); const _ = require("sdk/l10n").get; @@ -53,6 +53,9 @@ var status = check(ev.data); return status; }); + addMessageListener("canvasBlocker-checkStack", function(ev){ + return checkStack(ev.data); + }); addMessageListener("canvasBlocker-notify", function(ev){ var browser = ev.target;