64 lines
1.6 KiB
HTML
64 lines
1.6 KiB
HTML
<!--
|
|
Any copyright is dedicated to the Public Domain.
|
|
http://creativecommons.org/publicdomain/zero/1.0/
|
|
-->
|
|
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<title>Test for Bug 2022367</title>
|
|
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
</head>
|
|
<body>
|
|
<script type="text/javascript">
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
SpecialPowers.pushPrefEnv({"set": [["privacy.resistFingerprinting", true]]}).then(runTest);
|
|
|
|
function runTest() {
|
|
const nestedWorkerCode = `
|
|
for (let i = 0; i < 20; i++) {
|
|
let d = new Date();
|
|
d.getHours();
|
|
d.toString();
|
|
}
|
|
postMessage("done");
|
|
`;
|
|
const parentWorkerCode = `
|
|
const nestedBlob = new Blob([${JSON.stringify(nestedWorkerCode)}], {type: "application/javascript"});
|
|
const nestedURL = URL.createObjectURL(nestedBlob);
|
|
const NUM_NESTED = 2;
|
|
let doneCount = 0;
|
|
for (let n = 0; n < NUM_NESTED; n++) {
|
|
let w = new Worker(nestedURL);
|
|
w.onmessage = function() {
|
|
doneCount++;
|
|
if (doneCount === NUM_NESTED) {
|
|
postMessage("done");
|
|
}
|
|
}
|
|
}
|
|
`;
|
|
|
|
const blob = new Blob([parentWorkerCode], {type: "application/javascript"});
|
|
const url = URL.createObjectURL(blob);
|
|
|
|
const NUM_WORKERS = 2;
|
|
let doneCount = 0;
|
|
|
|
for (let i = 0; i < NUM_WORKERS; i++) {
|
|
let worker = new Worker(url);
|
|
worker.onmessage = function() {
|
|
doneCount++;
|
|
ok(true, `Worker ${i} and its nested workers completed`);
|
|
if (doneCount === NUM_WORKERS) {
|
|
ok(true, "All workers finished");
|
|
SimpleTest.finish();
|
|
}
|
|
};
|
|
}
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|