tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_navigator_hardwareConcurrency.html (1295B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <meta charset="utf-8">
      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">
      9  "use strict";
     10 
     11  function resistFingerprinting(value) {
     12    return SpecialPowers.pushPrefEnv({"set": [["privacy.resistFingerprinting", value]]});
     13  }
     14 
     15  var x = navigator.hardwareConcurrency;
     16  is(typeof x, "number", "hardwareConcurrency should be a number.");
     17  ok(x > 0, "hardwareConcurrency should be greater than 0.");
     18 
     19  SimpleTest.waitForExplicitFinish();
     20 
     21  resistFingerprinting(true).then(() => {
     22    const expected = SpecialPowers.Services.appinfo.OS == "Darwin" ? 8 : 4;
     23 
     24    const y = navigator.hardwareConcurrency;
     25    ok(y === expected, "hardwareConcurrency should always be 2 when we're resisting fingerprinting.");
     26 
     27    resistFingerprinting(false).then(() => {
     28      const z = navigator.hardwareConcurrency;
     29      ok(z === x, "hardwareConcurrency should be the same as before we were resisting fingerprinting.");
     30      SimpleTest.finish();
     31    });
     32  });
     33 
     34  </script>
     35 </head>
     36 <body>
     37 <p id="display"></p>
     38 <div id="content" style="display: none">
     39 
     40 </div>
     41 <pre id="test">
     42 </pre>
     43 </body>
     44 </html>