diff --git a/lib/intercept.js b/lib/intercept.js index 26268d9..1d6f792 100644 --- a/lib/intercept.js +++ b/lib/intercept.js @@ -21,8 +21,22 @@ } } exports.setRandomSupplyByType = setRandomSupplyByType; + + function getURL(window){ + if (window.location.href === "about:blank"){ + if (window !== window.parent){ + return getURL(window.parent); + } + else if (window.opener){ + return getURL(window.opener); + } + } + return window.location.href; + } + exports.intercept = function intercept({subject: window}, {check, checkStack, ask, notify, prefs}){ - var siteStatus = check({url: window.location.href}); + + var siteStatus = check({url: getURL(window)}); if (siteStatus.mode !== "allow"){ apiNames.forEach(function(name){ var changedFunction = changedFunctions[name]; @@ -37,7 +51,8 @@ enumerable: true, configureable: false, get: function(){ - if (!window.location.href){ + var url = getURL(window); + if (!url){ return undef; } var error = new Error(); @@ -56,7 +71,7 @@ case "fake": setRandomSupplyByType(prefs("rng")); var fake = changedFunction.fakeGenerator(prefs, function(messageId){ - notify({url: window.location.href, errorStack: error.stack, messageId}); + notify({url, errorStack: error.stack, messageId}); }, original); switch (fake){ case true: diff --git a/lib/randomSupplies.js b/lib/randomSupplies.js index 0058885..c7ba96c 100644 --- a/lib/randomSupplies.js +++ b/lib/randomSupplies.js @@ -5,10 +5,21 @@ (function(){ "use strict"; + function getDomain(window){ + if (window.location.href === "about:blank"){ + if (window !== window.parent){ + return getDomain(window.parent); + } + else if (window.opener){ + return getDomain(window.opener); + } + } + return window.location.host; + } const persistentRnd = Object.create(null); exports.persistent = { getRng: function(length, window){ - var domain = window.document.location.host; + var domain = getDomain(window); if (!persistentRnd[domain]){ // create the (sub-)domains random numbers if not existing persistentRnd[domain] = new Uint8Array(128); diff --git a/releaseNotes.txt b/releaseNotes.txt index f8044cc..d3410c7 100644 --- a/releaseNotes.txt +++ b/releaseNotes.txt @@ -10,6 +10,7 @@ Version 0.3.6: - faking webGL - added readPixels for webGL2 - removed error message when notification can not be closed + - about:blank pages are treated with respect to the opening page Version 0.3.5 new features: