1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-11-10 15:18:52 +01:00
CanvasBlocker/test/settingsLoading.php

93 lines
2.9 KiB
PHP
Raw Normal View History

2017-12-12 21:56:22 +01:00
<!DOCTYPE html>
<html>
<head>
2019-09-04 00:30:20 +02:00
<title>Settings loading test</title>
2019-02-20 08:13:37 +01:00
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="testIcon.svg" type="image/png" rel="icon">
<link href="testIcon.svg" type="image/png" rel="shortcut icon">
2020-11-21 13:58:32 +01:00
<link rel="stylesheet" href="../default.css" type="text/css">
2020-01-06 15:15:04 +01:00
<?php
echo "<script>" . file_get_contents("testAPI.js");
echo file_get_contents("canvasAPI.js") . "</script>";
?>
2017-12-12 21:56:22 +01:00
<script>
2019-12-16 19:27:28 +01:00
const firstDescriptor = Object.getOwnPropertyDescriptor(HTMLCanvasElement.prototype, "getContext");
console.log(new Date(), "starting first fingerprint", window.name);
2019-12-16 19:27:28 +01:00
let firstFingerprint = false;
2017-12-12 21:56:22 +01:00
try {
2020-01-06 15:15:04 +01:00
firstFingerprint = canvasAPI.fingerprint().url;
2017-12-12 21:56:22 +01:00
}
2019-11-28 01:26:35 +01:00
catch (error){
console.log(new Date(), error);
2017-12-12 21:56:22 +01:00
}
</script>
2019-09-04 00:30:20 +02:00
<style>
#output {
padding: 1em;
}
.ok {
2020-11-21 13:58:32 +01:00
background-color: lightgreen;
}
.kok {
background-color: orange;
}
.nok {
2020-11-21 13:58:32 +01:00
background-color: lightcoral;
}
2019-09-04 00:30:20 +02:00
</style>
2017-12-12 21:56:22 +01:00
</head>
<body>
2019-09-04 00:30:20 +02:00
<h1>Settings loading test</h1>
<h2>Expected result</h2>
<ul>
<li>the background of the test result is green and states "good"</li>
<li>the displayed hash changes upon reload (depending on CanvasBlocker settings - e.g. not in the stealth preset)</li>
2019-09-04 00:30:20 +02:00
</ul>
<h2>Test</h2>
<div id="output"></div>
2017-12-12 21:56:22 +01:00
<script>
2017-12-13 20:08:53 +01:00
if (firstFingerprint){
2019-12-16 19:27:28 +01:00
const output = document.getElementById("output");
2019-09-04 00:30:20 +02:00
output.textContent = "context API not blocked";
output.appendChild(document.createElement("br"));
2019-12-16 19:27:28 +01:00
window.setTimeout(async function(){
2019-11-30 02:05:37 +01:00
"use strict";
console.log(new Date(), "starting second fingerprint", window.name);
2019-12-16 19:27:28 +01:00
const secondDescriptor = Object.getOwnPropertyDescriptor(HTMLCanvasElement.prototype, "getContext");
if (firstDescriptor.value === secondDescriptor.value){
output.appendChild(document.createTextNode("descriptor did not change -> good!"));
output.classList.add("ok");
}
else {
output.appendChild(document.createTextNode("descriptor changed -> bad!"));
console.log(firstDescriptor, secondDescriptor);
output.classList.add("nok");
}
2019-09-04 00:30:20 +02:00
output.appendChild(document.createElement("br"));
2020-01-06 15:15:04 +01:00
const secondFingerprint = canvasAPI.fingerprint().url;
2017-12-13 20:08:53 +01:00
if (firstFingerprint === secondFingerprint){
2020-01-06 15:15:04 +01:00
const firstHash = await testAPI.hash(firstFingerprint);
2019-12-16 19:27:28 +01:00
output.appendChild(document.createTextNode("fingerprint consistent (" + firstHash + ") -> good!"));
output.classList.add("ok");
2017-12-13 20:08:53 +01:00
}
else {
2020-01-06 15:15:04 +01:00
const hashes = await Promise.all([testAPI.hash(firstFingerprint), testAPI.hash(secondFingerprint)]);
2019-12-16 19:27:28 +01:00
output.appendChild(
document.createTextNode(
"fingerprint not consistent (" +
hashes[0] + " != " + hashes[1] +
") -> very bad! (potential fingerprint leak)"
)
);
output.classList.add("nok");
2017-12-13 20:08:53 +01:00
}
}, 500);
}
else {
2019-09-04 00:30:20 +02:00
output.textContent = "context API blocked";
output.classList.add("kok");
2017-12-13 20:08:53 +01:00
}
2017-12-12 21:56:22 +01:00
</script>
</body></html>