summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fetch/metadata/sharedworker.https.sub.html
blob: 4df858208a7457605d31d43b481dda599b89d1c8 (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
38
39
40
<!DOCTYPE html>

<link rel="author" href="mtrzos@google.com" title="Maciek Trzos">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/fetch/metadata/resources/helper.js></script>
<script src=/common/utils.js></script>
<script>
  let nonce = token();
  let key = "sharedworker-same-origin" + nonce;

  // TESTS //
  if (window.Worker) {

      //  Same-Origin test
      var sharedWorker = new SharedWorker('/fetch/metadata/resources/record-header.py?file=' + key);
      sharedWorker.port.start();

      sharedWorker.onerror = function(){
        test_same_origin();
      }
      sharedWorker.port.onmessage = function(e) {
        test_same_origin();
      }
      sharedWorker.port.postMessage("Ready");
    }

  function test_same_origin(){
    promise_test(t => {
      return new Promise((resolve, reject) => {
        let expected = {"site":"same-origin", "user":"", "mode": "same-origin", "dest": "sharedworker"};

        validate_expectations(key, expected)
          .then(_ => resolve())
          .catch(e => reject(e));
      })
    }, "Same-Origin sharedworker")
  }
</script>
<body></body>