summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/workers/constructors/SharedWorker/URLMismatchError.htm
blob: 683d201ad3a0f7bbf8959d731ec20416c347909c (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
<!DOCTYPE html>
<meta charset="utf-8">
<title>Web Workers: SharedWorker - same name, different URL</title>
<link rel="author" title="Intel" href="http://www.intel.com">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
setup({ single_test: true });

let counter = 0
const maybeDone = () => {
  if(counter) {
    done()
  }
  counter++
}

const worker = new SharedWorker('shared-worker.js', 'name');
worker.port.postMessage("trigger a response")
worker.port.onmessage = e => {
  assert_equals(e.data, "ping")
  maybeDone()
}

// This used to throw "URLMismatchError", but the standard changed
const worker2 = new SharedWorker('1', 'name');
worker2.port.onmessage = e => {
  assert_array_equals(e.data, ["1", "name"])
  maybeDone()
}
</script>