mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-22 04:40:20 +01:00
Linting of .tools and test
This commit is contained in:
parent
aef6bd3d59
commit
17349dcb05
1
.eslintignore
Normal file
1
.eslintignore
Normal file
@ -0,0 +1 @@
|
||||
!/.tools
|
@ -6,12 +6,17 @@
|
||||
"webextensions": true
|
||||
},
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 8,
|
||||
"ecmaFeatures": {
|
||||
"jsx": true
|
||||
},
|
||||
"sourceType": "script"
|
||||
},
|
||||
"plugins": ["promise", "eslint-comments"],
|
||||
"plugins": [
|
||||
"promise",
|
||||
"eslint-comments",
|
||||
"html"
|
||||
],
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:promise/recommended",
|
||||
@ -59,9 +64,26 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": ["test/*.js"],
|
||||
"files": ["test/*"],
|
||||
"rules": {
|
||||
"no-var": "off"
|
||||
"no-var": "off",
|
||||
"no-console": "off"
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": [".tools/*.js"],
|
||||
"env": {
|
||||
"node": true
|
||||
},
|
||||
"rules": {
|
||||
"no-console": "off"
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": ["*.html", "*.php"],
|
||||
"rules": {
|
||||
"no-useless-escape": "off",
|
||||
"no-undef": "off"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -7,6 +7,8 @@ const la = require("../_locales/" + language + "/messages.json");
|
||||
const laKeys = Object.keys(la);
|
||||
|
||||
enKeys.forEach(function(key){
|
||||
"use strict";
|
||||
|
||||
if (en[key].message){
|
||||
if (!la[key] || !la[key].message){
|
||||
console.log(key, "missing");
|
||||
|
@ -5,6 +5,8 @@ const util = require("util");
|
||||
|
||||
|
||||
function getMessagesInContent(content){
|
||||
"use strict";
|
||||
|
||||
const foundMessages = [];
|
||||
[
|
||||
/\b(?:_|browser.i18n.getMessage|extension.getTranslation|notify|extension)\(["']([^"']+)["']\s*(?:\)|,)/g,
|
||||
@ -19,31 +21,32 @@ function getMessagesInContent(content){
|
||||
}
|
||||
|
||||
async function getMessagesInFile(path){
|
||||
return await util.promisify(fs.exists)(path)
|
||||
.then(function(exists){
|
||||
"use strict";
|
||||
|
||||
const exists = await util.promisify(fs.exists)(path);
|
||||
if (exists){
|
||||
return util.promisify(fs.readFile)(path, {encoding: "UTF-8"})
|
||||
.then(function(content){
|
||||
const content = await util.promisify(fs.readFile)(path, {encoding: "UTF-8"});
|
||||
return getMessagesInContent(content);
|
||||
});
|
||||
}
|
||||
else {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log("file does not exist:", path);
|
||||
return [];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function getMessagesInFolder(folder){
|
||||
return await util.promisify(fs.readdir)(folder, {encoding: "UTF-8"})
|
||||
.then(function(files){
|
||||
return Promise.all(
|
||||
"use strict";
|
||||
|
||||
const files = await util.promisify(fs.readdir)(folder, {encoding: "UTF-8"});
|
||||
|
||||
const messages = await Promise.all(
|
||||
files.filter(function(file){
|
||||
return !file.startsWith(".");
|
||||
}).map(function(file){
|
||||
return path.join(folder, file);
|
||||
}).map(function(path){
|
||||
return util.promisify(fs.stat)(path).then(function(stat){
|
||||
}).map(async function(path){
|
||||
const stat = await util.promisify(fs.stat)(path);
|
||||
if (stat.isDirectory()){
|
||||
return getMessagesInFolder(path);
|
||||
}
|
||||
@ -55,9 +58,8 @@ async function getMessagesInFolder(folder){
|
||||
return [];
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
).then(function(messages){
|
||||
);
|
||||
const flat = [];
|
||||
messages.forEach(function(messages){
|
||||
messages.forEach(function(message){
|
||||
@ -65,12 +67,12 @@ async function getMessagesInFolder(folder){
|
||||
});
|
||||
});
|
||||
return flat;
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
async function getSettingMessages(){
|
||||
"use strict";
|
||||
|
||||
const settingStrings = require("../lib/settingStrings");
|
||||
const settingDefinitions = require("../lib/settingDefinitions");
|
||||
function getDefinition(name){
|
||||
@ -113,33 +115,53 @@ async function getSettingMessages(){
|
||||
});
|
||||
});
|
||||
});
|
||||
const presets = require("../options/presets.json");
|
||||
Object.keys(presets).forEach(function(preset){
|
||||
foundMessages.push("preset_" + preset + "_title");
|
||||
foundMessages.push("preset_" + preset + "_description");
|
||||
});
|
||||
return foundMessages.map(function(message){return message.toLowerCase();});
|
||||
}
|
||||
|
||||
async function getKnownMessages(){
|
||||
"use strict";
|
||||
|
||||
return [
|
||||
"addon_title",
|
||||
"addon_description",
|
||||
"urlsettings_title",
|
||||
"urlSettings_title",
|
||||
"installnotice",
|
||||
"presets_installnotice",
|
||||
"updatenotice",
|
||||
"disablenotifications",
|
||||
"disableNotifications",
|
||||
"showoptions",
|
||||
"displayhiddensettings_title",
|
||||
"displayhiddensettings_description",
|
||||
"displayHiddenSettings_title",
|
||||
"displayHiddenSettings_description",
|
||||
"browseraction_settings",
|
||||
"browseraction_test",
|
||||
"browseraction_review",
|
||||
"browseraction_reportissue",
|
||||
];
|
||||
"browseraction_reportIssue",
|
||||
].map(function(message){
|
||||
return message.toLowerCase();
|
||||
});
|
||||
}
|
||||
|
||||
const en = require("../_locales/en/messages.json");
|
||||
const declaredMessages = Object.keys(en)
|
||||
async function main(){
|
||||
"use strict";
|
||||
const en = require("../_locales/en/messages.json");
|
||||
const declaredMessages = Object.keys(en)
|
||||
// .filter(function(key){return en[key].message;})
|
||||
.map(function(key){return key.toLowerCase();});
|
||||
Promise.all([getSettingMessages(), getMessagesInFolder(path.join(__dirname, "..")), getKnownMessages()]).then(function([settingMessages, fileMessages, knownMessages]){
|
||||
.map(function(key){
|
||||
return key.toLowerCase();
|
||||
});
|
||||
const [settingMessages, fileMessages, knownMessages] = await Promise.all([
|
||||
getSettingMessages(),
|
||||
getMessagesInFolder(path.join(__dirname, "..")),
|
||||
getKnownMessages()]
|
||||
);
|
||||
|
||||
declaredMessages.forEach(function(message){
|
||||
|
||||
if (
|
||||
fileMessages.indexOf(message) === -1 &&
|
||||
settingMessages.indexOf(message) === -1 &&
|
||||
@ -148,4 +170,6 @@ Promise.all([getSettingMessages(), getMessagesInFolder(path.join(__dirname, ".."
|
||||
console.log(`usage of ${message} not found`);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
main();
|
@ -8,35 +8,39 @@ const language = process.argv[2];
|
||||
|
||||
|
||||
function getTranslationPath(language){
|
||||
"use strict";
|
||||
|
||||
return path.join(__dirname, "../_locales/" + language + "/messages.json");
|
||||
}
|
||||
async function loadTranslation(language){
|
||||
"use strict";
|
||||
|
||||
const path = getTranslationPath(language);
|
||||
return await util.promisify(fs.exists)(path)
|
||||
.then(function(exists){
|
||||
const exists = await util.promisify(fs.exists)(path);
|
||||
if (exists){
|
||||
console.log("language exists -> load data");
|
||||
return util.promisify(fs.readFile)(path, {encoding: "UTF-8"})
|
||||
.then(function(data){
|
||||
const data = await util.promisify(fs.readFile)(path, {encoding: "UTF-8"});
|
||||
return JSON.parse(data);
|
||||
});
|
||||
}
|
||||
else {
|
||||
console.log("language does not exist -> create it");
|
||||
return {};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function saveTranslation(language, data){
|
||||
"use strict";
|
||||
|
||||
const path = getTranslationPath(language);
|
||||
return await util.promisify(fs.writeFile)(path, JSON.stringify(data, null, "\t"));
|
||||
}
|
||||
|
||||
async function getInput(prompt){
|
||||
return new Promise(function(resolve, reject){
|
||||
"use strict";
|
||||
|
||||
return new Promise(function(resolve){
|
||||
process.stdout.write(prompt);
|
||||
process.stdin.setEncoding('utf8');
|
||||
process.stdin.setEncoding("utf8");
|
||||
process.stdin.resume();
|
||||
process.stdin.on("data", function onData(data){
|
||||
process.stdin.removeListener("data", onData);
|
||||
@ -47,18 +51,22 @@ async function getInput(prompt){
|
||||
}
|
||||
|
||||
async function askForTranslation(key){
|
||||
"use strict";
|
||||
|
||||
const enData = en[key];
|
||||
console.log("English translation for", key, ":", enData.message);
|
||||
if (enData.description){
|
||||
console.log("\nDescription:", enData.description);
|
||||
}
|
||||
return await getInput("Please enter translation: ");
|
||||
return getInput("Please enter translation: ");
|
||||
}
|
||||
|
||||
async function translate(language){
|
||||
"use strict";
|
||||
|
||||
const originalData = await loadTranslation(language);
|
||||
const data = {};
|
||||
for (var i = 0; i < enKeys.length; i += 1){
|
||||
for (let i = 0; i < enKeys.length; i += 1){
|
||||
const key = enKeys[i];
|
||||
const oldData = originalData[key];
|
||||
const enData = en[key];
|
||||
@ -76,5 +84,11 @@ async function translate(language){
|
||||
}
|
||||
|
||||
translate(language).then(function(data){
|
||||
"use strict";
|
||||
|
||||
return saveTranslation(language, data);
|
||||
}).catch(function(error){
|
||||
"use strict";
|
||||
|
||||
console.error(error);
|
||||
});
|
9
.vscode/settings.json
vendored
9
.vscode/settings.json
vendored
@ -61,5 +61,12 @@
|
||||
"**/.git/objects/**",
|
||||
".vscode",
|
||||
".eslintrc.json"
|
||||
]
|
||||
],
|
||||
"eslint.validate": [
|
||||
"javascript",
|
||||
"php",
|
||||
"html"
|
||||
],
|
||||
"eslint.options": {"--ext": ".js,.html,.php"},
|
||||
"eslint.lintTask.enable": true
|
||||
}
|
4
.vscode/tasks.json
vendored
4
.vscode/tasks.json
vendored
@ -16,7 +16,9 @@
|
||||
"command": "eslint"
|
||||
},
|
||||
"args": [
|
||||
"./"
|
||||
"./",
|
||||
"--ext",
|
||||
".js,.html,.php"
|
||||
],
|
||||
"presentation": {
|
||||
"echo": true,
|
||||
|
6
codebeatsettings
Normal file
6
codebeatsettings
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"JAVASCRIPT": {
|
||||
"LOC": [70, 80, 100, 120],
|
||||
"BLOCK_NESTING": [4, 5, 6, 7]
|
||||
}
|
||||
}
|
@ -97,7 +97,14 @@
|
||||
"name": "clearPersistentRnd",
|
||||
"actions": [
|
||||
"clearPersistentRnd",
|
||||
browser.contextualIdentities? "clearPersistentRndForContainer": false
|
||||
function(){
|
||||
try {
|
||||
return browser.contextualIdentities? "clearPersistentRndForContainer": false;
|
||||
}
|
||||
catch (error){
|
||||
return false;
|
||||
}
|
||||
}()
|
||||
],
|
||||
"displayDependencies": [
|
||||
{
|
||||
|
@ -112,6 +112,7 @@
|
||||
}
|
||||
function getIsPointInPath(ctx){
|
||||
"use strict";
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(20, 19);
|
||||
ctx.lineTo(40, 19);
|
||||
@ -120,8 +121,10 @@
|
||||
ctx.stroke();
|
||||
|
||||
return ctx.isPointInPath(30, 19);
|
||||
};
|
||||
}
|
||||
function hashToString(hash){
|
||||
"use strict";
|
||||
|
||||
var chunks = [];
|
||||
(new Uint32Array(hash)).forEach(function(num){
|
||||
chunks.push(num.toString(16));
|
||||
@ -131,7 +134,9 @@
|
||||
}).join("");
|
||||
}
|
||||
|
||||
function send(form, {url, imageData, isPointInPath}){
|
||||
var send = function(){
|
||||
"use strict";
|
||||
return function send(form, {url, imageData, isPointInPath}){
|
||||
var buffer = new TextEncoder("utf-8").encode(url);
|
||||
Promise.all([
|
||||
crypto.subtle.digest("SHA-256", buffer),
|
||||
@ -157,8 +162,12 @@
|
||||
}
|
||||
};
|
||||
xhr.send(new FormData(form));
|
||||
return;
|
||||
}).catch(function(error){
|
||||
console.error(error);
|
||||
});
|
||||
}
|
||||
};
|
||||
}();
|
||||
|
||||
send(document.getElementById("form"), topTest());
|
||||
</script>
|
||||
|
@ -18,7 +18,6 @@ var addTest = (function(){
|
||||
status = func(log)? 1: 2;
|
||||
}
|
||||
catch (error){
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(error);
|
||||
status = 3;
|
||||
}
|
||||
|
@ -1,2 +1 @@
|
||||
// eslint-disable-next-line no-console
|
||||
console.log("first possible call");
|
@ -13,35 +13,91 @@
|
||||
const iframe = window[0];
|
||||
log("TEST:", "iframe in html:", compare(test(iframe), reference));
|
||||
iframe.addEventListener("load", function(){
|
||||
"use strict";
|
||||
|
||||
log("TEST:", "iframe after loading:", compare(test(iframe), reference));
|
||||
});
|
||||
document.write("<iframe></iframe><script>log(\"TEST:\", \"iframe and script in document.write:\", compare(test(window[1]), reference));<\/script>");
|
||||
document.write(
|
||||
"<iframe></iframe>" +
|
||||
"<script>log(\"TEST:\", \"iframe and script in document.write:\", compare(test(window[1]), reference));<\/script>"
|
||||
);
|
||||
log("TEST:", "iframe in document.write:", compare(test(window[1]), reference));
|
||||
document.write("<iframe></iframe>");
|
||||
document.write("<script>log(\"TEST:\", \"iframe and script in separate document.write:\", compare(test(window[2]), reference));<\/script>");
|
||||
"<iframe></iframe><script>log(\"TEST:\", \"iframe and script in fragmented document.write:\", compare(test(window[3]), reference));<\/script>".split(/(?=<)/).forEach(function(part){
|
||||
document.write(
|
||||
"<script>" +
|
||||
"log(\"TEST:\", \"iframe and script in separate document.write:\", compare(test(window[2]), reference));" +
|
||||
"<\/script>");
|
||||
|
||||
(
|
||||
"<iframe></iframe>" +
|
||||
"<script>" +
|
||||
"log(\"TEST:\", \"iframe and script in fragmented document.write:\", compare(test(window[3]), reference));" +
|
||||
"<\/script>"
|
||||
).split(/(?=<)/).forEach(function(part){
|
||||
"use strict";
|
||||
|
||||
document.write(part);
|
||||
});
|
||||
document.writeln("<iframe></iframe><script>log(\"TEST:\", \"iframe and script in document.writeln:\", compare(test(window[4]), reference));<\/script>");
|
||||
document.write("<script src=\"iframeTest.js\"><\/script><iframe></iframe><script>log(\"TEST:\", \"script with src, iframe and script in document.write:\", compare(test(window[5]), reference));<\/script>");
|
||||
document.writeln(
|
||||
"<iframe></iframe>" +
|
||||
"<script>log(\"TEST:\", \"iframe and script in document.writeln:\", compare(test(window[4]), reference));<\/script>"
|
||||
);
|
||||
document.write(
|
||||
"<script src=\"iframeTest.js\"><\/script>" +
|
||||
"<iframe></iframe>" +
|
||||
"<script>" +
|
||||
"log(" +
|
||||
"\"TEST:\", " +
|
||||
"\"script with src, iframe and script in document.write:\", " +
|
||||
"compare(test(window[5]), reference)" +
|
||||
");" +
|
||||
"<\/script>"
|
||||
);
|
||||
|
||||
"<ifr|ame></ifr|ame>".split("|").forEach(function(part){
|
||||
"use strict";
|
||||
|
||||
document.write(part);
|
||||
});
|
||||
document.write("<script>log(\"TEST:\", \"ifr|ame split:\", compare(test(window[6]), reference));<\/script>");
|
||||
window.addEventListener("load", function(){
|
||||
"use strict";
|
||||
|
||||
// document.open();
|
||||
"<ifr|ame></ifr|ame>".split("|").forEach(function(part){
|
||||
document.write(part);
|
||||
});
|
||||
document.write("<script>log(\"TEST:\", \"reopened document: ifr|ame split:\", compare(test(window[0]), reference));<\/script>");
|
||||
document.write("<script src=\"iframeTest.js\"><\/script><iframe></iframe><script>log(\"TEST:\", \"reopened document: script with src, iframe and script in document.write:\", compare(test(window[1]), reference, true));<\/script>");
|
||||
document.write(
|
||||
"<script>" +
|
||||
"log(\"TEST:\", \"reopened document: ifr|ame split:\", compare(test(window[0]), reference));" +
|
||||
"<\/script>");
|
||||
document.write(
|
||||
"<script src=\"iframeTest.js\"><\/script>" +
|
||||
"<iframe></iframe>" +
|
||||
"<script>" +
|
||||
"log(" +
|
||||
"\"TEST:\", " +
|
||||
"\"reopened document: script with src, iframe and script in document.write:\", " +
|
||||
"compare(test(window[1]), reference, true)" +
|
||||
");" +
|
||||
"<\/script>"
|
||||
);
|
||||
// document.close();
|
||||
});
|
||||
window.setTimeout(function(){
|
||||
"use strict";
|
||||
|
||||
document.body.innerHTML = "<iframe></iframe>";
|
||||
console.log("TEST:", "innerHTML after 1000ms:", compare(test(window[0]), reference));
|
||||
document.body.innerHTML = "<h1>Iframe protection</h1>Open console (Ctrl + Shift + K) to see results. Depending on your Browser version you might have to check the \"Persist Logs\" flag and reload the page.<br><h2>Expected result</h2><ul><li>the displayed hashes should not be your native hash (run test with CB disabled to get it)</li><li>all the displayed hashes should be the same (exception if there is a change to a wyciwyg page)</li><li>all lines with \"TEST:\" should have a \"match\" at the end</li></ul>";
|
||||
document.body.innerHTML = "<h1>Iframe protection</h1>" +
|
||||
"Open console (Ctrl + Shift + K) to see results. " +
|
||||
"Depending on your Browser version you might have to check the \"Persist Logs\" flag and reload the page.<br>" +
|
||||
"<h2>Expected result</h2>" +
|
||||
"<ul>" +
|
||||
"<li>the displayed hashes should not be your native hash (run test with CB disabled to get it)</li>" +
|
||||
"<li>all the displayed hashes should be the same (exception if there is a change to a wyciwyg page)</li>" +
|
||||
"<li>all lines with \"TEST:\" should have a \"match\" at the end</li>" +
|
||||
"</ul>";
|
||||
var title = document.createElement("title");
|
||||
title.textContent = "iFrame test";
|
||||
document.getElementsByTagName("head")[0].appendChild(title);
|
||||
|
@ -9,7 +9,6 @@ var log = function(){
|
||||
str.unshift("color: red");
|
||||
str.unshift("%cX");
|
||||
}
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(...str);
|
||||
};
|
||||
}();
|
||||
@ -67,7 +66,6 @@ function compare(string1, string2, alwaysOutputHashes){
|
||||
hash(string1),
|
||||
hash(string2)
|
||||
]).then(function(hashes){
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(message, ...hashes);
|
||||
return;
|
||||
});
|
||||
|
@ -22,7 +22,9 @@ var createLog = function(){
|
||||
|
||||
var log = createLog();
|
||||
|
||||
log("user agent equal between server and client: " + (window.serverUserAgent === navigator.userAgent));
|
||||
log("user agent equal between server and client: " + (
|
||||
document.getElementById("serverUserAgent").text === navigator.userAgent
|
||||
));
|
||||
|
||||
Object.keys(navigator.__proto__).sort().forEach(function(property){
|
||||
"use strict";
|
||||
|
@ -23,8 +23,6 @@ Tests the navigator properties. In the default settings of CanvasBlocker the nav
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
var serverUserAgent = <?php echo json_encode($_SERVER["HTTP_USER_AGENT"]);?>;
|
||||
</script>
|
||||
<script id="serverUserAgent" type="text/data"><?php echo htmlentities($_SERVER["HTTP_USER_AGENT"], ENT_QUOTES, "UTF-8");?></script>
|
||||
<script src="navigatorTest.js"></script>
|
||||
</body></html>
|
@ -52,8 +52,10 @@
|
||||
ctx.stroke();
|
||||
|
||||
return ctx.isPointInPath(30, 19);
|
||||
};
|
||||
}
|
||||
function hashToString(hash){
|
||||
"use strict";
|
||||
|
||||
var chunks = [];
|
||||
(new Uint32Array(hash)).forEach(function(num){
|
||||
chunks.push(num.toString(16));
|
||||
@ -63,9 +65,12 @@
|
||||
}).join("");
|
||||
}
|
||||
|
||||
function send(form, {url, imageData, isPointInPath}){
|
||||
var send = function(){
|
||||
"use strict";
|
||||
|
||||
return function send(form, {url, imageData, isPointInPath}){
|
||||
var buffer = new TextEncoder("utf-8").encode(url);
|
||||
Promise.all([
|
||||
return Promise.all([
|
||||
crypto.subtle.digest("SHA-256", buffer),
|
||||
crypto.subtle.digest("SHA-256", imageData.data)
|
||||
]).then(function(hashes){
|
||||
@ -91,14 +96,18 @@
|
||||
xhr.send(new FormData(form));
|
||||
window.setTimeout(function(){
|
||||
form.submit();
|
||||
window.setTimeout(function(){
|
||||
document.getElementById("log").textContent = "You see the real canvas fingerprint, but it cannot leak from this iFrame.";
|
||||
window.setTimeout(
|
||||
function(){
|
||||
document.getElementById("log").textContent =
|
||||
"You see the real canvas fingerprint, but it cannot leak from this iFrame.";
|
||||
},
|
||||
250
|
||||
);
|
||||
}, 1000);
|
||||
return;
|
||||
});
|
||||
}
|
||||
};
|
||||
}();
|
||||
|
||||
send(document.getElementById("form"), topTest());
|
||||
</script>
|
||||
|
@ -28,6 +28,8 @@
|
||||
return canvas.toDataURL();
|
||||
}
|
||||
function hash(url){
|
||||
"use strict";
|
||||
|
||||
var buffer = new TextEncoder("utf-8").encode(url);
|
||||
return crypto.subtle.digest("SHA-256", buffer).then(function(hash){
|
||||
var chunks = [];
|
||||
@ -39,12 +41,12 @@
|
||||
}).join("");
|
||||
});
|
||||
}
|
||||
var firstFingerprint = false;
|
||||
try {
|
||||
var firstFingerprint = fingerPrint();
|
||||
firstFingerprint = fingerPrint();
|
||||
}
|
||||
catch (error){
|
||||
console.log(new Date(), error);
|
||||
var firstFingerprint = false;
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
@ -67,19 +69,29 @@
|
||||
var output = document.getElementById("output");
|
||||
output.textContent = "context API not blocked";
|
||||
window.setTimeout(function(){
|
||||
"use strict";
|
||||
|
||||
console.log(new Date(), "starting second fingerprint", window.name);
|
||||
output.appendChild(document.createElement("br"));
|
||||
var secondFingerprint = fingerPrint();
|
||||
if (firstFingerprint === secondFingerprint){
|
||||
hash(firstFingerprint).then(function(hash){
|
||||
return hash(firstFingerprint).then(function(hash){
|
||||
output.appendChild(document.createTextNode("fingerprint consistent (" + hash + ") -> good!"));
|
||||
output.style.backgroundColor = "green";
|
||||
return;
|
||||
});
|
||||
}
|
||||
else {
|
||||
Promise.all([hash(firstFingerprint), hash(secondFingerprint)]).then(function(hashes){
|
||||
output.appendChild(document.createTextNode("fingerprint not consistent (" + hashes[0] + " != " + hashes[1] + ") -> very bad! (potential fingerprint leak)"));
|
||||
return Promise.all([hash(firstFingerprint), hash(secondFingerprint)]).then(function(hashes){
|
||||
output.appendChild(
|
||||
document.createTextNode(
|
||||
"fingerprint not consistent (" +
|
||||
hashes[0] + " != " + hashes[1] +
|
||||
") -> very bad! (potential fingerprint leak)"
|
||||
)
|
||||
);
|
||||
output.style.backgroundColor = "red";
|
||||
return;
|
||||
});
|
||||
}
|
||||
}, 500);
|
||||
|
@ -32,25 +32,18 @@
|
||||
|
||||
if (location.search !== "?notInitial"){
|
||||
try {show(document.getElementById("top"), topTest());}
|
||||
// eslint-disable-next-line no-console
|
||||
catch (error){console.error(error);}
|
||||
try {show(document.getElementById("iframe"), iframeTest(document.querySelector("#iframe iframe")));}
|
||||
// eslint-disable-next-line no-console
|
||||
catch (error){console.error(error);}
|
||||
try {show(document.getElementById("iframe2"), iframeTest(document.querySelector("#iframe2 iframe")));}
|
||||
// eslint-disable-next-line no-console
|
||||
catch (error){console.error(error);}
|
||||
try {show(document.getElementById("iframe3"), iframeTest(document.querySelector("#iframe3 iframe")));}
|
||||
// eslint-disable-next-line no-console
|
||||
catch (error){console.error(error);}
|
||||
try {show(document.getElementById("iframe4"), dynamicIframeTest1());}
|
||||
// eslint-disable-next-line no-console
|
||||
catch (error){console.error(error);}
|
||||
try {show(document.getElementById("iframe5"), dynamicIframeTest2());}
|
||||
// eslint-disable-next-line no-console
|
||||
catch (error){console.error(error);}
|
||||
try {show(document.getElementById("iframe6"), dynamicIframeTest3());}
|
||||
// eslint-disable-next-line no-console
|
||||
catch (error){console.error(error);}
|
||||
}
|
||||
document.querySelector("#top button").addEventListener("click", function(){
|
||||
|
Loading…
x
Reference in New Issue
Block a user