summaryrefslogtreecommitdiffstats
path: root/browser/components/resistfingerprinting/test/browser/file_hwconcurrency_aboutblank_iframee.html
blob: 79edbefe2436a3efbf9e0c68b1354bb17d4a5f50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<!DOCTYPE html>
<meta charset="utf8">
<script>
window.onload = async () => {
  parent.postMessage("ready", "*");
}

window.addEventListener("message", async function listener(event) {
  if (event.data[0] == "gimme") {
  	var iframe = document.createElement("iframe");
    iframe.src = "about:blank?foo";
    document.body.append(iframe);

    function test() {
      let result = {
        hardwareConcurrency : navigator.hardwareConcurrency
      };

      window.parent.document.querySelector("#result").textContent = JSON.stringify(result);
    }

    iframe.contentWindow.eval(`(${test})()`);

    parent.postMessage(JSON.parse(document.querySelector("#result").textContent), "*")
  }
});
</script>
<output id="result"></output>