Ask mode did not show canvas canvas any more.

This commit is contained in:
kkapsner 2018-09-21 16:42:58 +02:00
parent 95605ef746
commit 2f4fca10ab
4 changed files with 14 additions and 12 deletions

View File

@ -222,6 +222,7 @@
}
var funcStatus = changedFunction.getStatus(this, siteStatus, prefs);
const This = this;
function notifyCallback(messageId){
notify({
url,
@ -230,7 +231,7 @@
timestamp: new Date(),
functionName: name,
api: changedFunction.api,
dataURL: getDataURL(this, prefs)
dataURL: getDataURL(This, prefs)
});
}
const protectedAPIFeatures = prefs("protectedAPIFeatures");

View File

@ -214,7 +214,7 @@
if (canvasSizeShouldBeFaked(this, prefs)){
var fakeCanvas = getFakeCanvas(window, this, prefs);
if (fakeCanvas !== this){
notify.call(this, "fakedReadout");
notify("fakedReadout");
}
return original.apply(fakeCanvas, window.Array.from(args));
}
@ -244,7 +244,7 @@
if (canvasSizeShouldBeFaked(this, prefs)){
var fakeCanvas = getFakeCanvas(window, this, prefs);
if (fakeCanvas !== this){
notify.call(this, "fakedReadout");
notify("fakedReadout");
}
return original.apply(fakeCanvas, window.Array.from(args));
}
@ -275,7 +275,7 @@
if (canvasSizeShouldBeFaked(this, prefs)){
var fakeCanvas = getFakeCanvas(window, this, prefs);
if (fakeCanvas !== this){
notify.call(this, "fakedReadout");
notify("fakedReadout");
}
return original.apply(fakeCanvas, window.Array.from(args));
}
@ -305,7 +305,7 @@
fakeCanvas = getFakeCanvas(window, this.canvas, prefs);
}
if (fakeCanvas && fakeCanvas !== this.canvas){
notify.call(this, "fakedReadout");
notify("fakedReadout");
context = window.HTMLCanvasElement.prototype.getContext.call(
fakeCanvas,
"2d"
@ -335,7 +335,7 @@
var rng = randomSupply.getValueRng(1, window);
var originalValue = original.apply(this, window.Array.from(args));
if ((typeof originalValue) === "boolean"){
notify.call(this, "fakedReadout");
notify("fakedReadout");
var index = x + this.width * y;
return original.call(this, rng(x, index), rng(y, index));
}
@ -361,7 +361,7 @@
var rng = randomSupply.getValueRng(1, window);
var originalValue = original.apply(this, window.Array.from(args));
if ((typeof originalValue) === "boolean"){
notify.call(this, "fakedReadout");
notify("fakedReadout");
var index = x + this.width * y;
return original.call(this, rng(x, index), rng(y, index));
}
@ -385,7 +385,7 @@
return checkerWrapper(checker, this, arguments, function(args, check){
var {prefs, notify, window, original} = check;
if (!this || canvasSizeShouldBeFaked(this.canvas, prefs)){
notify.call(this, "fakedInput");
notify("fakedInput");
var oldImageData;
try {
// "this" is not trustable - it may be not a context
@ -420,7 +420,7 @@
return checkerWrapper(checker, this, arguments, function(args, check){
var {prefs, notify, window, original} = check;
if (!this || canvasSizeShouldBeFaked(this.canvas, prefs)){
notify.call(this, "fakedInput");
notify("fakedInput");
var oldImageData;
try {
// "this" is not trustable - it may be not a context
@ -455,7 +455,7 @@
return checkerWrapper(checker, this, arguments, function(args, check){
var {prefs, notify, window, original} = check;
if (!this || canvasSizeShouldBeFaked(this.canvas, prefs)){
notify.call(this, "fakedReadout");
notify("fakedReadout");
var fakeCanvas = getFakeCanvas(window, this.canvas, prefs);
var {context} = copyCanvasToWebgl(
window,

View File

@ -20,14 +20,14 @@
};
scope.checkerWrapper = function checkerWrapper(checker, object, args, callback){
const check = checker();
const check = checker.call(object);
if (check.allow){
if (check.allow === true){
return check.original.apply(object, check.window.Array.from(args));
}
return callback.call(object, args, check);
}
check.notify.call(object, "blocked");
check.notify("blocked");
return undefined;
};
}());

View File

@ -18,6 +18,7 @@ Version 0.5.4:
- window and audio API were always blocked when using any of the "block ..." modes
- canvas content was not stored to be displayed when wanted
- hovering over toolbar icon created error in the browser console
- canvas content was not shown in ask mode any more
known issues:
- if a data URL is blocked the page action button does not appear