summaryrefslogtreecommitdiffstats
path: root/toolkit/components/extensions/test/mochitest/file_redirect_cors_bypass.html
blob: b8fda2369a29d022d6c277e473959ea5ef6314fa (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
<!DOCTYPE HTML>
<html>
<head>
  <title>1450965 Skip Cors Check for Early WebExtention Redirects</title>
</head>
<body>
  <pre id="c">
    Fetching ...
  </pre>
  <script>
    "use strict";
    let c = document.querySelector("#c");
    const channel = new BroadcastChannel("test_bus");
    function l(t) { c.innerText += `${t}\n`; }

    fetch("https://example.org/tests/toolkit/components/extensions/test/mochitest/file_cors_blocked.txt")
      .then(r => r.text())
      .then(t => {
        // This Request should have been redirected to /file_sample.txt in
        // onBeforeRequest. So the text should be 'Sample'
        l(`Loaded: ${t}`);
        channel.postMessage(t);
      }).catch(e => {
        // The Redirect Failed, most likly due to a CORS Error
        l(`e`);
        channel.postMessage(e.toString());
      });
  </script>
</body>
</html>