gecko-dev/testing/web-platform/tests/workers/shared-worker-name-via-options.html
James Graham 3f997c7d6e Bug 1367340 - Update web-platform-tests to revision a2d29f3497c889546662566721bbd4f86efdbedd, a=testonly
MozReview-Commit-ID: G7hh5RgrlOv


--HG--
rename : testing/web-platform/tests/content-security-policy/navigation/to-javascript-url.html => testing/web-platform/tests/content-security-policy/navigation/to-javascript-url-script-src.html
rename : testing/web-platform/tests/webusb/idlharness.html => testing/web-platform/tests/webusb/idlharness.https.html
2017-05-24 14:03:28 +01:00

37 lines
1.2 KiB
HTML

<!DOCTYPE html>
<meta charset="utf-8">
<title>Test the name property of shared workers mixing constructor options and constructor strings</title>
<link rel="help" href="https://html.spec.whatwg.org/multipage/#concept-workerglobalscope-name">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-sharedworker">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-sharedworkerglobalscope-name">
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
"use strict";
const name = "my name";
const worker1 = new SharedWorker("support/shared-name.js", { name });
worker1.port.onmessage = receiveMessage;
const worker2 = new SharedWorker("support/shared-name.js", { name });
worker2.port.onmessage = receiveMessage;
const worker3 = new SharedWorker("support/shared-name.js", name);
worker3.port.onmessage = receiveMessage;
let nextCounterExpected = 1;
function receiveMessage(e) {
const { counter, name: receivedName } = e.data;
assert_equals(receivedName, name);
assert_equals(counter, nextCounterExpected);
++nextCounterExpected;
if (nextCounterExpected === 4) {
done();
}
}
</script>