summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/workers/constructors
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/workers/constructors
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/workers/constructors')
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/13
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/1.headers1
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/Infinity3
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/Infinity-arguments.html13
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/Infinity.headers1
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/NaN3
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/NaN-arguments.html13
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/NaN.headers1
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/SharedWorker-constructor.html28
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/URLMismatchError.htm31
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/connect-event.html14
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/connect-event.js3
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/dummy-name.html10
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/dummy-shared-worker.html10
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/dummy-shared-worker.js0
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/empty-name.html10
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/empty.js0
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/global-members.html12
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/global-members.js9
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/interface-objects.html20
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/interface-objects.js13
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/name.html12
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/name.js3
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/no-arguments-ctor.html13
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/null3
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/null-arguments.html13
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/null.headers1
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/number-arguments.html13
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/port-onmessage.html12
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/port-onmessage.js3
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/port-properties.html19
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/port-readonly.html14
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/same-origin.html62
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/setting-port-members.html53
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/shared-worker.js6
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/undefined3
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/undefined-arguments.html13
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/undefined.headers1
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/unexpected-global-properties.html12
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/unexpected-global-properties.js9
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/unresolvable-url.html12
-rw-r--r--testing/web-platform/tests/workers/constructors/Worker/11
-rw-r--r--testing/web-platform/tests/workers/constructors/Worker/1.headers1
-rw-r--r--testing/web-platform/tests/workers/constructors/Worker/AbstractWorker.onerror.html37
-rw-r--r--testing/web-platform/tests/workers/constructors/Worker/AbstractWorker.onerror.js5
-rw-r--r--testing/web-platform/tests/workers/constructors/Worker/Blob-url.html21
-rw-r--r--testing/web-platform/tests/workers/constructors/Worker/DedicatedWorkerGlobalScope-members.worker.js18
-rw-r--r--testing/web-platform/tests/workers/constructors/Worker/Worker-constructor.html60
-rw-r--r--testing/web-platform/tests/workers/constructors/Worker/ctor-1.html23
-rw-r--r--testing/web-platform/tests/workers/constructors/Worker/ctor-null.html23
-rw-r--r--testing/web-platform/tests/workers/constructors/Worker/ctor-undefined.html23
-rw-r--r--testing/web-platform/tests/workers/constructors/Worker/expected-self-properties.worker.js11
-rw-r--r--testing/web-platform/tests/workers/constructors/Worker/null1
-rw-r--r--testing/web-platform/tests/workers/constructors/Worker/null.headers1
-rw-r--r--testing/web-platform/tests/workers/constructors/Worker/same-origin.html65
-rw-r--r--testing/web-platform/tests/workers/constructors/Worker/sample_worker/worker.js1
-rw-r--r--testing/web-platform/tests/workers/constructors/Worker/terminate.html34
-rw-r--r--testing/web-platform/tests/workers/constructors/Worker/terminate.js4
-rw-r--r--testing/web-platform/tests/workers/constructors/Worker/undefined1
-rw-r--r--testing/web-platform/tests/workers/constructors/Worker/undefined.headers1
-rw-r--r--testing/web-platform/tests/workers/constructors/Worker/unexpected-self-properties.worker.js11
-rw-r--r--testing/web-platform/tests/workers/constructors/Worker/use-base-url.html18
62 files changed, 835 insertions, 0 deletions
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/1 b/testing/web-platform/tests/workers/constructors/SharedWorker/1
new file mode 100644
index 0000000000..831434e639
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/1
@@ -0,0 +1,3 @@
+onconnect = e => {
+ e.ports[0].postMessage(['1', self.name]);
+};
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/1.headers b/testing/web-platform/tests/workers/constructors/SharedWorker/1.headers
new file mode 100644
index 0000000000..e7ec0d6699
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/1.headers
@@ -0,0 +1 @@
+Content-Type: text/javascript
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/Infinity b/testing/web-platform/tests/workers/constructors/SharedWorker/Infinity
new file mode 100644
index 0000000000..d4c921c565
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/Infinity
@@ -0,0 +1,3 @@
+onconnect = e => {
+ e.ports[0].postMessage(['Infinity', self.name]);
+};
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/Infinity-arguments.html b/testing/web-platform/tests/workers/constructors/SharedWorker/Infinity-arguments.html
new file mode 100644
index 0000000000..b38e55dc6b
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/Infinity-arguments.html
@@ -0,0 +1,13 @@
+<!doctype html>
+<title>Infinity as arguments</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+async_test(t => {
+ const worker = new SharedWorker(Infinity, Infinity);
+ worker.port.onmessage = t.step_func_done(e => {
+ assert_equals(e.data[0], 'Infinity', 'first arg (script name)');
+ assert_equals(e.data[1], 'Infinity', 'second arg (worker name)');
+ });
+}, 'Test constructing a shared worker with Infinity');
+</script>
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/Infinity.headers b/testing/web-platform/tests/workers/constructors/SharedWorker/Infinity.headers
new file mode 100644
index 0000000000..6805c323df
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/Infinity.headers
@@ -0,0 +1 @@
+Content-Type: text/javascript; charset=utf-8
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/NaN b/testing/web-platform/tests/workers/constructors/SharedWorker/NaN
new file mode 100644
index 0000000000..1d06329788
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/NaN
@@ -0,0 +1,3 @@
+onconnect = e => {
+ e.ports[0].postMessage(['NaN', self.name]);
+};
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/NaN-arguments.html b/testing/web-platform/tests/workers/constructors/SharedWorker/NaN-arguments.html
new file mode 100644
index 0000000000..8a4578a965
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/NaN-arguments.html
@@ -0,0 +1,13 @@
+<!doctype html>
+<title>NaN as arguments</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+async_test(t => {
+ const worker = new SharedWorker(NaN, NaN);
+ worker.port.onmessage = t.step_func_done(e => {
+ assert_equals(e.data[0], 'NaN', 'first arg (script name)');
+ assert_equals(e.data[1], 'NaN', 'second arg (worker name)');
+ });
+}, 'Test constructing a shared worker with NaN');
+</script>
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/NaN.headers b/testing/web-platform/tests/workers/constructors/SharedWorker/NaN.headers
new file mode 100644
index 0000000000..6805c323df
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/NaN.headers
@@ -0,0 +1 @@
+Content-Type: text/javascript; charset=utf-8
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/SharedWorker-constructor.html b/testing/web-platform/tests/workers/constructors/SharedWorker/SharedWorker-constructor.html
new file mode 100644
index 0000000000..7909eb5369
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/SharedWorker-constructor.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<title>Test SharedWorker constructor functionality.</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+test(() => {
+ assert_throws_js(Error,
+ function() {
+ new SharedWorker({toString:function(){throw new Error()}})},
+ 'toString exception should be propagated');
+}, 'Test toString propagation exception.');
+
+test(() => {
+ assert_throws_js(TypeError,
+ function() { new SharedWorker(); },
+ 'invoking SharedWorker constructor without arguments should result ' +
+ 'in an exception.')
+}, 'Test Sharedworker creation with no arguments');
+
+
+test(() => {
+ assert_throws_dom("SyntaxError",
+ function() { var Sharedworker = new SharedWorker('http://invalid:123$'); },
+ 'Invoking SharedWorker constructor with invalid script URL should ' +
+ 'result in an exception.');
+}, 'Test invalid script URL.');
+
+</script>
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/URLMismatchError.htm b/testing/web-platform/tests/workers/constructors/SharedWorker/URLMismatchError.htm
new file mode 100644
index 0000000000..683d201ad3
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/URLMismatchError.htm
@@ -0,0 +1,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>
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/connect-event.html b/testing/web-platform/tests/workers/constructors/SharedWorker/connect-event.html
new file mode 100644
index 0000000000..0ab41d25c9
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/connect-event.html
@@ -0,0 +1,14 @@
+<!doctype html>
+<title>connect event</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+async_test(t => {
+ const worker = new SharedWorker('connect-event.js');
+ worker.port.onmessage = t.step_func_done(e => {
+ assert_true(e.data[0], "e.data === ''");
+ assert_true(e.data[1], "e instanceof MessageEvent");
+ assert_true(e.data[2], "e.ports.length == 1");
+ });
+}, 'Test connect event for a shared worker');
+</script>
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/connect-event.js b/testing/web-platform/tests/workers/constructors/SharedWorker/connect-event.js
new file mode 100644
index 0000000000..2cf26a723e
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/connect-event.js
@@ -0,0 +1,3 @@
+onconnect = e => {
+ e.ports[0].postMessage([e.data === '', e instanceof MessageEvent, e.ports.length == 1]);
+};
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/dummy-name.html b/testing/web-platform/tests/workers/constructors/SharedWorker/dummy-name.html
new file mode 100644
index 0000000000..25277042e2
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/dummy-name.html
@@ -0,0 +1,10 @@
+<!doctype html>
+<title>creating a dummy shared worker with name "foo"</title>
+<link rel=help href="http://www.whatwg.org/html/#dom-sharedworker">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+test(() => {
+ const worker = new SharedWorker('empty.js', 'foo');
+});
+</script>
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/dummy-shared-worker.html b/testing/web-platform/tests/workers/constructors/SharedWorker/dummy-shared-worker.html
new file mode 100644
index 0000000000..59a449ad7d
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/dummy-shared-worker.html
@@ -0,0 +1,10 @@
+<!doctype html>
+<title>creating a dummy shared worker</title>
+<link rel=help href="http://www.whatwg.org/html/#dom-sharedworker">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+test(() => {
+ const worker = new SharedWorker('dummy-shared-worker.js');
+});
+</script>
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/dummy-shared-worker.js b/testing/web-platform/tests/workers/constructors/SharedWorker/dummy-shared-worker.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/dummy-shared-worker.js
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/empty-name.html b/testing/web-platform/tests/workers/constructors/SharedWorker/empty-name.html
new file mode 100644
index 0000000000..94771d27c9
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/empty-name.html
@@ -0,0 +1,10 @@
+<!doctype html>
+<title>creating a dummy shared worker with explicit name ""</title>
+<link rel=help href="http://www.whatwg.org/html/#dom-sharedworker">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+test(() => {
+ const worker = new SharedWorker('empty.js', '');
+});
+</script>
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/empty.js b/testing/web-platform/tests/workers/constructors/SharedWorker/empty.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/empty.js
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/global-members.html b/testing/web-platform/tests/workers/constructors/SharedWorker/global-members.html
new file mode 100644
index 0000000000..2da4fc1cee
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/global-members.html
@@ -0,0 +1,12 @@
+<!doctype html>
+<title>members of SharedWorkerGlobalScope</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+async_test(t => {
+ const worker = new SharedWorker('global-members.js');
+ worker.port.onmessage = t.step_func_done(e => {
+ assert_equals(e.data, '');
+ });
+}, 'Test if global members exist in a shared worker');
+</script>
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/global-members.js b/testing/web-platform/tests/workers/constructors/SharedWorker/global-members.js
new file mode 100644
index 0000000000..453da6aae5
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/global-members.js
@@ -0,0 +1,9 @@
+const expected = 'self location close onerror importScripts navigator addEventListener removeEventListener dispatchEvent name onconnect setTimeout clearTimeout setInterval clearInterval'.split(' ');
+let log = '';
+for (let i = 0; i < expected.length; ++i) {
+ if (!(expected[i] in self))
+ log += expected[i] + ' did not exist\n';
+}
+onconnect = e => {
+ e.ports[0].postMessage(log);
+};
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/interface-objects.html b/testing/web-platform/tests/workers/constructors/SharedWorker/interface-objects.html
new file mode 100644
index 0000000000..a8f6998168
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/interface-objects.html
@@ -0,0 +1,20 @@
+<!doctype html>
+<title>expected interface objects/constructors</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+async_test(t => {
+ const expected = 'XMLHttpRequest WebSocket EventSource MessageChannel Worker'.split(' ');
+ const supported = [];
+ for (let i = 0; i < expected.length; ++i) {
+ if (expected[i] in window)
+ supported.push(expected[i]);
+ }
+ const worker = new SharedWorker('interface-objects.js');
+ worker.port.start();
+ worker.port.postMessage(supported);
+ worker.port.onmessage = t.step_func_done(e => {
+ assert_equals(e.data, 'These were missing: ');
+ });
+}, 'Test if interface objects exist in a shared worker');
+</script>
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/interface-objects.js b/testing/web-platform/tests/workers/constructors/SharedWorker/interface-objects.js
new file mode 100644
index 0000000000..2a7aaee687
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/interface-objects.js
@@ -0,0 +1,13 @@
+let prt;
+const handleCall = e => {
+ const log = [];
+ for (let i = 0; i < e.data.length; ++i) {
+ if (!(e.data[i] in self))
+ log.push(e.data[i]);
+ }
+ prt.postMessage('These were missing: '+log.join(', '));
+};
+onconnect = e => {
+ prt = e.ports[0];
+ prt.onmessage = handleCall;
+};
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/name.html b/testing/web-platform/tests/workers/constructors/SharedWorker/name.html
new file mode 100644
index 0000000000..4531cb1b80
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/name.html
@@ -0,0 +1,12 @@
+<!doctype html>
+<title>self.name</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+async_test(t => {
+ const worker = new SharedWorker('name.js', 'hello');
+ worker.port.onmessage = t.step_func_done(e => {
+ assert_equals(e.data, 'hello');
+ });
+}, 'Test self.name in a shared worker');
+</script>
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/name.js b/testing/web-platform/tests/workers/constructors/SharedWorker/name.js
new file mode 100644
index 0000000000..2bc2a4b18b
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/name.js
@@ -0,0 +1,3 @@
+onconnect = e => {
+ e.ports[0].postMessage(self.name);
+};
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/no-arguments-ctor.html b/testing/web-platform/tests/workers/constructors/SharedWorker/no-arguments-ctor.html
new file mode 100644
index 0000000000..5a1231d7b5
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/no-arguments-ctor.html
@@ -0,0 +1,13 @@
+<!doctype html>
+<title>no arguments</title>
+<link rel=help href="http://www.whatwg.org/html/#sharedworker">
+<link rel=help href="http://dev.w3.org/2006/webapi/WebIDL/#es-interface-call">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+test(() => {
+ assert_throws_js(TypeError, () => {
+ const worker = new SharedWorker();
+ });
+});
+</script>
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/null b/testing/web-platform/tests/workers/constructors/SharedWorker/null
new file mode 100644
index 0000000000..16f02d5131
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/null
@@ -0,0 +1,3 @@
+onconnect = e => {
+ e.ports[0].postMessage(['null', self.name]);
+};
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/null-arguments.html b/testing/web-platform/tests/workers/constructors/SharedWorker/null-arguments.html
new file mode 100644
index 0000000000..dd5e5773ed
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/null-arguments.html
@@ -0,0 +1,13 @@
+<!doctype html>
+<title>null as arguments</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+async_test(t => {
+ const worker = new SharedWorker(null, null);
+ worker.port.onmessage = t.step_func_done(e => {
+ assert_equals(e.data[0], 'null', 'first arg (script name)');
+ assert_equals(e.data[1], '', 'second arg (worker name)');
+ });
+}, 'Test constructing a shared worker with null');
+</script>
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/null.headers b/testing/web-platform/tests/workers/constructors/SharedWorker/null.headers
new file mode 100644
index 0000000000..e7ec0d6699
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/null.headers
@@ -0,0 +1 @@
+Content-Type: text/javascript
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/number-arguments.html b/testing/web-platform/tests/workers/constructors/SharedWorker/number-arguments.html
new file mode 100644
index 0000000000..8f90baa898
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/number-arguments.html
@@ -0,0 +1,13 @@
+<!doctype html>
+<title>1 as arguments</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+async_test(t => {
+ const worker = new SharedWorker(1, 1);
+ worker.port.onmessage = t.step_func_done(e => {
+ assert_equals(e.data[0], '1', 'first arg (script name)');
+ assert_equals(e.data[1], '1', 'second arg (worker name)');
+ });
+}, 'Test constructing a shared worker with 1');
+</script>
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/port-onmessage.html b/testing/web-platform/tests/workers/constructors/SharedWorker/port-onmessage.html
new file mode 100644
index 0000000000..706420c5e4
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/port-onmessage.html
@@ -0,0 +1,12 @@
+<!doctype html>
+<title>worker.port.onmessage</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+async_test(t => {
+ const worker = new SharedWorker('port-onmessage.js', '');
+ worker.port.onmessage = t.step_func_done(e => {
+ assert_true(e.data);
+ });
+}, 'Test SharedWorker.port.onmessage');
+</script>
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/port-onmessage.js b/testing/web-platform/tests/workers/constructors/SharedWorker/port-onmessage.js
new file mode 100644
index 0000000000..64ef84df15
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/port-onmessage.js
@@ -0,0 +1,3 @@
+onconnect = e => {
+ e.ports[0].postMessage(true);
+};
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/port-properties.html b/testing/web-platform/tests/workers/constructors/SharedWorker/port-properties.html
new file mode 100644
index 0000000000..e2a1d5b2a8
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/port-properties.html
@@ -0,0 +1,19 @@
+<!doctype html>
+<title>worker.port</title>
+<link rel=help href="http://www.whatwg.org/html/#sharedworker">
+<link rel=help href="http://www.whatwg.org/html/#messageport">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+test(() => {
+ const worker = new SharedWorker('empty.js', '');
+ assert_true('port' in worker, "port");
+ assert_true('postMessage' in worker.port, "postMessage");
+ assert_true('start' in worker.port, "start");
+ assert_true('close' in worker.port, "close");
+ assert_true('onmessage' in worker.port, "onmessage");
+ assert_true('addEventListener' in worker.port, "addEventListener");
+ assert_true('removeEventListener' in worker.port, "removeEventListener");
+ assert_true('dispatchEvent' in worker.port, "dispatchEvent");
+});
+</script>
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/port-readonly.html b/testing/web-platform/tests/workers/constructors/SharedWorker/port-readonly.html
new file mode 100644
index 0000000000..cfb5f3afa5
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/port-readonly.html
@@ -0,0 +1,14 @@
+<!doctype html>
+<title>setting worker.port</title>
+<link rel=help href="http://www.whatwg.org/html/#sharedworker">
+<link rel=help href="http://dev.w3.org/2006/webapi/WebIDL/#dfn-attribute-setter">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+test(() => {
+ const worker = new SharedWorker('empty.js', '');
+ const x = worker.port;
+ worker.port = 1;
+ assert_equals(worker.port, x);
+});
+</script>
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/same-origin.html b/testing/web-platform/tests/workers/constructors/SharedWorker/same-origin.html
new file mode 100644
index 0000000000..0bfc503d06
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/same-origin.html
@@ -0,0 +1,62 @@
+<!doctype html>
+<title>same-origin checks</title>
+<meta name="timeout" content="long">
+<link rel=help href="https://html.spec.whatwg.org/multipage/workers.html#dom-sharedworker">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+// Needed to prevent a race condition if a worker throws an exception that may or may
+// not propogate to the window before the tests finish
+setup({allow_uncaught_exception: true});
+
+testSharedWorkerHelper = (t, script) => {
+ try {
+ const worker = new SharedWorker(script, '');
+ worker.onerror = t.step_func_done(e => {
+ assert_true(e instanceof Event);
+ });
+ } catch (e) {
+ assert_throws_dom("SecurityError", () => {throw e}, "DOMExceptions thrown on cross-origin SharedWorker construction must be SecurityErrors");
+ t.done();
+ }
+}
+
+test(() => {
+ assert_throws_dom("SecurityError", () => { new SharedWorker('unsupported:', ''); });
+}, "unsupported_scheme");
+
+async_test(t => {
+ const worker = new SharedWorker('data:,onconnect = e => { e.ports[0].postMessage(1); }', '');
+ worker.port.onmessage = t.step_func_done(e => {
+ assert_equals(e.data, 1);
+ });
+}, "data_url");
+
+async_test(t => {
+ testSharedWorkerHelper(t, 'javascript:""');
+}, "javascript_url");
+
+async_test(t => {
+ testSharedWorkerHelper(t, 'about:blank');
+}, "about_blank");
+
+async_test(t => {
+ testSharedWorkerHelper(t, 'http://www.opera.com/');
+}, "opera_com");
+
+async_test(t => {
+ testSharedWorkerHelper(t, location.protocol+'//'+location.hostname+':81/');
+}, "port_81");
+
+async_test(t => {
+ testSharedWorkerHelper(t, 'https://'+location.hostname+':80/');
+}, "https_port_80");
+
+async_test(t => {
+ testSharedWorkerHelper(t, 'https://'+location.hostname+':8000/');
+}, "https_port_8000");
+
+async_test(t => {
+ testSharedWorkerHelper(t, 'http://'+location.hostname+':8012/');
+}, "http_port_8012");
+</script>
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/setting-port-members.html b/testing/web-platform/tests/workers/constructors/SharedWorker/setting-port-members.html
new file mode 100644
index 0000000000..0c53474ff0
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/setting-port-members.html
@@ -0,0 +1,53 @@
+<!doctype html>
+<title>setting members of worker.port</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+setup(() => {
+ window.worker = new SharedWorker('#', '');
+});
+test(() => {
+ worker.port.postMessage = 1;
+ assert_equals(worker.port.postMessage, 1);
+}, 'postMessage');
+test(() => {
+ worker.port.start = 1;
+ assert_equals(worker.port.start, 1);
+}, 'start');
+test(() => {
+ worker.port.close = 1;
+ assert_equals(worker.port.close, 1);
+}, 'close');
+test(() => {
+ const f = () => {};
+ worker.port.onmessage = f;
+ assert_equals(worker.port.onmessage, f, '() => {}');
+ worker.port.onmessage = 1;
+ assert_equals(worker.port.onmessage, null, '1');
+ worker.port.onmessage = f;
+ worker.port.onmessage = ';';
+ assert_equals(worker.port.onmessage, null, '";"');
+ worker.port.onmessage = f;
+ const handler = {handleEvent:() => {}};
+ worker.port.onmessage = handler;
+ assert_equals(worker.port.onmessage, handler, '{handleEvent:() => {}}');
+ worker.port.onmessage = f;
+ worker.port.onmessage = null;
+ assert_equals(worker.port.onmessage, null, 'null');
+ worker.port.onmessage = f;
+ worker.port.onmessage = undefined;
+ assert_equals(worker.port.onmessage, null, 'undefined');
+}, 'onmessage');
+test(() => {
+ worker.port.addEventListener = 1;
+ assert_equals(worker.port.addEventListener, 1);
+}, 'addEventListener');
+test(() => {
+ worker.port.removeEventListener = 1;
+ assert_equals(worker.port.removeEventListener, 1);
+}, 'removeEventListener');
+test(() => {
+ worker.port.despatchEvent = 1;
+ assert_equals(worker.port.despatchEvent, 1);
+}, 'despatchEvent');
+</script>
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/shared-worker.js b/testing/web-platform/tests/workers/constructors/SharedWorker/shared-worker.js
new file mode 100644
index 0000000000..b6d18855da
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/shared-worker.js
@@ -0,0 +1,6 @@
+onconnect = e => {
+ const port = e.ports[0];
+ port.onmessage = e => {
+ port.postMessage('ping');
+ }
+}
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/undefined b/testing/web-platform/tests/workers/constructors/SharedWorker/undefined
new file mode 100644
index 0000000000..b8462f1911
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/undefined
@@ -0,0 +1,3 @@
+onconnect = e => {
+ e.ports[0].postMessage(['undefined', self.name]);
+};
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/undefined-arguments.html b/testing/web-platform/tests/workers/constructors/SharedWorker/undefined-arguments.html
new file mode 100644
index 0000000000..cd4c86e84a
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/undefined-arguments.html
@@ -0,0 +1,13 @@
+<!doctype html>
+<title>undefined as arguments</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+async_test(t => {
+ const worker = new SharedWorker(undefined, undefined);
+ worker.port.onmessage = t.step_func_done(e => {
+ assert_equals(e.data[0], 'undefined', 'first arg (script name)');
+ assert_equals(e.data[1], '', 'second arg (worker name)');
+ });
+}, 'Test constructing a shared worker with undefined');
+</script>
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/undefined.headers b/testing/web-platform/tests/workers/constructors/SharedWorker/undefined.headers
new file mode 100644
index 0000000000..e7ec0d6699
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/undefined.headers
@@ -0,0 +1 @@
+Content-Type: text/javascript
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/unexpected-global-properties.html b/testing/web-platform/tests/workers/constructors/SharedWorker/unexpected-global-properties.html
new file mode 100644
index 0000000000..522d31ff56
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/unexpected-global-properties.html
@@ -0,0 +1,12 @@
+<!doctype html>
+<title>unexpected members/interface objects/constructors</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+async_test(t => {
+ const worker = new SharedWorker('unexpected-global-properties.js');
+ worker.port.onmessage = t.step_func_done(e => {
+ assert_equals(e.data, '');
+ });
+}, 'Test unexpected properties are not in global scope');
+</script>
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/unexpected-global-properties.js b/testing/web-platform/tests/workers/constructors/SharedWorker/unexpected-global-properties.js
new file mode 100644
index 0000000000..0af8935821
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/unexpected-global-properties.js
@@ -0,0 +1,9 @@
+const unexpected = 'open print stop getComputedStyle getSelection releaseEvents captureEvents alert confirm prompt addEventStream removeEventStream back forward attachEvent detachEvent navigate DOMParser XMLSerializer XPathEvaluator XSLTProcessor opera Image Option frames Audio SVGUnitTypes SVGZoomAndPan java netscape sun Packages ByteArray closed defaultStatus document event frameElement history innerHeight innerWidth opener outerHeight outerWidth pageXOffset pageYOffset parent screen screenLeft screenTop screenX screenY status top window length'.split(' '); // iterated window in opera and removed expected ones
+let log = '';
+for (let i = 0; i < unexpected.length; ++i) {
+ if (unexpected[i] in self)
+ log += unexpected[i] + ' ';
+}
+onconnect = e => {
+ e.ports[0].postMessage(log);
+};
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/unresolvable-url.html b/testing/web-platform/tests/workers/constructors/SharedWorker/unresolvable-url.html
new file mode 100644
index 0000000000..c68968d77d
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/unresolvable-url.html
@@ -0,0 +1,12 @@
+<!doctype html>
+<title>resolving broken url</title>
+<link rel=help href="http://www.whatwg.org/html/#dom-sharedworker">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+test(() => {
+ assert_throws_dom("SyntaxError", () => {
+ const worker = new SharedWorker('http://foo bar');
+ });
+});
+</script>
diff --git a/testing/web-platform/tests/workers/constructors/Worker/1 b/testing/web-platform/tests/workers/constructors/Worker/1
new file mode 100644
index 0000000000..ea0b7c8f4c
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/Worker/1
@@ -0,0 +1 @@
+postMessage('1');
diff --git a/testing/web-platform/tests/workers/constructors/Worker/1.headers b/testing/web-platform/tests/workers/constructors/Worker/1.headers
new file mode 100644
index 0000000000..e7ec0d6699
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/Worker/1.headers
@@ -0,0 +1 @@
+Content-Type: text/javascript
diff --git a/testing/web-platform/tests/workers/constructors/Worker/AbstractWorker.onerror.html b/testing/web-platform/tests/workers/constructors/Worker/AbstractWorker.onerror.html
new file mode 100644
index 0000000000..b27f278bff
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/Worker/AbstractWorker.onerror.html
@@ -0,0 +1,37 @@
+<!doctype html>
+<title>AbstractWorker.onerror</title>
+<link rel=help href="https://html.spec.whatwg.org/multipage/#runtime-script-errors-2">
+<link rel=help href="https://html.spec.whatwg.org/multipage/#report-the-error">
+<link rel=help href="https://html.spec.whatwg.org/multipage/#the-event-handler-processing-algorithm">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+setup({allow_uncaught_exception:true});
+async_test(function() {
+ var worker = new Worker('AbstractWorker.onerror.js');
+ var error;
+ worker.onerror = this.step_func(function(a, b, c) {
+ error = a;
+ assert_equals('' + a, '[object ErrorEvent]');
+ assert_true("message" in a, 'ErrorEvent.message');
+ assert_equals(typeof a.message, "string", 'ErrorEvent.message');
+ assert_equals(a.filename, document.URL.replace('.html', '.js'), 'ErrorEvent.filename');
+ assert_true("lineno" in a, 'ErrorEvent.lineno');
+ assert_equals(typeof a.lineno, "number", 'ErrorEvent.lineno');
+ assert_equals(b, undefined, 'unexpected second argument to onerror');
+ assert_equals(c, undefined, 'unexpected third argument to onerror');
+ });
+ worker.onmessage = this.step_func(function(e) {
+ assert_unreached('onmessage was invoked but worker script shouldn\'t have compiled');
+ });
+ window.onerror = this.step_func_done(function(a, b, c, d, e, f) {
+ assert_equals(a, error.message, 'message');
+ assert_equals(b, error.filename, 'filename');
+ assert_equals(c, error.lineno, 'lineno');
+ assert_equals(d, error.colno, 'colno');
+ assert_equals(e, error.error, 'error');
+ assert_equals(f, undefined, 'unexpected sixth argument to onerror');
+ });
+});
+</script> \ No newline at end of file
diff --git a/testing/web-platform/tests/workers/constructors/Worker/AbstractWorker.onerror.js b/testing/web-platform/tests/workers/constructors/Worker/AbstractWorker.onerror.js
new file mode 100644
index 0000000000..e0bc507637
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/Worker/AbstractWorker.onerror.js
@@ -0,0 +1,5 @@
+for (;) // should cause onerror to be invoked, but onerror is null, so
+ // the error is "not handled". should fire an ErrorEvent on the
+ // worker.
+ break;
+postMessage(1); // shouldn't do anything since the script doesn't compile \ No newline at end of file
diff --git a/testing/web-platform/tests/workers/constructors/Worker/Blob-url.html b/testing/web-platform/tests/workers/constructors/Worker/Blob-url.html
new file mode 100644
index 0000000000..168fc91ae1
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/Worker/Blob-url.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Web Workers: Worker - Blob url</title>
+<link rel="author" title="Intel" href="http://www.intel.com">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+
+ async_test(function(t) {
+ var blob = new Blob(["onmessage = function(event) { postMessage(event.data); }"], {type: "text/plain"});
+ var worker = new Worker(window.URL.createObjectURL(blob));
+ var data = "Blob URL";
+ worker.postMessage(data);
+ worker.onmessage = t.step_func(function(event) {
+ assert_equals(event.data, data, "event.data");
+ t.done();
+ });
+ }, "Worker supports Blob url");
+
+</script>
diff --git a/testing/web-platform/tests/workers/constructors/Worker/DedicatedWorkerGlobalScope-members.worker.js b/testing/web-platform/tests/workers/constructors/Worker/DedicatedWorkerGlobalScope-members.worker.js
new file mode 100644
index 0000000000..2ef466ccdc
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/Worker/DedicatedWorkerGlobalScope-members.worker.js
@@ -0,0 +1,18 @@
+importScripts("/resources/testharness.js");
+
+var expected = [
+ 'postMessage', 'onmessage', /* DedicatedWorkerGlobalScope */
+ 'self', 'location', 'close', 'onerror', 'onoffline', 'ononline', /* WorkerGlobalScope */
+ 'addEventListener', 'removeEventListener', 'dispatchEvent', /* EventListener */
+ 'importScripts', 'navigator', /* WorkerUtils */
+ 'setTimeout', 'clearTimeout', 'setInterval', 'clearInterval', /* WindowTimers */
+ 'btoa', 'atob' /* WindowBase64 */
+];
+for (var i = 0; i < expected.length; ++i) {
+ var property = expected[i];
+ test(function() {
+ assert_true(property in self);
+ }, "existence of " + property);
+}
+
+done();
diff --git a/testing/web-platform/tests/workers/constructors/Worker/Worker-constructor.html b/testing/web-platform/tests/workers/constructors/Worker/Worker-constructor.html
new file mode 100644
index 0000000000..6d6843b77b
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/Worker/Worker-constructor.html
@@ -0,0 +1,60 @@
+<!DOCTYPE html>
+<title>Test Worker constructor functionality.</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+
+test(() => {
+ assert_throws_js(Error,
+ function() {
+ new Worker({toString:function(){throw new Error()}})},
+ 'toString exception should be propagated');
+}, 'Test toString propagation exception.');
+
+test(() => {
+ try {
+ var foo = {toString:function(){new Worker(foo)}};
+ new Worker(foo);
+ } catch(ex) {
+ assert_true(true, 'trying to create workers recursively should result in an: ' +
+ ex + 'exception.')
+ }
+}, 'Test recursive Worker creation.');
+
+test(() => {
+ assert_throws_js(TypeError,
+ function() { new Worker(); },
+ 'invoking Worker constructor without arguments should result ' +
+ 'in an exception.')
+}, 'Test worker creation with no arguments');
+
+async_test(t => {
+ var worker = new Worker('');
+ worker.onerror = function(e) {
+ e.preventDefault();
+ t.done();
+ }
+}, 'Test Worker creation with empty script URL.');
+
+test(() => {
+ assert_throws_dom("SyntaxError",
+ function() { var worker = new Worker('http://invalid:123$'); },
+ 'Invoking Worker constructor with invalid script URL should ' +
+ 'result in an exception.');
+}, 'Test invalid script URL.');
+
+async_test(t => {
+ var worker = new Worker('does-not-exist.js');
+ worker.onerror = function(e) {
+ t.done();
+ }
+}, 'Test not existent script URL.');
+
+test(() => {
+ var worker = new Worker('../../support/Worker-common.js');
+ assert_true('postMessage' in worker,
+ 'worker.postMessage did not exist.');
+ assert_true('addEventListener' in worker,
+ 'worker.addEventListener did not exist.');
+}, 'Test the Worker object defines postMessage() and addEventListener().');
+</script>
diff --git a/testing/web-platform/tests/workers/constructors/Worker/ctor-1.html b/testing/web-platform/tests/workers/constructors/Worker/ctor-1.html
new file mode 100644
index 0000000000..bd865261fc
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/Worker/ctor-1.html
@@ -0,0 +1,23 @@
+<!--
+postMessage('FAIL');
+/*
+-->
+<!doctype html>
+<title>1 as argument</title>
+<link rel=help href="http://www.whatwg.org/html/#dom-worker">
+<link rel=help href="http://dev.w3.org/2006/webapi/WebIDL/#es-DOMString">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+var t = async_test();
+t.step(function() {
+ var worker = new Worker(1);
+ worker.addEventListener('message', t.step_func_done(function(e) {
+ assert_equals(e.data, '1')
+ }), false);
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/constructors/Worker/ctor-null.html b/testing/web-platform/tests/workers/constructors/Worker/ctor-null.html
new file mode 100644
index 0000000000..94ab71aeff
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/Worker/ctor-null.html
@@ -0,0 +1,23 @@
+<!--
+postMessage('FAIL');
+/*
+-->
+<!doctype html>
+<title>null as argument</title>
+<link rel=help href="http://www.whatwg.org/html/#dom-worker">
+<link rel=help href="http://dev.w3.org/2006/webapi/WebIDL/#es-DOMString">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+var t = async_test();
+t.step(function() {
+ var worker = new Worker(null);
+ worker.addEventListener('message', t.step_func_done(function(e) {
+ assert_equals(e.data, 'null')
+ }), false);
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/constructors/Worker/ctor-undefined.html b/testing/web-platform/tests/workers/constructors/Worker/ctor-undefined.html
new file mode 100644
index 0000000000..2d9eb6e656
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/Worker/ctor-undefined.html
@@ -0,0 +1,23 @@
+<!--
+postMessage('FAIL');
+/*
+-->
+<!doctype html>
+<title>undefined as argument</title>
+<link rel=help href="http://www.whatwg.org/html/#dom-worker">
+<link rel=help href="http://dev.w3.org/2006/webapi/WebIDL/#es-DOMString">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+var t = async_test();
+t.step(function() {
+ var worker = new Worker(undefined);
+ worker.addEventListener('message', t.step_func_done(function(e) {
+ assert_equals(e.data, 'undefined')
+ }), false);
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/constructors/Worker/expected-self-properties.worker.js b/testing/web-platform/tests/workers/constructors/Worker/expected-self-properties.worker.js
new file mode 100644
index 0000000000..0ce41b59e7
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/Worker/expected-self-properties.worker.js
@@ -0,0 +1,11 @@
+importScripts("/resources/testharness.js");
+
+var expected = ['XMLHttpRequest', 'WebSocket', 'EventSource', 'MessageChannel', 'Worker', 'SharedWorker'];
+for (var i = 0; i < expected.length; ++i) {
+ var property = expected[i];
+ test(function() {
+ assert_true(property in self);
+ }, "existence of " + property);
+}
+
+done();
diff --git a/testing/web-platform/tests/workers/constructors/Worker/null b/testing/web-platform/tests/workers/constructors/Worker/null
new file mode 100644
index 0000000000..6d079b514c
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/Worker/null
@@ -0,0 +1 @@
+postMessage('null');
diff --git a/testing/web-platform/tests/workers/constructors/Worker/null.headers b/testing/web-platform/tests/workers/constructors/Worker/null.headers
new file mode 100644
index 0000000000..e7ec0d6699
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/Worker/null.headers
@@ -0,0 +1 @@
+Content-Type: text/javascript
diff --git a/testing/web-platform/tests/workers/constructors/Worker/same-origin.html b/testing/web-platform/tests/workers/constructors/Worker/same-origin.html
new file mode 100644
index 0000000000..cdc36c1718
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/Worker/same-origin.html
@@ -0,0 +1,65 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>same-origin checks; the script is in a script element</title>
+<meta name="timeout" content="long">
+<link rel=help href="https://html.spec.whatwg.org/multipage/workers.html#dom-worker">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+// Needed to prevent a race condition if a worker throws an exception that may or may
+// not propogate to the window before the tests finish
+setup({allow_uncaught_exception: true});
+
+function testWorkerHelper(t, script) {
+ try {
+ var worker = new Worker(script);
+ worker.onerror = t.step_func_done(function(e) {
+ assert_true(e instanceof Event);
+ });
+ } catch (e) {
+ assert_throws_dom("SecurityError", () => {throw e}, "DOMExceptions thrown on cross-origin Worker construction must be SecurityErrors");
+ t.done();
+ }
+}
+
+test(function() {
+ assert_throws_dom("SecurityError", function() { new Worker('unsupported:'); });
+}, "unsupported_scheme");
+
+async_test(function() {
+ var worker = new Worker('data:,postMessage(1);');
+ worker.onmessage = this.step_func_done(function(e) {
+ assert_equals(e.data, 1);
+ });
+}, "data_url");
+
+async_test(function(t) {
+ testWorkerHelper(t, 'about:blank');
+}, "about_blank");
+
+async_test(function(t) {
+ testWorkerHelper(t, 'http://www.example.invalid/');
+}, "example_invalid");
+
+async_test(function(t) {
+ testWorkerHelper(t, location.protocol+'//'+location.hostname+':81/');
+}, "port_81");
+
+async_test(function(t) {
+ testWorkerHelper(t, 'https://'+location.hostname+':80/');
+}, "https_port_80");
+
+async_test(function(t) {
+ testWorkerHelper(t, 'https://'+location.hostname+':8000/');
+}, "https_port_8000");
+
+async_test(function(t) {
+ testWorkerHelper(t, 'http://'+location.hostname+':8012/');
+}, "http_post_8012");
+
+async_test(function(t) {
+ testWorkerHelper(t,'javascript:""');
+}, "javascript_url");
+
+</script>
diff --git a/testing/web-platform/tests/workers/constructors/Worker/sample_worker/worker.js b/testing/web-platform/tests/workers/constructors/Worker/sample_worker/worker.js
new file mode 100644
index 0000000000..19bbea58e7
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/Worker/sample_worker/worker.js
@@ -0,0 +1 @@
+onmessage = function(event) { postMessage(event.data); }
diff --git a/testing/web-platform/tests/workers/constructors/Worker/terminate.html b/testing/web-platform/tests/workers/constructors/Worker/terminate.html
new file mode 100644
index 0000000000..b9af76e2fb
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/Worker/terminate.html
@@ -0,0 +1,34 @@
+<!doctype html>
+<title>terminate()</title>
+<link rel=help href="http://www.whatwg.org/html/#dom-worker-terminate">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+var t = async_test();
+t.step(function() {
+ var worker = new Worker('terminate.js');
+ var i = 0;
+ var expected;
+
+ worker.onmessage = t.step_func(function() {
+ i++;
+ });
+
+ setTimeout(t.step_func(function() {
+ expected = i;
+ start_time = Date.now();
+ //Hang the main thread for a bit to give the worker the chance to post some more messages
+ while(Date.now() - start_time < 500) {
+ //pass
+ }
+ worker.terminate();
+
+ setTimeout(t.step_func(function() {
+ assert_equals(i, expected);
+ t.done();
+ }), 100);
+
+ }), 100);
+});
+</script> \ No newline at end of file
diff --git a/testing/web-platform/tests/workers/constructors/Worker/terminate.js b/testing/web-platform/tests/workers/constructors/Worker/terminate.js
new file mode 100644
index 0000000000..e6349c3320
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/Worker/terminate.js
@@ -0,0 +1,4 @@
+(function f() {
+ postMessage(1);
+ setTimeout(f, 0);
+})(); \ No newline at end of file
diff --git a/testing/web-platform/tests/workers/constructors/Worker/undefined b/testing/web-platform/tests/workers/constructors/Worker/undefined
new file mode 100644
index 0000000000..bc7f482e94
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/Worker/undefined
@@ -0,0 +1 @@
+postMessage('undefined');
diff --git a/testing/web-platform/tests/workers/constructors/Worker/undefined.headers b/testing/web-platform/tests/workers/constructors/Worker/undefined.headers
new file mode 100644
index 0000000000..e7ec0d6699
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/Worker/undefined.headers
@@ -0,0 +1 @@
+Content-Type: text/javascript
diff --git a/testing/web-platform/tests/workers/constructors/Worker/unexpected-self-properties.worker.js b/testing/web-platform/tests/workers/constructors/Worker/unexpected-self-properties.worker.js
new file mode 100644
index 0000000000..69d29b2297
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/Worker/unexpected-self-properties.worker.js
@@ -0,0 +1,11 @@
+importScripts("/resources/testharness.js");
+
+var unexpected = ['open', 'print', 'stop', 'getComputedStyle', 'getSelection', 'releaseEvents', 'captureEvents', 'alert', 'confirm', 'prompt', 'addEventStream', 'removeEventStream', 'back', 'forward', 'attachEvent', 'detachEvent', 'navigate', 'DOMParser', 'XMLSerializer', 'XPathEvaluator', 'XSLTProcessor', 'opera', 'Image', 'Option', 'frames', 'Audio', 'SVGUnitTypes', 'SVGZoomAndPan', 'java', 'netscape', 'sun', 'Packages', 'ByteArray', 'closed', 'defaultStatus', 'document', 'event', 'frameElement', 'history', 'innerHeight', 'innerWidth', 'opener', 'outerHeight', 'outerWidth', 'pageXOffset', 'pageYOffset', 'parent', 'screen', 'screenLeft', 'screenTop', 'screenX', 'screenY', 'status', 'top', 'window', 'length']; // iterated window in opera and removed expected ones
+for (var i = 0; i < unexpected.length; ++i) {
+ var property = unexpected[i];
+ test(function() {
+ assert_false(property in self);
+ }, "existence of " + property);
+}
+
+done();
diff --git a/testing/web-platform/tests/workers/constructors/Worker/use-base-url.html b/testing/web-platform/tests/workers/constructors/Worker/use-base-url.html
new file mode 100644
index 0000000000..94ce2a71f1
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/Worker/use-base-url.html
@@ -0,0 +1,18 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>Use the document base url when resolving worker URLs</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<base href="/workers/constructors/Worker/sample_worker/">
+<script>
+ async_test(function(t) {
+ var worker = new Worker('worker.js');
+ var data = "foo";
+ worker.postMessage(data);
+ worker.onmessage = t.step_func_done(function(event) {
+ assert_equals(event.data, data, "event.data does not match expected data");
+ });
+ worker.onerror = t.unreached_func("received error event");
+ }, "Use the document base url when resolving worker URLs");
+</script>