5 <title>Test for Navigator.hardwareConcurrency
</title>
6 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
7 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
8 <script type=
"application/javascript">
11 SimpleTest.waitForExplicitFinish();
13 function getWorkerHardwareConcurrency(onmessage) {
14 var script =
"postMessage(navigator.hardwareConcurrency)";
15 var url = URL.createObjectURL(new Blob([script]));
16 var w = new Worker(url);
17 w.onmessage = onmessage;
20 function resistFingerprinting(value) {
21 return SpecialPowers.pushPrefEnv({
"set": [[
"privacy.resistFingerprinting", value]]});
24 getWorkerHardwareConcurrency(e =
> {
26 is(typeof x,
"number",
"hardwareConcurrency should be a number.");
27 ok(x
> 0,
"hardwareConcurrency should be greater than 0.");
29 resistFingerprinting(true).then(() =
> {
30 getWorkerHardwareConcurrency(msg =
> {
32 ok(y ===
2,
"hardwareConcurrency should always be 2 when we're resisting fingerprinting.");
34 resistFingerprinting(false).then(() =
> {
35 getWorkerHardwareConcurrency(msg1 =
> {
37 ok(z === x,
"hardwareConcurrency should be the same as before we were resisting fingerprinting.");
50 <div id=
"content" style=
"display: none">