summaryrefslogtreecommitdiffstats
path: root/browser/components/resistfingerprinting/test/browser/file_navigator_iframer.html
blob: 3498393904b810c76b6c629cef2a33fb8133eea5 (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
29
30
31
32
33
34
35
36
37
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="shared_test_funcs.js"></script>
<script>
async function runTheTest(iframe_domain, cross_origin_domain) {
  const iframes = document.querySelectorAll("iframe");
  iframes[0].src = `https://${iframe_domain}/browser/browser/components/resistfingerprinting/test/browser/file_navigator_iframee.html`;
  await waitForMessage("ready", `https://${iframe_domain}`);

  const promiseForRFPTest = new Promise(resolve => {
    window.addEventListener("message", event => {
      if(event.origin != `https://${iframe_domain}`) {
        throw new Error(`origin should be ${iframe_domain}`);
      }
      resolve(event.data);
    }, { once: true });
  });
  iframes[0].contentWindow.postMessage(["gimme", cross_origin_domain], "*");
  var result = await promiseForRFPTest;

  await fetch(`https://${cross_origin_domain}/browser/browser/components/resistfingerprinting/test/browser/file_navigator_header.sjs?`)
  .then((response) => { return response.text(); })
  .then((content) => {
    result.framer_crossOrigin_userAgentHTTPHeader = content;
  });

  return result;
}
</script>
</head>
<body>
<iframe width=100></iframe>
</body>
</html>