1
0
Fork 0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2025-07-03 12:06:31 +02:00

Added protection for history.length

As requested by #231.
This commit is contained in:
kkapsner 2018-08-27 00:30:48 +02:00
parent 4c7b83aca6
commit fd7c4fabbd
12 changed files with 161 additions and 19 deletions

View file

@ -96,22 +96,28 @@ addTest("function length", function(log){
addTest("function code", function(log){
"use strict";
var codeDetected = false;
if (
!CanvasRenderingContext2D.prototype.getImageData.toString().match(
/^\s*function getImageData\s*\(\)\s*\{\s*\[native code\]\s*\}\s*$/
)
){
log("unexpected function code:", CanvasRenderingContext2D.prototype.getImageData.toString());
codeDetected = true;
}
if (
!HTMLCanvasElement.prototype.toDataURL.toString().match(
/^\s*function toDataURL\s*\(\)\s*\{\s*\[native code\]\s*\}\s*$/
)
){
log("unexpected function code:", HTMLCanvasElement.prototype.toDataURL.toString());
codeDetected = true;
function checkFunctionCode(func, expectedName){
log("checking", expectedName);
if (!func.toString().match(
new RegExp("^\\s*function " + expectedName + "\\s*\\(\\)\\s*\\{\\s*\\[native code\\]\\s*\\}\\s*$")
)){
log("unexpected function code:", func.toString());
return true;
}
return false;
}
codeDetected = checkFunctionCode(
CanvasRenderingContext2D.prototype.getImageData,
"getImageData"
) || codeDetected;
codeDetected = checkFunctionCode(
HTMLCanvasElement.prototype.toDataURL,
"toDataURL"
) || codeDetected;
codeDetected = checkFunctionCode(
history.__lookupGetter__("length"),
"get length"
) || codeDetected;
return codeDetected;
});
addTest("toString modified", function(log){