1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-12-22 21:00:23 +01:00

about:blank pages are treated with respect to the opening page

This commit is contained in:
kkapsner 2017-01-31 20:00:02 +01:00
parent b563a9d3ca
commit ec1ae73cda
3 changed files with 31 additions and 4 deletions

View File

@ -21,8 +21,22 @@
} }
} }
exports.setRandomSupplyByType = setRandomSupplyByType; 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}){ 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"){ if (siteStatus.mode !== "allow"){
apiNames.forEach(function(name){ apiNames.forEach(function(name){
var changedFunction = changedFunctions[name]; var changedFunction = changedFunctions[name];
@ -37,7 +51,8 @@
enumerable: true, enumerable: true,
configureable: false, configureable: false,
get: function(){ get: function(){
if (!window.location.href){ var url = getURL(window);
if (!url){
return undef; return undef;
} }
var error = new Error(); var error = new Error();
@ -56,7 +71,7 @@
case "fake": case "fake":
setRandomSupplyByType(prefs("rng")); setRandomSupplyByType(prefs("rng"));
var fake = changedFunction.fakeGenerator(prefs, function(messageId){ var fake = changedFunction.fakeGenerator(prefs, function(messageId){
notify({url: window.location.href, errorStack: error.stack, messageId}); notify({url, errorStack: error.stack, messageId});
}, original); }, original);
switch (fake){ switch (fake){
case true: case true:

View File

@ -5,10 +5,21 @@
(function(){ (function(){
"use strict"; "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); const persistentRnd = Object.create(null);
exports.persistent = { exports.persistent = {
getRng: function(length, window){ getRng: function(length, window){
var domain = window.document.location.host; var domain = getDomain(window);
if (!persistentRnd[domain]){ if (!persistentRnd[domain]){
// create the (sub-)domains random numbers if not existing // create the (sub-)domains random numbers if not existing
persistentRnd[domain] = new Uint8Array(128); persistentRnd[domain] = new Uint8Array(128);

View File

@ -10,6 +10,7 @@ Version 0.3.6:
- faking webGL - faking webGL
- added readPixels for webGL2 - added readPixels for webGL2
- removed error message when notification can not be closed - removed error message when notification can not be closed
- about:blank pages are treated with respect to the opening page
Version 0.3.5 Version 0.3.5
new features: new features: