Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /workers/constructors/SharedWorker/URLMismatchError.htm - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<title>Web Workers: SharedWorker - same name, different URL</title>
<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>