mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-22 21:00:23 +01:00
Code linting.
This commit is contained in:
parent
cde71f8a62
commit
ef38abe545
@ -11,15 +11,25 @@
|
|||||||
},
|
},
|
||||||
"sourceType": "script"
|
"sourceType": "script"
|
||||||
},
|
},
|
||||||
|
"extends": "eslint:recommended",
|
||||||
|
"globals": {
|
||||||
|
"exportFunction": false,
|
||||||
|
"settings": false
|
||||||
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
|
"brace-style": ["warn", "stroustrup", {"allowSingleLine": true}],
|
||||||
|
"eqeqeq": "warn",
|
||||||
"no-const-assign": "warn",
|
"no-const-assign": "warn",
|
||||||
"no-this-before-super": "warn",
|
"no-this-before-super": "warn",
|
||||||
"no-undef": "warn",
|
"no-undef": "warn",
|
||||||
"no-unreachable": "warn",
|
"no-unreachable": "warn",
|
||||||
"no-unused-vars": "warn",
|
"no-unused-vars": "off",
|
||||||
|
"no-trailing-spaces": ["warn", {"skipBlankLines": true}],
|
||||||
|
"no-mixed-spaces-and-tabs": ["warn", "smart-tabs"],
|
||||||
"constructor-super": "warn",
|
"constructor-super": "warn",
|
||||||
"valid-typeof": "warn",
|
"valid-typeof": "warn",
|
||||||
"brace-style": "warn",
|
"quotes": ["error", "double"],
|
||||||
|
"semi": ["error", "always"],
|
||||||
"strict": ["warn", "function"]
|
"strict": ["warn", "function"]
|
||||||
}
|
}
|
||||||
}
|
}
|
28
.vscode/tasks.json
vendored
Normal file
28
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||||
|
// for the documentation about the tasks.json format
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"taskName": "eslint",
|
||||||
|
"type": "shell",
|
||||||
|
"windows": {
|
||||||
|
"command": "eslint"
|
||||||
|
},
|
||||||
|
"linux": {
|
||||||
|
"command": "eslint"
|
||||||
|
},
|
||||||
|
"osx": {
|
||||||
|
"command": "eslint"
|
||||||
|
},
|
||||||
|
"args": ["./"],
|
||||||
|
"presentation": {
|
||||||
|
"echo": true,
|
||||||
|
"reveal": "silent",
|
||||||
|
"focus": false,
|
||||||
|
"panel": "shared"
|
||||||
|
},
|
||||||
|
"problemMatcher": "$eslint-stylish"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -1,4 +1,3 @@
|
|||||||
/* jslint moz: true */
|
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
@ -25,7 +24,9 @@
|
|||||||
try {
|
try {
|
||||||
nodeName = context.nodeName;
|
nodeName = context.nodeName;
|
||||||
}
|
}
|
||||||
catch (e){}
|
catch (e){
|
||||||
|
nodeName = "";
|
||||||
|
}
|
||||||
if (nodeName === "CANVAS"){
|
if (nodeName === "CANVAS"){
|
||||||
canvas = context;
|
canvas = context;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
/* global exports */
|
|
||||||
/* jslint moz: true */
|
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
@ -21,7 +19,6 @@
|
|||||||
// Translation
|
// Translation
|
||||||
var translate = require("sdk/l10n").get;
|
var translate = require("sdk/l10n").get;
|
||||||
var _ = function(name, replace, translateAPI){
|
var _ = function(name, replace, translateAPI){
|
||||||
"use strict";
|
|
||||||
if (!translateAPI){
|
if (!translateAPI){
|
||||||
translateAPI = translate;
|
translateAPI = translate;
|
||||||
}
|
}
|
||||||
@ -38,8 +35,6 @@
|
|||||||
|
|
||||||
// Stack parsing
|
// Stack parsing
|
||||||
function parseStackEntry(entry){
|
function parseStackEntry(entry){
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var m = /@(.*):(\d*):(\d*)$/.exec(entry) || ["", entry, "--", "--"];
|
var m = /@(.*):(\d*):(\d*)$/.exec(entry) || ["", entry, "--", "--"];
|
||||||
return {
|
return {
|
||||||
url: m[1],
|
url: m[1],
|
||||||
@ -67,8 +62,6 @@
|
|||||||
|
|
||||||
// parse calling stack
|
// parse calling stack
|
||||||
function parseErrorStack(errorStack){
|
function parseErrorStack(errorStack){
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var callers = errorStack.trim().split("\n");
|
var callers = errorStack.trim().split("\n");
|
||||||
var findme = callers.shift(); // Remove us from the stack
|
var findme = callers.shift(); // Remove us from the stack
|
||||||
findme = findme.replace(/(:[0-9]+){1,2}$/, ""); // rm line & column
|
findme = findme.replace(/(:[0-9]+){1,2}$/, ""); // rm line & column
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
/* global console,exports */
|
|
||||||
/* jslint moz: true */
|
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
@ -19,7 +17,6 @@
|
|||||||
const preferences = require("sdk/simple-prefs");
|
const preferences = require("sdk/simple-prefs");
|
||||||
const prefs = preferences.prefs;
|
const prefs = preferences.prefs;
|
||||||
const {parseErrorStack} = require("./callingStack");
|
const {parseErrorStack} = require("./callingStack");
|
||||||
const {URL} = require("sdk/url");
|
|
||||||
const logging = require("./logging");
|
const logging = require("./logging");
|
||||||
|
|
||||||
scope.check = function check({url, errorStack}){
|
scope.check = function check({url, errorStack}){
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
/* jslint moz: true */
|
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
@ -37,24 +36,24 @@
|
|||||||
color.count += 1;
|
color.count += 1;
|
||||||
if (color.count > color.nextColor.count){
|
if (color.count > color.nextColor.count){
|
||||||
// swap colors to remain in right order
|
// swap colors to remain in right order
|
||||||
// a -> b -> c -> d becomes a -> c -> b -> d
|
// a_ -> b_ -> c -> d becomes a_ -> c -> b_ -> d
|
||||||
var a = color.previousColor;
|
var a_ = color.previousColor;
|
||||||
var b = color;
|
var b_ = color;
|
||||||
var c = color.nextColor;
|
var c = color.nextColor;
|
||||||
var d = color.nextColor.nextColor;
|
var d = color.nextColor.nextColor;
|
||||||
|
|
||||||
a.nextColor = c;
|
a_.nextColor = c;
|
||||||
c.previousColor = a;
|
c.previousColor = a_;
|
||||||
|
|
||||||
c.nextColor = b;
|
c.nextColor = b_;
|
||||||
b.previousColor = c;
|
b_.previousColor = c;
|
||||||
|
|
||||||
b.nextColor = d;
|
b_.nextColor = d;
|
||||||
d.previousColor = b;
|
d.previousColor = b_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getMaxColors(n){
|
getMaxColors(n){
|
||||||
var n = Math.min(n, this.numberOfColors);
|
n = Math.min(n, this.numberOfColors);
|
||||||
var colors = Object.create(null);
|
var colors = Object.create(null);
|
||||||
var current = this.maxBoundary;
|
var current = this.maxBoundary;
|
||||||
for (;n && current;n -= 1){
|
for (;n && current;n -= 1){
|
||||||
@ -76,5 +75,5 @@
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
return statistic;
|
return statistic;
|
||||||
}
|
};
|
||||||
}());
|
}());
|
@ -1,6 +1,4 @@
|
|||||||
"use strict";
|
const settings = {
|
||||||
|
|
||||||
var settings = {
|
|
||||||
logLevel: 1,
|
logLevel: 1,
|
||||||
whiteList: "",
|
whiteList: "",
|
||||||
blackList: "",
|
blackList: "",
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
/* jslint moz: true */
|
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
@ -136,7 +135,7 @@
|
|||||||
|
|
||||||
interceptedWindows.set(window, true);
|
interceptedWindows.set(window, true);
|
||||||
return true;
|
return true;
|
||||||
};
|
}
|
||||||
|
|
||||||
if (settings.isStillDefault){
|
if (settings.isStillDefault){
|
||||||
message("load settings");
|
message("load settings");
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
/* jslint moz: true */
|
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
@ -98,7 +97,7 @@
|
|||||||
errorStack: error.stack,
|
errorStack: error.stack,
|
||||||
messageId, timestamp: new Date(),
|
messageId, timestamp: new Date(),
|
||||||
functionName: name,
|
functionName: name,
|
||||||
dataURL:
|
dataURL:
|
||||||
prefs("storeImageForInspection") &&
|
prefs("storeImageForInspection") &&
|
||||||
prefs("showNotifications")
|
prefs("showNotifications")
|
||||||
?
|
?
|
||||||
|
12
lib/lists.js
12
lib/lists.js
@ -1,4 +1,3 @@
|
|||||||
/* jslint moz: true */
|
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
@ -21,8 +20,6 @@
|
|||||||
|
|
||||||
|
|
||||||
function getDomainRegExpList(domainList){
|
function getDomainRegExpList(domainList){
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var list = domainList
|
var list = domainList
|
||||||
.split(",")
|
.split(",")
|
||||||
.map(function(entry){
|
.map(function(entry){
|
||||||
@ -35,7 +32,7 @@
|
|||||||
var regExp;
|
var regExp;
|
||||||
var domain = !!entry.match(/^[\w.]+$/);
|
var domain = !!entry.match(/^[\w.]+$/);
|
||||||
if (domain){
|
if (domain){
|
||||||
regExp = new RegExp("(?:^|\\.)" + entry.replace(/([\\\+\*\?\[\^\]\$\(\)\{\}\=\!\|\.])/g, "\\$1") + "\\.?$", "i");
|
regExp = new RegExp("(?:^|\\.)" + entry.replace(/([\\+*?[^\]$(){}=!|.])/g, "\\$1") + "\\.?$", "i");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
regExp = new RegExp(entry, "i");
|
regExp = new RegExp(entry, "i");
|
||||||
@ -68,15 +65,12 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
function updateList(type, value){
|
function updateList(type, value){
|
||||||
"use strict";
|
|
||||||
if (typeof value === "undefined"){
|
if (typeof value === "undefined"){
|
||||||
value = prefs[type + "List"];
|
value = prefs[type + "List"];
|
||||||
}
|
}
|
||||||
lists[type] = getDomainRegExpList(value);
|
lists[type] = getDomainRegExpList(value);
|
||||||
}
|
}
|
||||||
Object.keys(lists).forEach(function(type){
|
Object.keys(lists).forEach(function(type){
|
||||||
"use strict";
|
|
||||||
|
|
||||||
preferences.on(type + "List", function(value){
|
preferences.on(type + "List", function(value){
|
||||||
updateList(type, value);
|
updateList(type, value);
|
||||||
});
|
});
|
||||||
@ -111,13 +105,9 @@
|
|||||||
updateStackList(prefs.stackList);
|
updateStackList(prefs.stackList);
|
||||||
|
|
||||||
scope.get = function getList(type){
|
scope.get = function getList(type){
|
||||||
"use strict";
|
|
||||||
|
|
||||||
return lists[type];
|
return lists[type];
|
||||||
};
|
};
|
||||||
scope.appendTo = function appendToList(type, entry){
|
scope.appendTo = function appendToList(type, entry){
|
||||||
"use strict";
|
|
||||||
|
|
||||||
prefs[type + "List"] += (prefs[type + "List"]? ",": "") + entry;
|
prefs[type + "List"] += (prefs[type + "List"]? ",": "") + entry;
|
||||||
var obj = {};
|
var obj = {};
|
||||||
obj[type + "List"] = prefs[type + "List"];
|
obj[type + "List"] = prefs[type + "List"];
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* jslint moz: true */
|
/* eslint no-console: off */
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
@ -45,9 +45,9 @@
|
|||||||
leftPad(date.getDate(), "0", 2) + " " +
|
leftPad(date.getDate(), "0", 2) + " " +
|
||||||
leftPad(date.getHours(), "0", 2) + ":" +
|
leftPad(date.getHours(), "0", 2) + ":" +
|
||||||
leftPad(date.getMinutes(), "0", 2) + ":" +
|
leftPad(date.getMinutes(), "0", 2) + ":" +
|
||||||
leftPad(date.getSeconds(), "0", 2) + "." +
|
leftPad(date.getSeconds(), "0", 2) + "." +
|
||||||
leftPad(date.getMilliseconds(), "0", 3) +
|
leftPad(date.getMilliseconds(), "0", 3) +
|
||||||
"]"
|
"]";
|
||||||
if (typeof args[0] === "string"){
|
if (typeof args[0] === "string"){
|
||||||
args[0] = pre + " " + args[0];
|
args[0] = pre + " " + args[0];
|
||||||
}
|
}
|
||||||
|
11
lib/main.js
11
lib/main.js
@ -1,4 +1,3 @@
|
|||||||
/* jslint moz: true */
|
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
@ -32,13 +31,17 @@
|
|||||||
if (
|
if (
|
||||||
Array.isArray(value) &&
|
Array.isArray(value) &&
|
||||||
value.length === 128 &&
|
value.length === 128 &&
|
||||||
value.every(function(value){return typeof value === "number" && value >= 0 && value < 256;})
|
value.every(function(value){
|
||||||
|
return typeof value === "number" && value >= 0 && value < 256;
|
||||||
|
})
|
||||||
){
|
){
|
||||||
persistentRnd[domain] = value;
|
persistentRnd[domain] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(e){}
|
catch(e){
|
||||||
|
// JSON is not valid -> ignore it
|
||||||
|
}
|
||||||
|
|
||||||
function updateContentScripts(){
|
function updateContentScripts(){
|
||||||
message("update content scripts");
|
message("update content scripts");
|
||||||
@ -101,7 +104,7 @@
|
|||||||
){
|
){
|
||||||
browser.pageAction.show(port.sender.tab.id);
|
browser.pageAction.show(port.sender.tab.id);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
verbose("got data", data, "from port", port);
|
verbose("got data", data, "from port", port);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
/* jslint moz: true */
|
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
@ -18,8 +17,6 @@
|
|||||||
const logging = require("./logging");
|
const logging = require("./logging");
|
||||||
const {copyCanvasToWebgl} = require("./webgl");
|
const {copyCanvasToWebgl} = require("./webgl");
|
||||||
|
|
||||||
// let Cu = require("chrome").Cu;
|
|
||||||
|
|
||||||
var randomSupply = null;
|
var randomSupply = null;
|
||||||
|
|
||||||
function getContext(window, canvas){
|
function getContext(window, canvas){
|
||||||
@ -82,9 +79,9 @@
|
|||||||
var fakeAlphaChannel = prefs("fakeAlphaChannel");
|
var fakeAlphaChannel = prefs("fakeAlphaChannel");
|
||||||
for (var i = 0; i < l; i += 4){
|
for (var i = 0; i < l; i += 4){
|
||||||
var [r, g, b, a] = rng(
|
var [r, g, b, a] = rng(
|
||||||
source[i + 0],
|
source[i + 0],
|
||||||
source[i + 1],
|
source[i + 1],
|
||||||
source[i + 2],
|
source[i + 2],
|
||||||
source[i + 3],
|
source[i + 3],
|
||||||
i / 4
|
i / 4
|
||||||
);
|
);
|
||||||
@ -134,7 +131,7 @@
|
|||||||
return size > minSize & size <= maxSize;
|
return size > minSize & size <= maxSize;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return true
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,7 +153,7 @@
|
|||||||
mode: "allow",
|
mode: "allow",
|
||||||
type: status.type,
|
type: status.type,
|
||||||
active: false
|
active: false
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
else if (hasType(status, "context") || hasType(status, "input")){
|
else if (hasType(status, "context") || hasType(status, "input")){
|
||||||
return {
|
return {
|
||||||
@ -166,7 +163,7 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var status = Object.create(status);
|
status = Object.create(status);
|
||||||
status.active = false;
|
status.active = false;
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@ -182,7 +179,7 @@
|
|||||||
toDataURL: {
|
toDataURL: {
|
||||||
type: "readout",
|
type: "readout",
|
||||||
getStatus: function(obj, status){
|
getStatus: function(obj, status){
|
||||||
var status = Object.create(status);
|
status = Object.create(status);
|
||||||
if (hasType(status, "input")){
|
if (hasType(status, "input")){
|
||||||
var contextType = canvasContextType.get(obj);
|
var contextType = canvasContextType.get(obj);
|
||||||
status.active = contextType !== "2d";
|
status.active = contextType !== "2d";
|
||||||
@ -208,7 +205,7 @@
|
|||||||
toBlob: {
|
toBlob: {
|
||||||
type: "readout",
|
type: "readout",
|
||||||
getStatus: function(obj, status){
|
getStatus: function(obj, status){
|
||||||
var status = Object.create(status);
|
status = Object.create(status);
|
||||||
if (hasType(status, "input")){
|
if (hasType(status, "input")){
|
||||||
var contextType = canvasContextType.get(obj);
|
var contextType = canvasContextType.get(obj);
|
||||||
status.active = contextType !== "2d";
|
status.active = contextType !== "2d";
|
||||||
@ -235,7 +232,7 @@
|
|||||||
mozGetAsFile: {
|
mozGetAsFile: {
|
||||||
type: "readout",
|
type: "readout",
|
||||||
getStatus: function(obj, status){
|
getStatus: function(obj, status){
|
||||||
var status = Object.create(status);
|
status = Object.create(status);
|
||||||
if (hasType(status, "input")){
|
if (hasType(status, "input")){
|
||||||
var contextType = canvasContextType.get(obj);
|
var contextType = canvasContextType.get(obj);
|
||||||
status.active = contextType !== "2d";
|
status.active = contextType !== "2d";
|
||||||
@ -261,7 +258,7 @@
|
|||||||
getImageData: {
|
getImageData: {
|
||||||
type: "readout",
|
type: "readout",
|
||||||
getStatus: function(obj, status){
|
getStatus: function(obj, status){
|
||||||
var status = Object.create(status);
|
status = Object.create(status);
|
||||||
if (hasType(status, "input")){
|
if (hasType(status, "input")){
|
||||||
var contextType = canvasContextType.get(obj && obj.canvas);
|
var contextType = canvasContextType.get(obj && obj.canvas);
|
||||||
status.active = contextType !== "2d";
|
status.active = contextType !== "2d";
|
||||||
@ -298,7 +295,7 @@
|
|||||||
fillText: {
|
fillText: {
|
||||||
type: "input",
|
type: "input",
|
||||||
getStatus: function(obj, status){
|
getStatus: function(obj, status){
|
||||||
var status = Object.create(status);
|
status = Object.create(status);
|
||||||
status.active = hasType(status, "input");
|
status.active = hasType(status, "input");
|
||||||
return status;
|
return status;
|
||||||
},
|
},
|
||||||
@ -312,7 +309,9 @@
|
|||||||
// "this" is not trustable - it may be not a context
|
// "this" is not trustable - it may be not a context
|
||||||
oldImageData = getImageData(window, this).imageData;
|
oldImageData = getImageData(window, this).imageData;
|
||||||
}
|
}
|
||||||
catch (e){}
|
catch (e){
|
||||||
|
// nothing to do here
|
||||||
|
}
|
||||||
// if "this" is not a correct context the next line will throw an error
|
// if "this" is not a correct context the next line will throw an error
|
||||||
var ret = original.apply(this, window.Array.from(arguments));
|
var ret = original.apply(this, window.Array.from(arguments));
|
||||||
var newImageData = getImageData(window, this).imageData;
|
var newImageData = getImageData(window, this).imageData;
|
||||||
@ -328,7 +327,7 @@
|
|||||||
strokeText: {
|
strokeText: {
|
||||||
type: "input",
|
type: "input",
|
||||||
getStatus: function(obj, status){
|
getStatus: function(obj, status){
|
||||||
var status = Object.create(status);
|
status = Object.create(status);
|
||||||
status.active = hasType(status, "input");
|
status.active = hasType(status, "input");
|
||||||
return status;
|
return status;
|
||||||
},
|
},
|
||||||
@ -342,7 +341,9 @@
|
|||||||
// "this" is not trustable - it may be not a context
|
// "this" is not trustable - it may be not a context
|
||||||
oldImageData = getImageData(window, this).imageData;
|
oldImageData = getImageData(window, this).imageData;
|
||||||
}
|
}
|
||||||
catch (e){}
|
catch (e){
|
||||||
|
// nothing to do here
|
||||||
|
}
|
||||||
// if "this" is not a correct context the next line will throw an error
|
// if "this" is not a correct context the next line will throw an error
|
||||||
var ret = original.apply(this, window.Array.from(arguments));
|
var ret = original.apply(this, window.Array.from(arguments));
|
||||||
var newImageData = getImageData(window, this).imageData;
|
var newImageData = getImageData(window, this).imageData;
|
||||||
@ -358,7 +359,7 @@
|
|||||||
readPixels: {
|
readPixels: {
|
||||||
type: "readout",
|
type: "readout",
|
||||||
getStatus: function(obj, status){
|
getStatus: function(obj, status){
|
||||||
var status = Object.create(status);
|
status = Object.create(status);
|
||||||
status.active = hasType(status, "readout") || hasType(status, "input");
|
status.active = hasType(status, "readout") || hasType(status, "input");
|
||||||
return status;
|
return status;
|
||||||
},
|
},
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
/* jslint moz: true, bitwise: true */
|
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
@ -48,7 +47,7 @@
|
|||||||
browser.runtime.sendMessage({"canvasBlocker-new-domain-rnd": {domain, rnd: Array.from(persistentRnd[domain])}});
|
browser.runtime.sendMessage({"canvasBlocker-new-domain-rnd": {domain, rnd: Array.from(persistentRnd[domain])}});
|
||||||
}
|
}
|
||||||
return persistentRnd[domain];
|
return persistentRnd[domain];
|
||||||
}
|
};
|
||||||
}());
|
}());
|
||||||
scope.persistent = {
|
scope.persistent = {
|
||||||
name: "persistent",
|
name: "persistent",
|
||||||
@ -88,7 +87,7 @@
|
|||||||
rng(b, baseIndex + 2),
|
rng(b, baseIndex + 2),
|
||||||
rng(a, baseIndex + 3)
|
rng(a, baseIndex + 3)
|
||||||
];
|
];
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -160,7 +159,7 @@
|
|||||||
rng(b, baseIndex + 2),
|
rng(b, baseIndex + 2),
|
||||||
rng(a, baseIndex + 3)
|
rng(a, baseIndex + 3)
|
||||||
];
|
];
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}());
|
}());
|
@ -1,5 +1,11 @@
|
|||||||
|
/* global settings exportFunction */
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
window.scope = {};
|
window.scope = {};
|
||||||
function require(module){
|
function require(module){
|
||||||
|
"use strict";
|
||||||
if (module.startsWith("./")){
|
if (module.startsWith("./")){
|
||||||
var scopeName = module.substr(2).replace(/\..+/, "");
|
var scopeName = module.substr(2).replace(/\..+/, "");
|
||||||
return window.scope[scopeName];
|
return window.scope[scopeName];
|
||||||
@ -21,22 +27,21 @@ function require(module){
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
else if (module === "sdk/l10n"){
|
else if (module === "sdk/l10n"){
|
||||||
return {
|
return {
|
||||||
get: function(key){
|
get: function(key){
|
||||||
return browser.i18n.getMessage(key);
|
return browser.i18n.getMessage(key);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
else if (module === "sdk/url"){
|
else if (module === "sdk/url"){
|
||||||
return {
|
return {
|
||||||
URL
|
URL
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
console.error("Not able to get non relative modules!", module);
|
throw new ReferenceError("Unable to get non relative module " + module + "!");
|
||||||
return undefined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
window.scope.require = require;
|
window.scope.require = require;
|
@ -1,4 +1,3 @@
|
|||||||
/* jslint moz: true */
|
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
@ -44,8 +43,8 @@
|
|||||||
}
|
}
|
||||||
context.attachShader(program, shader);
|
context.attachShader(program, shader);
|
||||||
|
|
||||||
var shader = context.createShader(context.FRAGMENT_SHADER);
|
shader = context.createShader(context.FRAGMENT_SHADER);
|
||||||
var fragmenter = "precision mediump float;\nuniform sampler2D u_image;\nvarying vec2 v_texCoord;\nvoid main(){\n\tgl_FragColor = texture2D(u_image, v_texCoord);\n}"
|
var fragmenter = "precision mediump float;\nuniform sampler2D u_image;\nvarying vec2 v_texCoord;\nvoid main(){\n\tgl_FragColor = texture2D(u_image, v_texCoord);\n}";
|
||||||
context.shaderSource(shader, fragmenter);
|
context.shaderSource(shader, fragmenter);
|
||||||
context.compileShader(shader);
|
context.compileShader(shader);
|
||||||
success = context.getShaderParameter(shader, context.COMPILE_STATUS);
|
success = context.getShaderParameter(shader, context.COMPILE_STATUS);
|
||||||
@ -112,9 +111,9 @@
|
|||||||
context.texImage2D(context.TEXTURE_2D, 0, context.RGBA, context.RGBA, context.UNSIGNED_BYTE, canvas);
|
context.texImage2D(context.TEXTURE_2D, 0, context.RGBA, context.RGBA, context.UNSIGNED_BYTE, canvas);
|
||||||
|
|
||||||
var primitiveType = context.TRIANGLES;
|
var primitiveType = context.TRIANGLES;
|
||||||
var offset = 0;
|
var triangleOffset = 0;
|
||||||
var count = 6;
|
var count = 6;
|
||||||
context.drawArrays(primitiveType, offset, count);
|
context.drawArrays(primitiveType, triangleOffset, count);
|
||||||
|
|
||||||
return {webGlCanvas, context};
|
return {webGlCanvas, context};
|
||||||
};
|
};
|
||||||
|
@ -1,348 +1,357 @@
|
|||||||
var table = document.createElement("table");
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
table.className = "settings";
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
document.body.appendChild(table);
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
(function(){
|
||||||
|
"use strict";
|
||||||
|
|
||||||
[
|
const logging = require("./logging");
|
||||||
{
|
|
||||||
"name": "displayAdvancedSettings",
|
var table = document.createElement("table");
|
||||||
"title": "Display advanced settings",
|
table.className = "settings";
|
||||||
"type": "bool",
|
document.body.appendChild(table);
|
||||||
"value": false
|
|
||||||
},
|
[
|
||||||
{
|
{
|
||||||
"name": "blockMode",
|
"name": "displayAdvancedSettings",
|
||||||
"title": "block mode",
|
"title": "Display advanced settings",
|
||||||
"type": "menulist",
|
"type": "bool",
|
||||||
"value": "fakeReadout",
|
"value": false
|
||||||
"options": [
|
},
|
||||||
{
|
{
|
||||||
"value": "blockReadout",
|
"name": "blockMode",
|
||||||
"label": "block readout API"
|
"title": "block mode",
|
||||||
},
|
"type": "menulist",
|
||||||
{
|
"value": "fakeReadout",
|
||||||
"value": "fakeReadout",
|
"options": [
|
||||||
"label": "fake readout API"
|
{
|
||||||
},
|
"value": "blockReadout",
|
||||||
{
|
"label": "block readout API"
|
||||||
"value": "fakeInput",
|
},
|
||||||
"label": "fake input API"
|
{
|
||||||
},
|
"value": "fakeReadout",
|
||||||
{
|
"label": "fake readout API"
|
||||||
"value": "askReadout",
|
},
|
||||||
"label": "ask for readout API permission"
|
{
|
||||||
},
|
"value": "fakeInput",
|
||||||
{
|
"label": "fake input API"
|
||||||
"value": "",
|
},
|
||||||
"label": ""
|
{
|
||||||
},
|
"value": "askReadout",
|
||||||
{
|
"label": "ask for readout API permission"
|
||||||
"value": "blockEverything",
|
},
|
||||||
"label": "block everything"
|
{
|
||||||
},
|
"value": "",
|
||||||
{
|
"label": ""
|
||||||
"value": "block",
|
},
|
||||||
"label": "allow only white list"
|
{
|
||||||
},
|
"value": "blockEverything",
|
||||||
{
|
"label": "block everything"
|
||||||
"value": "ask",
|
},
|
||||||
"label": "ask for permission"
|
{
|
||||||
},
|
"value": "block",
|
||||||
{
|
"label": "allow only white list"
|
||||||
"value": "allow",
|
},
|
||||||
"label": "block only black list"
|
{
|
||||||
},
|
"value": "ask",
|
||||||
{
|
"label": "ask for permission"
|
||||||
"value": "allowEverything",
|
},
|
||||||
"label": "allow everything"
|
{
|
||||||
|
"value": "allow",
|
||||||
|
"label": "block only black list"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "allowEverything",
|
||||||
|
"label": "allow everything"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "whiteList",
|
||||||
|
"title": "White list",
|
||||||
|
"type": "string",
|
||||||
|
"value": "",
|
||||||
|
"displayDependencies": {
|
||||||
|
"blockMode": ["blockReadout", "fakeReadout", "fakeInput", "askReadout", "block", "ask"]
|
||||||
}
|
}
|
||||||
]
|
},
|
||||||
},
|
{
|
||||||
{
|
"name": "blackList",
|
||||||
"name": "whiteList",
|
"title": "Black list",
|
||||||
"title": "White list",
|
"type": "string",
|
||||||
"type": "string",
|
"value": "",
|
||||||
"value": "",
|
"displayDependencies": {
|
||||||
"displayDependencies": {
|
"blockMode": ["blockReadout", "fakeReadout", "fakeInput", "askReadout", "ask", "allow"]
|
||||||
"blockMode": ["blockReadout", "fakeReadout", "fakeInput", "askReadout", "block", "ask"]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "blackList",
|
|
||||||
"title": "Black list",
|
|
||||||
"type": "string",
|
|
||||||
"value": "",
|
|
||||||
"displayDependencies": {
|
|
||||||
"blockMode": ["blockReadout", "fakeReadout", "fakeInput", "askReadout", "ask", "allow"]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "minFakeSize",
|
|
||||||
"title": "Minimal fake size",
|
|
||||||
"type": "integer",
|
|
||||||
"value": 1,
|
|
||||||
"displayDependencies": {
|
|
||||||
"blockMode": ["fakeReadout", "fakeInput"],
|
|
||||||
"displayAdvancedSettings": [true]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "maxFakeSize",
|
|
||||||
"title": "Maximal fake size",
|
|
||||||
"type": "integer",
|
|
||||||
"value": 0,
|
|
||||||
"displayDependencies": {
|
|
||||||
"blockMode": ["fakeReadout", "fakeInput"],
|
|
||||||
"displayAdvancedSettings": [true]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "rng",
|
|
||||||
"title": "Random number generator",
|
|
||||||
"type": "menulist",
|
|
||||||
"value": "nonPersistent",
|
|
||||||
"options": [
|
|
||||||
{
|
|
||||||
"value": "nonPersistent",
|
|
||||||
"label": "non persistent"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"value": "constant",
|
|
||||||
"label": "constant"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"value": "persistent",
|
|
||||||
"label": "persistent"
|
|
||||||
}
|
}
|
||||||
],
|
},
|
||||||
"displayDependencies": {
|
{
|
||||||
"blockMode": ["fakeReadout", "fakeInput"],
|
"name": "minFakeSize",
|
||||||
"displayAdvancedSettings": [true]
|
"title": "Minimal fake size",
|
||||||
}
|
"type": "integer",
|
||||||
},
|
"value": 1,
|
||||||
{
|
"displayDependencies": {
|
||||||
"name": "storePersistentRnd",
|
"blockMode": ["fakeReadout", "fakeInput"],
|
||||||
"title": "Store persistent data",
|
"displayAdvancedSettings": [true]
|
||||||
"type": "bool",
|
}
|
||||||
"value": false,
|
},
|
||||||
"displayDependencies": {
|
{
|
||||||
"blockMode": ["fakeReadout", "fakeInput"],
|
"name": "maxFakeSize",
|
||||||
"rng": ["persistent"],
|
"title": "Maximal fake size",
|
||||||
"displayAdvancedSettings": [true]
|
"type": "integer",
|
||||||
}
|
"value": 0,
|
||||||
},
|
"displayDependencies": {
|
||||||
{
|
"blockMode": ["fakeReadout", "fakeInput"],
|
||||||
"name": "clearPersistentRnd",
|
"displayAdvancedSettings": [true]
|
||||||
"title": "Clear persistent random storage",
|
}
|
||||||
"type": "control",
|
},
|
||||||
"label": "Clear",
|
{
|
||||||
"displayDependencies": {
|
"name": "rng",
|
||||||
"blockMode": ["fakeReadout", "fakeInput"],
|
"title": "Random number generator",
|
||||||
"rng": ["persistent"],
|
"type": "menulist",
|
||||||
"displayAdvancedSettings": [true]
|
"value": "nonPersistent",
|
||||||
}
|
"options": [
|
||||||
},
|
{
|
||||||
{
|
"value": "nonPersistent",
|
||||||
"name": "ignoreFrequentColors",
|
"label": "non persistent"
|
||||||
"title": "Ignore most frequent colors",
|
},
|
||||||
"type": "integer",
|
{
|
||||||
"value": 0,
|
"value": "constant",
|
||||||
"displayDependencies": {
|
"label": "constant"
|
||||||
"blockMode": ["fakeReadout"],
|
},
|
||||||
"displayAdvancedSettings": [true]
|
{
|
||||||
}
|
"value": "persistent",
|
||||||
},
|
"label": "persistent"
|
||||||
{
|
}
|
||||||
"name": "fakeAlphaChannel",
|
],
|
||||||
"title": "Fake the alpha channel",
|
"displayDependencies": {
|
||||||
"type": "bool",
|
"blockMode": ["fakeReadout", "fakeInput"],
|
||||||
"value": false,
|
"displayAdvancedSettings": [true]
|
||||||
"displayDependencies": {
|
}
|
||||||
"blockMode": ["fakeReadout"],
|
},
|
||||||
"displayAdvancedSettings": [true]
|
{
|
||||||
}
|
"name": "storePersistentRnd",
|
||||||
},
|
"title": "Store persistent data",
|
||||||
{
|
"type": "bool",
|
||||||
"name": "useCanvasCache",
|
"value": false,
|
||||||
"title": "Use canvas cache",
|
"displayDependencies": {
|
||||||
"type": "bool",
|
"blockMode": ["fakeReadout", "fakeInput"],
|
||||||
"value": true,
|
"rng": ["persistent"],
|
||||||
"displayDependencies": {
|
"displayAdvancedSettings": [true]
|
||||||
"blockMode": ["fakeReadout"],
|
}
|
||||||
"displayAdvancedSettings": [true]
|
},
|
||||||
}
|
{
|
||||||
},
|
"name": "clearPersistentRnd",
|
||||||
{
|
"title": "Clear persistent random storage",
|
||||||
"name": "askOnlyOnce",
|
"type": "control",
|
||||||
"title": "Ask only once",
|
"label": "Clear",
|
||||||
"type": "bool",
|
"displayDependencies": {
|
||||||
"value": true,
|
"blockMode": ["fakeReadout", "fakeInput"],
|
||||||
"displayDependencies": {
|
"rng": ["persistent"],
|
||||||
"blockMode": ["askReadout", "ask"]
|
"displayAdvancedSettings": [true]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "showNotifications",
|
"name": "ignoreFrequentColors",
|
||||||
"title": "Show notifications",
|
"title": "Ignore most frequent colors",
|
||||||
"type": "bool",
|
"type": "integer",
|
||||||
"value": true,
|
"value": 0,
|
||||||
"displayDependencies": {
|
"displayDependencies": {
|
||||||
"blockMode": ["fakeReadout", "fakeInput"]
|
"blockMode": ["fakeReadout"],
|
||||||
}
|
"displayAdvancedSettings": [true]
|
||||||
},
|
}
|
||||||
{
|
},
|
||||||
"name": "storeImageForInspection",
|
{
|
||||||
"title": "Store image for inspection",
|
"name": "fakeAlphaChannel",
|
||||||
"type": "bool",
|
"title": "Fake the alpha channel",
|
||||||
"value": false,
|
"type": "bool",
|
||||||
"displayDependencies": {
|
"value": false,
|
||||||
"blockMode": ["fakeReadout", "fakeInput"],
|
"displayDependencies": {
|
||||||
"showNotifications": [true],
|
"blockMode": ["fakeReadout"],
|
||||||
"displayAdvancedSettings": [true]
|
"displayAdvancedSettings": [true]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// {
|
{
|
||||||
// "name": "notificationDisplayTime",
|
"name": "useCanvasCache",
|
||||||
// "title": "notification display time",
|
"title": "Use canvas cache",
|
||||||
// "type": "integer",
|
"type": "bool",
|
||||||
// "value": 30,
|
"value": true,
|
||||||
// "displayDependencies": {
|
"displayDependencies": {
|
||||||
// "blockMode": ["fakeReadout", "fakeInput"]
|
"blockMode": ["fakeReadout"],
|
||||||
// }
|
"displayAdvancedSettings": [true]
|
||||||
// },
|
}
|
||||||
{
|
},
|
||||||
"name": "ignoreList",
|
{
|
||||||
"title": "Ignore list",
|
"name": "askOnlyOnce",
|
||||||
"type": "string",
|
"title": "Ask only once",
|
||||||
"value": "",
|
"type": "bool",
|
||||||
"displayDependencies": {
|
"value": true,
|
||||||
"blockMode": ["fakeReadout", "fakeInput"],
|
"displayDependencies": {
|
||||||
"showNotifications": [true]
|
"blockMode": ["askReadout", "ask"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "showCallingFile",
|
"name": "showNotifications",
|
||||||
"title": "Display calling file",
|
"title": "Show notifications",
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"value": false,
|
"value": true,
|
||||||
"displayDependencies": {
|
"displayDependencies": {
|
||||||
"blockMode": ["askReadout", "ask"],
|
"blockMode": ["fakeReadout", "fakeInput"]
|
||||||
"displayAdvancedSettings": [true]
|
}
|
||||||
}
|
},
|
||||||
},
|
{
|
||||||
{
|
"name": "storeImageForInspection",
|
||||||
"name": "showCompleteCallingStack",
|
"title": "Store image for inspection",
|
||||||
"title": "Display complete calling stack",
|
"type": "bool",
|
||||||
"type": "bool",
|
"value": false,
|
||||||
"value": false,
|
"displayDependencies": {
|
||||||
"displayDependencies": [
|
|
||||||
{
|
|
||||||
"blockMode": ["fakeReadout", "fakeInput"],
|
"blockMode": ["fakeReadout", "fakeInput"],
|
||||||
"showNotifications": [true],
|
"showNotifications": [true],
|
||||||
"displayAdvancedSettings": [true]
|
"displayAdvancedSettings": [true]
|
||||||
},
|
}
|
||||||
{
|
},
|
||||||
|
// {
|
||||||
|
// "name": "notificationDisplayTime",
|
||||||
|
// "title": "notification display time",
|
||||||
|
// "type": "integer",
|
||||||
|
// "value": 30,
|
||||||
|
// "displayDependencies": {
|
||||||
|
// "blockMode": ["fakeReadout", "fakeInput"]
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
{
|
||||||
|
"name": "ignoreList",
|
||||||
|
"title": "Ignore list",
|
||||||
|
"type": "string",
|
||||||
|
"value": "",
|
||||||
|
"displayDependencies": {
|
||||||
|
"blockMode": ["fakeReadout", "fakeInput"],
|
||||||
|
"showNotifications": [true]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "showCallingFile",
|
||||||
|
"title": "Display calling file",
|
||||||
|
"type": "bool",
|
||||||
|
"value": false,
|
||||||
|
"displayDependencies": {
|
||||||
"blockMode": ["askReadout", "ask"],
|
"blockMode": ["askReadout", "ask"],
|
||||||
"displayAdvancedSettings": [true]
|
"displayAdvancedSettings": [true]
|
||||||
}
|
}
|
||||||
]
|
},
|
||||||
},{
|
{
|
||||||
"name": "enableStackList",
|
"name": "showCompleteCallingStack",
|
||||||
"title": "Use file specific scoped white list",
|
"title": "Display complete calling stack",
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"value": false,
|
"value": false,
|
||||||
"displayDependencies": {
|
"displayDependencies": [
|
||||||
"blockMode": ["blockReadout", "fakeReadout", "fakeInput", "askReadout", "block", "ask"],
|
{
|
||||||
"displayAdvancedSettings": [true]
|
"blockMode": ["fakeReadout", "fakeInput"],
|
||||||
}
|
"showNotifications": [true],
|
||||||
},
|
"displayAdvancedSettings": [true]
|
||||||
{
|
},
|
||||||
"name": "stackList",
|
{
|
||||||
"title": "File specific white list",
|
"blockMode": ["askReadout", "ask"],
|
||||||
"type": "string",
|
"displayAdvancedSettings": [true]
|
||||||
"value": "",
|
}
|
||||||
"displayDependencies": {
|
]
|
||||||
"enableStackList": [true],
|
},{
|
||||||
"displayAdvancedSettings": [true]
|
"name": "enableStackList",
|
||||||
}
|
"title": "Use file specific scoped white list",
|
||||||
|
"type": "bool",
|
||||||
},
|
"value": false,
|
||||||
{
|
"displayDependencies": {
|
||||||
"name": "showReleaseNotes",
|
"blockMode": ["blockReadout", "fakeReadout", "fakeInput", "askReadout", "block", "ask"],
|
||||||
"title": "Release notes",
|
"displayAdvancedSettings": [true]
|
||||||
"type": "control",
|
}
|
||||||
"label": "Show"
|
},
|
||||||
},
|
{
|
||||||
{
|
"name": "stackList",
|
||||||
"name": "logLevel",
|
"title": "File specific white list",
|
||||||
"title": "logging level",
|
"type": "string",
|
||||||
"type": "menulist",
|
"value": "",
|
||||||
"value": 1,
|
"displayDependencies": {
|
||||||
"options": [
|
"enableStackList": [true],
|
||||||
{
|
"displayAdvancedSettings": [true]
|
||||||
"value": 0,
|
}
|
||||||
"label": "none"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"value": 1,
|
"name": "showReleaseNotes",
|
||||||
"label": "error"
|
"title": "Release notes",
|
||||||
},
|
"type": "control",
|
||||||
{
|
"label": "Show"
|
||||||
"value": 25,
|
},
|
||||||
"label": "warning"
|
{
|
||||||
},
|
"name": "logLevel",
|
||||||
{
|
"title": "logging level",
|
||||||
"value": 50,
|
"type": "menulist",
|
||||||
"label": "message"
|
"value": 1,
|
||||||
},
|
"options": [
|
||||||
{
|
{
|
||||||
"value": 75,
|
"value": 0,
|
||||||
"label": "notice"
|
"label": "none"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"value": 100,
|
"value": 1,
|
||||||
"label": "verbose"
|
"label": "error"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": 25,
|
||||||
|
"label": "warning"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": 50,
|
||||||
|
"label": "message"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": 75,
|
||||||
|
"label": "notice"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": 100,
|
||||||
|
"label": "verbose"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"displayDependencies": {
|
||||||
|
"displayAdvancedSettings": [true]
|
||||||
}
|
}
|
||||||
],
|
|
||||||
"displayDependencies": {
|
|
||||||
"displayAdvancedSettings": [true]
|
|
||||||
}
|
}
|
||||||
}
|
].forEach(function(pref){
|
||||||
].forEach(function(pref){
|
var html = "<td><div class=\"content\"><span class=\"title\">__MSG_" + pref.name + "_title__</span><div class=\"description\">__MSG_" + pref.name + "_description__</div></div></td><td><div class=\"content\">";
|
||||||
var html = '<td><div class="content"><span class="title">__MSG_' + pref.name + '_title__</span><div class="description">__MSG_' + pref.name + '_description__</div></div></td><td><div class="content">';
|
var inputAttributes = " data-storage-name=\"" + pref.name + "\" data-storage-type=\"" + pref.type + "\" class=\"setting\"";
|
||||||
var inputAttributes = ' data-storage-name="' + pref.name + '" data-storage-type="' + pref.type + '" class="setting"'
|
switch (pref.type){
|
||||||
switch (pref.type){
|
case "integer":
|
||||||
case "integer":
|
html += "<input type=\"number\"" + inputAttributes + " value=\"" + pref.value + "\">";
|
||||||
html += '<input type="number"' + inputAttributes + ' value="' + pref.value + '">';
|
break;
|
||||||
break;
|
case "string":
|
||||||
case "string":
|
html += "<input type=\"text\"" + inputAttributes + " value=\"" + pref.value + "\">";
|
||||||
html += '<input type="text"' + inputAttributes + ' value="' + pref.value + '">';
|
break;
|
||||||
break;
|
case "bool":
|
||||||
case "bool":
|
html += "<input type=\"checkbox\" style=\"display: inline\"" + inputAttributes + (pref.value? " checked=\"checked\"": "") + ">";
|
||||||
html += '<input type="checkbox" style="display: inline"' + inputAttributes + (pref.value? ' checked="checked"': "") + '>';
|
break;
|
||||||
break;
|
case "menulist":
|
||||||
case "menulist":
|
html += "<select" + inputAttributes + "data-type=\"" + (typeof pref.value) + "\">" +
|
||||||
html += '<select' + inputAttributes + 'data-type="' + (typeof pref.value) + '">' +
|
pref.options.map(function(option){
|
||||||
pref.options.map(function(option){
|
if (option.value !== ""){
|
||||||
if (option.value !== ""){
|
return "<option value=\"" + option.value + "\"" + (option.value === pref.value? " selected": "") + ">__MSG_" + pref.name + "_options." + option.label + "__</option>";
|
||||||
return '<option value="' + option.value + '"' + (option.value === pref.value? " selected": "") + '>__MSG_' + pref.name + '_options.' + option.label + '__</option>';
|
}
|
||||||
}
|
else {
|
||||||
else {
|
return "<option disabled>----------------</option>";
|
||||||
return '<option disabled>----------------</option>';
|
}
|
||||||
}
|
}).join("") +
|
||||||
}).join("") +
|
"</select>";
|
||||||
'</select>';
|
break;
|
||||||
break;
|
case "control":
|
||||||
case "control":
|
html += "<button" + inputAttributes + "\">__MSG_" + pref.name + "_label__</button>";
|
||||||
html += '<button' + inputAttributes + '">__MSG_' + pref.name + '_label__</button>';
|
break;
|
||||||
break;
|
default:
|
||||||
default:
|
logging.warning("Unknown preference type: " + pref.type);
|
||||||
logging.warning("Unknown preference type: " + pref.type);
|
}
|
||||||
}
|
html += "</div></td>";
|
||||||
html += "</div></td>";
|
var tr = document.createElement("tr");
|
||||||
var tr = document.createElement("tr");
|
tr.setting = pref;
|
||||||
tr.setting = pref;
|
tr.className = "settingRow";
|
||||||
tr.className = "settingRow";
|
tr.innerHTML = html;
|
||||||
tr.innerHTML = html;
|
logging.verbose(html);
|
||||||
logging.verbose(html);
|
table.appendChild(tr);
|
||||||
table.appendChild(tr);
|
});
|
||||||
});
|
}());
|
@ -7,6 +7,7 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<script src="../lib/defaultSettings.js"></script>
|
<script src="../lib/defaultSettings.js"></script>
|
||||||
|
<script src="../lib/require.js"></script>
|
||||||
<script src="../lib/logging.js"></script>
|
<script src="../lib/logging.js"></script>
|
||||||
<script src="buildPrefInputs.js"></script>
|
<script src="buildPrefInputs.js"></script>
|
||||||
<script src="options.js"></script>
|
<script src="options.js"></script>
|
||||||
|
@ -1,130 +1,136 @@
|
|||||||
/* jslint moz: true */
|
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
browser.storage.local.get().then(function(data){
|
(function(){
|
||||||
Object.keys(data).forEach(function(key){
|
"use strict";
|
||||||
settings[key] = data[key];
|
|
||||||
});
|
const logging = require("./logging");
|
||||||
settings.isStillDefault = false;
|
|
||||||
logging.setPrefix("options page");
|
browser.storage.local.get().then(function(data){
|
||||||
logging.clearQueue();
|
Object.keys(data).forEach(function(key){
|
||||||
return settings;
|
settings[key] = data[key];
|
||||||
}).then(function(settings){
|
});
|
||||||
function traverse(node, func){
|
settings.isStillDefault = false;
|
||||||
func(node);
|
logging.setPrefix("options page");
|
||||||
Array.from(node.childNodes).forEach(function(child){traverse(child, func);});
|
logging.clearQueue();
|
||||||
}
|
return settings;
|
||||||
|
}).then(function(settings){
|
||||||
// getting the translation of all the messages
|
function traverse(node, func){
|
||||||
logging.message("transate all messages");
|
func(node);
|
||||||
traverse(document.body, function(node){
|
Array.from(node.childNodes).forEach(function(child){traverse(child, func);});
|
||||||
if (node.nodeType == 3){
|
}
|
||||||
var lines = node.nodeValue.replace(/\b__MSG_(.+)__\b/g, function(m, key){
|
|
||||||
try {
|
// getting the translation of all the messages
|
||||||
return browser.i18n.getMessage(key);
|
logging.message("transate all messages");
|
||||||
|
traverse(document.body, function(node){
|
||||||
|
if (node.nodeType === 3){
|
||||||
|
var lines = node.nodeValue.replace(/\b__MSG_(.+)__\b/g, function(m, key){
|
||||||
|
try {
|
||||||
|
return browser.i18n.getMessage(key);
|
||||||
|
}
|
||||||
|
catch (e){
|
||||||
|
return "Unknown i18n key: " + key;
|
||||||
|
}
|
||||||
|
}).split(/\n/g);
|
||||||
|
node.nodeValue = lines.shift();
|
||||||
|
lines.forEach(function(line){
|
||||||
|
node.parentNode.appendChild(document.createElement("br"));
|
||||||
|
node.parentNode.appendChild(document.createTextNode(line));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
logging.message("register events to store changes in local storage");
|
||||||
|
Array.from(document.querySelectorAll("input.setting, select.setting")).forEach(function(input){
|
||||||
|
var storageName = input.dataset.storageName;
|
||||||
|
if (input.type === "checkbox"){
|
||||||
|
input.checked = settings[storageName];
|
||||||
|
|
||||||
|
input.addEventListener("click", function(){
|
||||||
|
logging.message("changed setting", storageName, ":", this.checked);
|
||||||
|
var value = this.checked;
|
||||||
|
var obj = {};
|
||||||
|
obj[storageName] = value;
|
||||||
|
browser.storage.local.set(obj);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
input.value = settings[storageName];
|
||||||
|
|
||||||
|
input.addEventListener("change", function(){
|
||||||
|
var value = this.value;
|
||||||
|
if (this.type === "number" || this.dataset.type === "number"){
|
||||||
|
value = parseFloat(value);
|
||||||
|
}
|
||||||
|
logging.message("changed setting", storageName, ":", value);
|
||||||
|
var obj = {};
|
||||||
|
obj[storageName] = value;
|
||||||
|
browser.storage.local.set(obj);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var callbacks = {
|
||||||
|
showReleaseNotes: function(){
|
||||||
|
logging.verbose("open release notes");
|
||||||
|
window.open("../releaseNotes.txt", "_blank");
|
||||||
|
// would be nicer but is not supported in fennec
|
||||||
|
// browser.windows.create({
|
||||||
|
// url: "../releaseNotes.txt",
|
||||||
|
// type: "popup"
|
||||||
|
// });
|
||||||
|
},
|
||||||
|
clearPersistentRnd: function(){
|
||||||
|
logging.message("clear persistent rnd storage");
|
||||||
|
logging.notice("empty storage");
|
||||||
|
browser.storage.local.set({persistentRndStorage: ""});
|
||||||
|
logging.notice("send message to main script");
|
||||||
|
browser.runtime.sendMessage({"canvasBlocker-clear-domain-rnd": true});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Array.from(document.querySelectorAll("button.setting")).forEach(function(button){
|
||||||
|
var storageName = button.dataset.storageName;
|
||||||
|
button.addEventListener("click", function(){
|
||||||
|
if (callbacks[storageName]){
|
||||||
|
callbacks[storageName]();
|
||||||
}
|
}
|
||||||
catch (e){
|
});
|
||||||
return "Unknown i18n key: " + key;
|
});
|
||||||
|
|
||||||
|
function updateDisplay(){
|
||||||
|
logging.notice("update display");
|
||||||
|
document.querySelectorAll("tr.settingRow").forEach(function(row){
|
||||||
|
logging.verbose("evaluate display dependencies for", row.setting);
|
||||||
|
var displayDependencies = row.setting.displayDependencies;
|
||||||
|
if (displayDependencies){
|
||||||
|
row.classList[(
|
||||||
|
(Array.isArray(displayDependencies)? displayDependencies: [displayDependencies]).some(function(displayDependency){
|
||||||
|
return Object.keys(displayDependency).every(function(key){
|
||||||
|
return displayDependency[key].indexOf(settings[key]) !== -1;
|
||||||
|
});
|
||||||
|
})
|
||||||
|
)? "remove": "add"]("hidden");
|
||||||
}
|
}
|
||||||
}).split(/\n/g);
|
|
||||||
node.nodeValue = lines.shift();
|
|
||||||
lines.forEach(function(line){
|
|
||||||
node.parentNode.appendChild(document.createElement("br"));
|
|
||||||
node.parentNode.appendChild(document.createTextNode(line));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
updateDisplay();
|
||||||
|
|
||||||
logging.message("register events to store changes in local storage");
|
browser.storage.onChanged.addListener(function(change, area){
|
||||||
Array.from(document.querySelectorAll("input.setting, select.setting")).forEach(function(input){
|
if (area === "local"){
|
||||||
var storageName = input.dataset.storageName;
|
Object.keys(change).forEach(function(key){
|
||||||
if (input.type === "checkbox"){
|
settings[key] = change[key].newValue;
|
||||||
input.checked = settings[storageName];
|
var input = document.querySelector(".setting[data-storage-name=" + key + "]");
|
||||||
|
if (input){
|
||||||
input.addEventListener("click", function(){
|
if (input.type === "checkbox"){
|
||||||
logging.message("changed setting", storageName, ":", this.checked);
|
input.checked = change[key].newValue;
|
||||||
var value = this.checked;
|
}
|
||||||
var obj = {};
|
else {
|
||||||
obj[storageName] = value;
|
input.value = change[key].newValue;
|
||||||
browser.storage.local.set(obj);
|
}
|
||||||
});}
|
}
|
||||||
else {
|
});
|
||||||
input.value = settings[storageName];
|
updateDisplay();
|
||||||
|
|
||||||
input.addEventListener("change", function(){
|
|
||||||
var value = this.value;
|
|
||||||
if (this.type === "number" || this.dataset.type === "number"){
|
|
||||||
value = parseFloat(value);
|
|
||||||
}
|
|
||||||
logging.message("changed setting", storageName, ":", value);
|
|
||||||
var obj = {};
|
|
||||||
obj[storageName] = value;
|
|
||||||
browser.storage.local.set(obj);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var callbacks = {
|
|
||||||
showReleaseNotes: function(){
|
|
||||||
logging.verbose("open release notes");
|
|
||||||
window.open("../releaseNotes.txt", "_blank");
|
|
||||||
// would be nicer but is not supported in fennec
|
|
||||||
// browser.windows.create({
|
|
||||||
// url: "../releaseNotes.txt",
|
|
||||||
// type: "popup"
|
|
||||||
// });
|
|
||||||
},
|
|
||||||
clearPersistentRnd: function(){
|
|
||||||
logging.message("clear persistent rnd storage");
|
|
||||||
logging.notice("empty storage");
|
|
||||||
browser.storage.local.set({persistentRndStorage: ""});
|
|
||||||
logging.notice("send message to main script");
|
|
||||||
browser.runtime.sendMessage({"canvasBlocker-clear-domain-rnd": true});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Array.from(document.querySelectorAll("button.setting")).forEach(function(button){
|
|
||||||
var storageName = button.dataset.storageName;
|
|
||||||
button.addEventListener("click", function(){
|
|
||||||
if (callbacks[storageName]){
|
|
||||||
callbacks[storageName]();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}());
|
||||||
function updateDisplay(){
|
|
||||||
logging.notice("update display");
|
|
||||||
document.querySelectorAll("tr.settingRow").forEach(function(row){
|
|
||||||
logging.verbose("evaluate display dependencies for", row.setting);
|
|
||||||
var displayDependencies = row.setting.displayDependencies;
|
|
||||||
if (displayDependencies){
|
|
||||||
row.classList[(
|
|
||||||
(Array.isArray(displayDependencies)? displayDependencies: [displayDependencies]).some(function(displayDependency){
|
|
||||||
return Object.keys(displayDependency).every(function(key){
|
|
||||||
return displayDependency[key].indexOf(settings[key]) !== -1;
|
|
||||||
});
|
|
||||||
})
|
|
||||||
)? "remove": "add"]("hidden");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
updateDisplay();
|
|
||||||
|
|
||||||
browser.storage.onChanged.addListener(function(change, area){
|
|
||||||
if (area === "local"){
|
|
||||||
Object.keys(change).forEach(function(key){
|
|
||||||
settings[key] = change[key].newValue;
|
|
||||||
var input = document.querySelector(".setting[data-storage-name=" + key + "]");
|
|
||||||
if (input){
|
|
||||||
if (input.type === "checkbox"){
|
|
||||||
input.checked = change[key].newValue;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
input.value = change[key].newValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
updateDisplay();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,5 +1,7 @@
|
|||||||
|
/* eslint no-console: off */
|
||||||
var addTest = (function(){
|
var addTest = (function(){
|
||||||
|
"use strict";
|
||||||
|
|
||||||
var stati = [
|
var stati = [
|
||||||
{className: "notRun", text: "not run"},
|
{className: "notRun", text: "not run"},
|
||||||
{className: "loud", text: "CB detected"},
|
{className: "loud", text: "CB detected"},
|
||||||
@ -34,10 +36,12 @@ var addTest = (function(){
|
|||||||
statusNode.title = logs.join("\n");
|
statusNode.title = logs.join("\n");
|
||||||
li.appendChild(statusNode);
|
li.appendChild(statusNode);
|
||||||
ul.appendChild(li);
|
ul.appendChild(li);
|
||||||
}
|
};
|
||||||
}());
|
}());
|
||||||
|
|
||||||
addTest("function length", function(log){
|
addTest("function length", function(log){
|
||||||
|
"use strict";
|
||||||
|
|
||||||
if (CanvasRenderingContext2D.prototype.getImageData.length !== 4){
|
if (CanvasRenderingContext2D.prototype.getImageData.length !== 4){
|
||||||
log("expected 4 parameters for getImageData - got", CanvasRenderingContext2D.prototype.getImageData.length);
|
log("expected 4 parameters for getImageData - got", CanvasRenderingContext2D.prototype.getImageData.length);
|
||||||
return true;
|
return true;
|
||||||
@ -47,6 +51,8 @@ addTest("function length", function(log){
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
addTest("function code", function(log){
|
addTest("function code", function(log){
|
||||||
|
"use strict";
|
||||||
|
|
||||||
if (!CanvasRenderingContext2D.prototype.getImageData.toString().match(/^\s*function getImageData\s*\(\)\s*\{\s*\[native code\]\s*\}\s*$/)){
|
if (!CanvasRenderingContext2D.prototype.getImageData.toString().match(/^\s*function getImageData\s*\(\)\s*\{\s*\[native code\]\s*\}\s*$/)){
|
||||||
log("unexpected function code:", CanvasRenderingContext2D.prototype.getImageData.toString());
|
log("unexpected function code:", CanvasRenderingContext2D.prototype.getImageData.toString());
|
||||||
return true;
|
return true;
|
||||||
@ -55,9 +61,15 @@ addTest("function code", function(log){
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
addTest("function name", function(){return CanvasRenderingContext2D.prototype.getImageData.name !== "getImageData"});
|
addTest("function name", function(){
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
return CanvasRenderingContext2D.prototype.getImageData.name !== "getImageData";
|
||||||
|
});
|
||||||
addTest("error provocation 1", function(log){
|
addTest("error provocation 1", function(log){
|
||||||
var canvas = document.createElement('canvas');
|
"use strict";
|
||||||
|
|
||||||
|
var canvas = document.createElement("canvas");
|
||||||
var ctx = canvas.getContext("2d");
|
var ctx = canvas.getContext("2d");
|
||||||
var canvasBlocker = false;
|
var canvasBlocker = false;
|
||||||
try{
|
try{
|
||||||
@ -75,7 +87,9 @@ addTest("error provocation 1", function(log){
|
|||||||
return canvasBlocker;
|
return canvasBlocker;
|
||||||
});
|
});
|
||||||
addTest("error provocation 2", function(log){
|
addTest("error provocation 2", function(log){
|
||||||
var canvas = document.createElement('canvas');
|
"use strict";
|
||||||
|
|
||||||
|
var canvas = document.createElement("canvas");
|
||||||
canvas.width = 0;
|
canvas.width = 0;
|
||||||
var ctx = canvas.getContext("2d");
|
var ctx = canvas.getContext("2d");
|
||||||
var canvasBlocker = false;
|
var canvasBlocker = false;
|
||||||
@ -95,6 +109,8 @@ addTest("error provocation 2", function(log){
|
|||||||
return canvasBlocker;
|
return canvasBlocker;
|
||||||
});
|
});
|
||||||
addTest("error provocation 3", function(log){
|
addTest("error provocation 3", function(log){
|
||||||
|
"use strict";
|
||||||
|
|
||||||
var canvasBlocker = false;
|
var canvasBlocker = false;
|
||||||
try{
|
try{
|
||||||
CanvasRenderingContext2D.prototype.getImageData.apply(undefined, [0, 0, 1, 1]);
|
CanvasRenderingContext2D.prototype.getImageData.apply(undefined, [0, 0, 1, 1]);
|
||||||
@ -111,6 +127,8 @@ addTest("error provocation 3", function(log){
|
|||||||
return canvasBlocker;
|
return canvasBlocker;
|
||||||
});
|
});
|
||||||
function testKnownPixelValue(size, log){
|
function testKnownPixelValue(size, log){
|
||||||
|
"use strict";
|
||||||
|
|
||||||
var canvas = document.createElement("canvas");
|
var canvas = document.createElement("canvas");
|
||||||
canvas.height = size;
|
canvas.height = size;
|
||||||
canvas.width = size;
|
canvas.width = size;
|
||||||
@ -128,16 +146,22 @@ function testKnownPixelValue(size, log){
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
addTest("known pixel value test 1", function(log){
|
addTest("known pixel value test 1", function(log){
|
||||||
|
"use strict";
|
||||||
|
|
||||||
return testKnownPixelValue(1, log);
|
return testKnownPixelValue(1, log);
|
||||||
});
|
});
|
||||||
addTest("known pixel value test 10", function(log){
|
addTest("known pixel value test 10", function(log){
|
||||||
|
"use strict";
|
||||||
|
|
||||||
return testKnownPixelValue(10, log);
|
return testKnownPixelValue(10, log);
|
||||||
});
|
});
|
||||||
addTest("double readout test", function(log){
|
addTest("double readout test", function(log){
|
||||||
|
"use strict";
|
||||||
|
|
||||||
var canvas = document.createElement("canvas");
|
var canvas = document.createElement("canvas");
|
||||||
var context = canvas.getContext("2d");
|
var context = canvas.getContext("2d");
|
||||||
var imageData = context.getImageData(0, 0, canvas.width, canvas.height);
|
var imageData = context.getImageData(0, 0, canvas.width, canvas.height);
|
||||||
for (var i = 0; i < imageData.data.length; i += 1){
|
for (let i = 0; i < imageData.data.length; i += 1){
|
||||||
if (i % 4 !== 3){
|
if (i % 4 !== 3){
|
||||||
imageData.data[i] = Math.floor(256 * Math.random());
|
imageData.data[i] = Math.floor(256 * Math.random());
|
||||||
}
|
}
|
||||||
@ -149,7 +173,7 @@ addTest("double readout test", function(log){
|
|||||||
|
|
||||||
var imageData1 = context.getImageData(0, 0, canvas.width, canvas.height);
|
var imageData1 = context.getImageData(0, 0, canvas.width, canvas.height);
|
||||||
var imageData2 = context.getImageData(0, 0, canvas.width, canvas.height);
|
var imageData2 = context.getImageData(0, 0, canvas.width, canvas.height);
|
||||||
for (var i = 0; i < imageData2.data.length; i += 1){
|
for (let i = 0; i < imageData2.data.length; i += 1){
|
||||||
if (imageData1.data[i] !== imageData2.data[i]){
|
if (imageData1.data[i] !== imageData2.data[i]){
|
||||||
log("mismatch at", i, ":",
|
log("mismatch at", i, ":",
|
||||||
imageData1.data[i], "(", imageData1.data[i].toString(2), ")",
|
imageData1.data[i], "(", imageData1.data[i].toString(2), ")",
|
||||||
@ -163,10 +187,12 @@ addTest("double readout test", function(log){
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
addTest("readout - in - out test", function(log){
|
addTest("readout - in - out test", function(log){
|
||||||
|
"use strict";
|
||||||
|
|
||||||
var canvas = document.createElement("canvas");
|
var canvas = document.createElement("canvas");
|
||||||
var context = canvas.getContext("2d");
|
var context = canvas.getContext("2d");
|
||||||
var imageData = context.getImageData(0, 0, canvas.width, canvas.height);
|
var imageData = context.getImageData(0, 0, canvas.width, canvas.height);
|
||||||
for (var i = 0; i < imageData.data.length; i += 1){
|
for (let i = 0; i < imageData.data.length; i += 1){
|
||||||
if (i % 4 !== 3){
|
if (i % 4 !== 3){
|
||||||
imageData.data[i] = Math.floor(256 * Math.random());
|
imageData.data[i] = Math.floor(256 * Math.random());
|
||||||
}
|
}
|
||||||
@ -181,7 +207,7 @@ addTest("readout - in - out test", function(log){
|
|||||||
var context2 = canvas2.getContext("2d");
|
var context2 = canvas2.getContext("2d");
|
||||||
context2.putImageData(imageData1, 0, 0);
|
context2.putImageData(imageData1, 0, 0);
|
||||||
var imageData2 = context2.getImageData(0, 0, canvas.width, canvas.height);
|
var imageData2 = context2.getImageData(0, 0, canvas.width, canvas.height);
|
||||||
for (var i = 0; i < imageData2.data.length; i += 1){
|
for (let i = 0; i < imageData2.data.length; i += 1){
|
||||||
if (imageData1.data[i] !== imageData2.data[i]){
|
if (imageData1.data[i] !== imageData2.data[i]){
|
||||||
log("mismatch at", i, ":",
|
log("mismatch at", i, ":",
|
||||||
imageData1.data[i], "(", imageData1.data[i].toString(2), ")",
|
imageData1.data[i], "(", imageData1.data[i].toString(2), ")",
|
||||||
|
@ -1 +1,2 @@
|
|||||||
|
/* eslint no-console: off */
|
||||||
console.log("first possible call");
|
console.log("first possible call");
|
@ -1,5 +1,7 @@
|
|||||||
|
|
||||||
var createLog = function(){
|
var createLog = function(){
|
||||||
|
"use strict";
|
||||||
|
|
||||||
var div = document.getElementById("log");
|
var div = document.getElementById("log");
|
||||||
|
|
||||||
return function createLog(){
|
return function createLog(){
|
||||||
@ -19,6 +21,8 @@ var createLog = function(){
|
|||||||
}();
|
}();
|
||||||
|
|
||||||
var performTest = function(){
|
var performTest = function(){
|
||||||
|
"use strict";
|
||||||
|
|
||||||
return function performTest(name, func, innerRunLength, outerRunLength){
|
return function performTest(name, func, innerRunLength, outerRunLength){
|
||||||
var log = createLog();
|
var log = createLog();
|
||||||
log("test " + name);
|
log("test " + name);
|
||||||
@ -59,12 +63,14 @@ var performTest = function(){
|
|||||||
}();
|
}();
|
||||||
|
|
||||||
function draw(canvas){
|
function draw(canvas){
|
||||||
|
"use strict";
|
||||||
|
|
||||||
canvas.setAttribute("width", 220);
|
canvas.setAttribute("width", 220);
|
||||||
canvas.setAttribute("height", 30);
|
canvas.setAttribute("height", 30);
|
||||||
|
|
||||||
var fp_text = "BrowserLeaks,com <canvas> 10";
|
var fp_text = "BrowserLeaks,com <canvas> 10";
|
||||||
|
|
||||||
var ctx = canvas.getContext('2d');
|
var ctx = canvas.getContext("2d");
|
||||||
ctx.textBaseline = "top";
|
ctx.textBaseline = "top";
|
||||||
ctx.font = "14px 'Arial'";
|
ctx.font = "14px 'Arial'";
|
||||||
ctx.textBaseline = "alphabetic";
|
ctx.textBaseline = "alphabetic";
|
||||||
@ -79,11 +85,13 @@ function draw(canvas){
|
|||||||
}
|
}
|
||||||
|
|
||||||
var fingerprintTest = function(){
|
var fingerprintTest = function(){
|
||||||
|
"use strict";
|
||||||
|
|
||||||
var canvas;
|
var canvas;
|
||||||
return {
|
return {
|
||||||
prepare: function(){
|
prepare: function(){
|
||||||
// create window canvas
|
// create window canvas
|
||||||
canvas = document.createElement('canvas');
|
canvas = document.createElement("canvas");
|
||||||
// draw image in window canvas
|
// draw image in window canvas
|
||||||
draw(canvas);
|
draw(canvas);
|
||||||
},
|
},
|
||||||
@ -94,6 +102,8 @@ var fingerprintTest = function(){
|
|||||||
}();
|
}();
|
||||||
|
|
||||||
var randomImageTest = function(){
|
var randomImageTest = function(){
|
||||||
|
"use strict";
|
||||||
|
|
||||||
var canvas;
|
var canvas;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
17
test/test.js
17
test/test.js
@ -1,5 +1,7 @@
|
|||||||
|
|
||||||
(function(){
|
(function(){
|
||||||
|
"use strict";
|
||||||
|
|
||||||
function show(container, url){
|
function show(container, url){
|
||||||
container.querySelector(".display").src = url;
|
container.querySelector(".display").src = url;
|
||||||
var buffer = new TextEncoder("utf-8").encode(url);
|
var buffer = new TextEncoder("utf-8").encode(url);
|
||||||
@ -23,12 +25,14 @@
|
|||||||
}());
|
}());
|
||||||
|
|
||||||
function draw(canvas){
|
function draw(canvas){
|
||||||
|
"use strict";
|
||||||
|
|
||||||
canvas.setAttribute("width", 220);
|
canvas.setAttribute("width", 220);
|
||||||
canvas.setAttribute("height", 30);
|
canvas.setAttribute("height", 30);
|
||||||
|
|
||||||
var fp_text = "BrowserLeaks,com <canvas> 10";
|
var fp_text = "BrowserLeaks,com <canvas> 10";
|
||||||
|
|
||||||
var ctx = canvas.getContext('2d');
|
var ctx = canvas.getContext("2d");
|
||||||
ctx.textBaseline = "top";
|
ctx.textBaseline = "top";
|
||||||
ctx.font = "14px 'Arial'";
|
ctx.font = "14px 'Arial'";
|
||||||
ctx.textBaseline = "alphabetic";
|
ctx.textBaseline = "alphabetic";
|
||||||
@ -43,26 +47,29 @@ function draw(canvas){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function topTest(){
|
function topTest(){
|
||||||
|
"use strict";
|
||||||
|
|
||||||
// create window canvas
|
// create window canvas
|
||||||
var canvas = document.createElement('canvas');
|
var canvas = document.createElement("canvas");
|
||||||
// draw image in window canvas
|
// draw image in window canvas
|
||||||
draw(canvas);
|
draw(canvas);
|
||||||
return canvas.toDataURL();
|
return canvas.toDataURL();
|
||||||
}
|
}
|
||||||
|
|
||||||
function iframeTest(){
|
function iframeTest(){
|
||||||
|
"use strict";
|
||||||
|
|
||||||
// create window canvas
|
// create window canvas
|
||||||
var canvas = document.createElement('canvas');
|
var canvas = document.createElement("canvas");
|
||||||
|
|
||||||
// draw image in window canvas
|
// draw image in window canvas
|
||||||
draw(canvas);
|
draw(canvas);
|
||||||
|
|
||||||
// create iframe canvas and ctx
|
// create iframe canvas and ctx
|
||||||
var iframe_canvas = document.querySelector("#iframe iframe").contentDocument.createElement('canvas');
|
var iframe_canvas = document.querySelector("#iframe iframe").contentDocument.createElement("canvas");
|
||||||
iframe_canvas.setAttribute("width", 220);
|
iframe_canvas.setAttribute("width", 220);
|
||||||
iframe_canvas.setAttribute("height", 30);
|
iframe_canvas.setAttribute("height", 30);
|
||||||
var iframe_ctx = iframe_canvas.getContext('2d');
|
var iframe_ctx = iframe_canvas.getContext("2d");
|
||||||
|
|
||||||
// copy image from window canvas to iframe ctx
|
// copy image from window canvas to iframe ctx
|
||||||
iframe_ctx.drawImage(canvas, 0, 0);
|
iframe_ctx.drawImage(canvas, 0, 0);
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
(function(){
|
(function(){
|
||||||
var canvas = document.createElement('canvas');
|
"use strict";
|
||||||
|
|
||||||
|
var canvas = document.createElement("canvas");
|
||||||
canvas.width = 11;
|
canvas.width = 11;
|
||||||
canvas.height = 13;
|
canvas.height = 13;
|
||||||
var gl = canvas.getContext('webgl');
|
var gl = canvas.getContext("webgl");
|
||||||
|
|
||||||
// paint it completely black
|
// paint it completely black
|
||||||
gl.clearColor(0, 0, 0, 1);
|
gl.clearColor(0, 0, 0, 1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user