summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/workers
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/workers
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/workers')
-rw-r--r--testing/web-platform/tests/workers/OWNERS6
-rw-r--r--testing/web-platform/tests/workers/README.md8
-rw-r--r--testing/web-platform/tests/workers/WorkerGlobalScope_ErrorEvent_colno.htm18
-rw-r--r--testing/web-platform/tests/workers/WorkerGlobalScope_ErrorEvent_filename.htm20
-rw-r--r--testing/web-platform/tests/workers/WorkerGlobalScope_ErrorEvent_lineno.htm18
-rw-r--r--testing/web-platform/tests/workers/WorkerGlobalScope_ErrorEvent_message.htm19
-rw-r--r--testing/web-platform/tests/workers/WorkerGlobalScope_close.htm17
-rw-r--r--testing/web-platform/tests/workers/WorkerGlobalScope_importScripts.htm14
-rw-r--r--testing/web-platform/tests/workers/WorkerGlobalScope_importScripts_NetworkErr.htm13
-rw-r--r--testing/web-platform/tests/workers/WorkerGlobalScope_setInterval.htm20
-rw-r--r--testing/web-platform/tests/workers/WorkerGlobalScope_setTimeout.htm20
-rw-r--r--testing/web-platform/tests/workers/WorkerLocation.htm15
-rw-r--r--testing/web-platform/tests/workers/WorkerLocation_hash.htm13
-rw-r--r--testing/web-platform/tests/workers/WorkerLocation_hash_encoding.htm13
-rw-r--r--testing/web-platform/tests/workers/WorkerLocation_hash_nonexist.htm13
-rw-r--r--testing/web-platform/tests/workers/WorkerLocation_host.htm13
-rw-r--r--testing/web-platform/tests/workers/WorkerLocation_hostname.htm13
-rw-r--r--testing/web-platform/tests/workers/WorkerLocation_href.htm15
-rw-r--r--testing/web-platform/tests/workers/WorkerLocation_pathname.htm15
-rw-r--r--testing/web-platform/tests/workers/WorkerLocation_port.htm13
-rw-r--r--testing/web-platform/tests/workers/WorkerLocation_protocol.htm13
-rw-r--r--testing/web-platform/tests/workers/WorkerLocation_search.htm13
-rw-r--r--testing/web-platform/tests/workers/WorkerLocation_search_empty.htm13
-rw-r--r--testing/web-platform/tests/workers/WorkerLocation_search_fragment.htm13
-rw-r--r--testing/web-platform/tests/workers/WorkerLocation_search_nonexist.htm13
-rw-r--r--testing/web-platform/tests/workers/WorkerNavigator_appName.htm13
-rw-r--r--testing/web-platform/tests/workers/WorkerNavigator_appVersion.htm13
-rw-r--r--testing/web-platform/tests/workers/WorkerNavigator_onLine.htm13
-rw-r--r--testing/web-platform/tests/workers/WorkerNavigator_platform.htm13
-rw-r--r--testing/web-platform/tests/workers/WorkerNavigator_userAgent.htm13
-rw-r--r--testing/web-platform/tests/workers/Worker_ErrorEvent_bubbles_cancelable.htm22
-rw-r--r--testing/web-platform/tests/workers/Worker_ErrorEvent_error.htm29
-rw-r--r--testing/web-platform/tests/workers/Worker_ErrorEvent_filename.htm20
-rw-r--r--testing/web-platform/tests/workers/Worker_ErrorEvent_lineno.htm18
-rw-r--r--testing/web-platform/tests/workers/Worker_ErrorEvent_message.htm19
-rw-r--r--testing/web-platform/tests/workers/Worker_ErrorEvent_type.htm19
-rw-r--r--testing/web-platform/tests/workers/Worker_basic.htm31
-rw-r--r--testing/web-platform/tests/workers/Worker_cross_origin_security_err.htm17
-rw-r--r--testing/web-platform/tests/workers/Worker_dispatchEvent_ErrorEvent.htm37
-rw-r--r--testing/web-platform/tests/workers/Worker_script_mimetype.htm14
-rw-r--r--testing/web-platform/tests/workers/Worker_terminate_event_queue.htm22
-rw-r--r--testing/web-platform/tests/workers/baseurl/alpha/importScripts.html14
-rw-r--r--testing/web-platform/tests/workers/baseurl/alpha/sharedworker.html14
-rw-r--r--testing/web-platform/tests/workers/baseurl/alpha/worker.html14
-rw-r--r--testing/web-platform/tests/workers/baseurl/alpha/xhr.html14
-rw-r--r--testing/web-platform/tests/workers/baseurl/beta/importScripts.py3
-rw-r--r--testing/web-platform/tests/workers/baseurl/beta/script.js1
-rw-r--r--testing/web-platform/tests/workers/baseurl/beta/sharedworker.py3
-rw-r--r--testing/web-platform/tests/workers/baseurl/beta/subsharedworker.js3
-rw-r--r--testing/web-platform/tests/workers/baseurl/beta/subworker.js1
-rw-r--r--testing/web-platform/tests/workers/baseurl/beta/test.txt1
-rw-r--r--testing/web-platform/tests/workers/baseurl/beta/worker.py3
-rw-r--r--testing/web-platform/tests/workers/baseurl/beta/xhr.py3
-rw-r--r--testing/web-platform/tests/workers/baseurl/gamma/importScripts.js1
-rw-r--r--testing/web-platform/tests/workers/baseurl/gamma/script.js1
-rw-r--r--testing/web-platform/tests/workers/baseurl/gamma/sharedworker.js4
-rw-r--r--testing/web-platform/tests/workers/baseurl/gamma/subsharedworker.js3
-rw-r--r--testing/web-platform/tests/workers/baseurl/gamma/subworker.js1
-rw-r--r--testing/web-platform/tests/workers/baseurl/gamma/test.txt1
-rw-r--r--testing/web-platform/tests/workers/baseurl/gamma/worker.js4
-rw-r--r--testing/web-platform/tests/workers/baseurl/gamma/xhr.js4
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/13
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/URLMismatchError.htm19
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/connect-event.html26
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/dummy-name.html17
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/dummy-shared-worker.html17
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/empty-name.html17
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/global-members.html34
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/interface-objects.html41
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/name.html24
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/no-arguments-ctor.html20
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/null3
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/null-arguments.html25
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/number-arguments.html25
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/port-onmessage.html23
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/port-properties.html26
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/port-readonly.html21
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/same-origin.html67
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/setting-port-members.html59
-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.html25
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/unexpected-global-properties.html30
-rw-r--r--testing/web-platform/tests/workers/constructors/SharedWorker/unresolvable-url.html19
-rw-r--r--testing/web-platform/tests/workers/constructors/Worker/11
-rw-r--r--testing/web-platform/tests/workers/constructors/Worker/AbstractWorker.onerror.html48
-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/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/no-arguments-ctor.html13
-rw-r--r--testing/web-platform/tests/workers/constructors/Worker/null1
-rw-r--r--testing/web-platform/tests/workers/constructors/Worker/resolve-empty-string.html22
-rw-r--r--testing/web-platform/tests/workers/constructors/Worker/same-origin.html63
-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.html44
-rw-r--r--testing/web-platform/tests/workers/constructors/Worker/undefined1
-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/unresolvable-url.html12
-rw-r--r--testing/web-platform/tests/workers/constructors/Worker/use-base-url.html18
-rw-r--r--testing/web-platform/tests/workers/interfaces.idl106
-rw-r--r--testing/web-platform/tests/workers/interfaces.worker.js20
-rw-r--r--testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/EventTarget.worker.js23
-rw-r--r--testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/onmessage.worker.js40
-rw-r--r--testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/event-ports-dedicated.html25
-rw-r--r--testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/imagedata-cloned-canvas-in-array.html39
-rw-r--r--testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/message-event.html23
-rw-r--r--testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/message-event.js1
-rw-r--r--testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/return-value.worker.js8
-rw-r--r--testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/second-argument-null-in-array.html26
-rw-r--r--testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/second-argument-null.html25
-rw-r--r--testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/second-argument-undefined.html25
-rw-r--r--testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/setting-postMessage.html24
-rw-r--r--testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/structured-clone-imagedata.html30
-rw-r--r--testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/structured-clone-message.html58
-rw-r--r--testing/web-platform/tests/workers/interfaces/SharedWorkerGlobalScope/name/getting.html34
-rw-r--r--testing/web-platform/tests/workers/interfaces/SharedWorkerGlobalScope/name/setting.html25
-rw-r--r--testing/web-platform/tests/workers/interfaces/SharedWorkerGlobalScope/onconnect.html39
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/close/incoming-message.html29
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/close/sending-messages.html27
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/close/setInterval.html34
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/close/setTimeout.html28
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/helper-redirect.py3
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/members.html31
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/post-location-members.js8
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/redirect.html28
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/returns-same-object.html21
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/setting-members.html43
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/worker-separate-file.html28
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/onerror/exception-in-onerror.html32
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/onerror/handled.html36
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/onerror/not-handled.html32
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/onerror/propagate-to-window-onerror.html31
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/self.html39
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerUtils/WindowTimers/001.html23
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerUtils/WindowTimers/002.html21
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerUtils/WindowTimers/003.html22
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerUtils/WindowTimers/004.html23
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/001.worker.js7
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/002.worker.js11
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/003.html28
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/004.html34
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/005.html30
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/006.html33
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/007.html25
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/008.html23
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/009.html29
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/010.html34
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/011.html34
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/012.html34
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/11
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/null1
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/undefined1
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/002.html21
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/003.html21
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/004.html21
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/005.html21
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/006.html21
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/007.html30
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/language.html21
-rw-r--r--testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/window-only.worker.js22
-rw-r--r--testing/web-platform/tests/workers/nested_worker.worker.js11
-rw-r--r--testing/web-platform/tests/workers/non-automated/application-cache-dedicated.html21
-rw-r--r--testing/web-platform/tests/workers/non-automated/application-cache-dedicated.js1
-rw-r--r--testing/web-platform/tests/workers/non-automated/cache.manifest3
-rw-r--r--testing/web-platform/tests/workers/non-automated/infinite-nested.html12
-rw-r--r--testing/web-platform/tests/workers/non-automated/infinite-nested.js5
-rw-r--r--testing/web-platform/tests/workers/non-automated/infinite-sibling-and-nested.html12
-rw-r--r--testing/web-platform/tests/workers/non-automated/infinite-sibling-and-nested.js8
-rw-r--r--testing/web-platform/tests/workers/non-automated/infinite-sibling.html12
-rw-r--r--testing/web-platform/tests/workers/non-automated/infinite-sibling.js8
-rw-r--r--testing/web-platform/tests/workers/non-automated/navigator-onLine.html46
-rw-r--r--testing/web-platform/tests/workers/non-automated/post-a-1.js1
-rw-r--r--testing/web-platform/tests/workers/postMessage_DataCloneErr.htm13
-rw-r--r--testing/web-platform/tests/workers/postMessage_clone_port.htm22
-rw-r--r--testing/web-platform/tests/workers/postMessage_clone_port_error.htm14
-rw-r--r--testing/web-platform/tests/workers/postMessage_event_properties.htm24
-rw-r--r--testing/web-platform/tests/workers/postMessage_ports_readonly_array.htm20
-rw-r--r--testing/web-platform/tests/workers/postMessage_target_source.htm18
-rw-r--r--testing/web-platform/tests/workers/semantics/encodings/001.html21
-rw-r--r--testing/web-platform/tests/workers/semantics/encodings/001.html.headers1
-rw-r--r--testing/web-platform/tests/workers/semantics/encodings/002.html23
-rw-r--r--testing/web-platform/tests/workers/semantics/encodings/002.html.headers1
-rw-r--r--testing/web-platform/tests/workers/semantics/encodings/003-1.py4
-rw-r--r--testing/web-platform/tests/workers/semantics/encodings/003.html26
-rw-r--r--testing/web-platform/tests/workers/semantics/encodings/004.html27
-rw-r--r--testing/web-platform/tests/workers/semantics/encodings/004.worker.js5
-rw-r--r--testing/web-platform/tests/workers/semantics/interface-objects/001.worker.js79
-rw-r--r--testing/web-platform/tests/workers/semantics/interface-objects/002.worker.js49
-rw-r--r--testing/web-platform/tests/workers/semantics/interface-objects/003.html106
-rw-r--r--testing/web-platform/tests/workers/semantics/interface-objects/004.html73
-rw-r--r--testing/web-platform/tests/workers/semantics/multiple-workers/001.html41
-rw-r--r--testing/web-platform/tests/workers/semantics/multiple-workers/002.html28
-rw-r--r--testing/web-platform/tests/workers/semantics/multiple-workers/003.html34
-rw-r--r--testing/web-platform/tests/workers/semantics/multiple-workers/004-1.html7
-rw-r--r--testing/web-platform/tests/workers/semantics/multiple-workers/004-2.js6
-rw-r--r--testing/web-platform/tests/workers/semantics/multiple-workers/004.html34
-rw-r--r--testing/web-platform/tests/workers/semantics/multiple-workers/005.html37
-rw-r--r--testing/web-platform/tests/workers/semantics/multiple-workers/006-1.js3
-rw-r--r--testing/web-platform/tests/workers/semantics/multiple-workers/006.html35
-rw-r--r--testing/web-platform/tests/workers/semantics/multiple-workers/007.html39
-rw-r--r--testing/web-platform/tests/workers/semantics/multiple-workers/008-1.html8
-rw-r--r--testing/web-platform/tests/workers/semantics/multiple-workers/008.html31
-rw-r--r--testing/web-platform/tests/workers/semantics/navigation/001-1.html23
-rw-r--r--testing/web-platform/tests/workers/semantics/navigation/001.html36
-rw-r--r--testing/web-platform/tests/workers/semantics/navigation/002.html36
-rw-r--r--testing/web-platform/tests/workers/semantics/reporting-errors/001.html53
-rw-r--r--testing/web-platform/tests/workers/semantics/reporting-errors/002.html59
-rw-r--r--testing/web-platform/tests/workers/semantics/reporting-errors/003.html39
-rw-r--r--testing/web-platform/tests/workers/semantics/reporting-errors/004-1.html18
-rw-r--r--testing/web-platform/tests/workers/semantics/reporting-errors/004.html39
-rw-r--r--testing/web-platform/tests/workers/semantics/run-a-worker/001.html22
-rw-r--r--testing/web-platform/tests/workers/semantics/run-a-worker/002.html24
-rw-r--r--testing/web-platform/tests/workers/semantics/run-a-worker/003.html21
-rw-r--r--testing/web-platform/tests/workers/semantics/structured-clone/common.js596
-rw-r--r--testing/web-platform/tests/workers/semantics/structured-clone/dedicated.html9
-rw-r--r--testing/web-platform/tests/workers/semantics/structured-clone/dedicated.js4
-rw-r--r--testing/web-platform/tests/workers/semantics/structured-clone/shared.html9
-rw-r--r--testing/web-platform/tests/workers/semantics/structured-clone/shared.js6
-rw-r--r--testing/web-platform/tests/workers/semantics/structured-clone/worker-common.js1018
-rw-r--r--testing/web-platform/tests/workers/semantics/xhr/001-1.xml1
-rw-r--r--testing/web-platform/tests/workers/semantics/xhr/001.html35
-rw-r--r--testing/web-platform/tests/workers/semantics/xhr/002.html32
-rw-r--r--testing/web-platform/tests/workers/semantics/xhr/003.html41
-rw-r--r--testing/web-platform/tests/workers/semantics/xhr/004.html36
-rw-r--r--testing/web-platform/tests/workers/semantics/xhr/005.html21
-rw-r--r--testing/web-platform/tests/workers/semantics/xhr/006.html21
-rw-r--r--testing/web-platform/tests/workers/semantics/xhr/support/001-1.xml1
-rw-r--r--testing/web-platform/tests/workers/semantics/xhr/support/005-1.js5
-rw-r--r--testing/web-platform/tests/workers/semantics/xhr/support/006-1.js7
-rw-r--r--testing/web-platform/tests/workers/support/ErrorEvent-error.js9
-rw-r--r--testing/web-platform/tests/workers/support/ErrorEvent.js10
-rw-r--r--testing/web-platform/tests/workers/support/ImportScripts.js9
-rw-r--r--testing/web-platform/tests/workers/support/ImportScriptsNetworkErr.js15
-rw-r--r--testing/web-platform/tests/workers/support/Timer.js50
-rw-r--r--testing/web-platform/tests/workers/support/WorkerBasic.js7
-rw-r--r--testing/web-platform/tests/workers/support/WorkerClose.js5
-rw-r--r--testing/web-platform/tests/workers/support/WorkerDataCloneErr.js15
-rw-r--r--testing/web-platform/tests/workers/support/WorkerLocation.js12
-rw-r--r--testing/web-platform/tests/workers/support/WorkerNavigator.js8
-rw-r--r--testing/web-platform/tests/workers/support/WorkerTerminate.js10
-rw-r--r--testing/web-platform/tests/workers/support/WorkerText.txt2
244 files changed, 6617 insertions, 0 deletions
diff --git a/testing/web-platform/tests/workers/OWNERS b/testing/web-platform/tests/workers/OWNERS
new file mode 100644
index 000000000..d211ea968
--- /dev/null
+++ b/testing/web-platform/tests/workers/OWNERS
@@ -0,0 +1,6 @@
+@zqzhang
+@chunywang
+@zcorpan
+@caitp
+@Ms2ger
+@jdm
diff --git a/testing/web-platform/tests/workers/README.md b/testing/web-platform/tests/workers/README.md
new file mode 100644
index 000000000..3a1c58f3b
--- /dev/null
+++ b/testing/web-platform/tests/workers/README.md
@@ -0,0 +1,8 @@
+This directory contains the Web Workers test suite.
+
+To run this test suite within a browser, go to: <http://w3c-test.org/web-platform-tests/master/workers/>.
+
+The latest Editor's Draft of Web Workers is: <http://dev.w3.org/html5/workers/>.
+
+The latest W3C Technical Report of Web Workers is <http://www.w3.org/TR/workers/>.
+
diff --git a/testing/web-platform/tests/workers/WorkerGlobalScope_ErrorEvent_colno.htm b/testing/web-platform/tests/workers/WorkerGlobalScope_ErrorEvent_colno.htm
new file mode 100644
index 000000000..793d6c180
--- /dev/null
+++ b/testing/web-platform/tests/workers/WorkerGlobalScope_ErrorEvent_colno.htm
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<title> WorkerGlobalScope onerror event handler argument: col </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+// The worker events races with the window's load event; if the worker events
+// arrive first, the harness will detect the error event and fail the test.
+setup({ allow_uncaught_exception: true });
+
+async_test(function(t) {
+ var worker = new Worker('./support/ErrorEvent.js');
+ worker.onmessage = t.step_func_done(function(e) {
+ assert_equals(typeof e.data.colno, "number");
+ });
+ worker.postMessage("Error Message");
+});
+</script>
diff --git a/testing/web-platform/tests/workers/WorkerGlobalScope_ErrorEvent_filename.htm b/testing/web-platform/tests/workers/WorkerGlobalScope_ErrorEvent_filename.htm
new file mode 100644
index 000000000..e165a23f4
--- /dev/null
+++ b/testing/web-platform/tests/workers/WorkerGlobalScope_ErrorEvent_filename.htm
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<title> WorkerGlobalScope onerror event handler argument: location </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+// The worker events races with the window's load event; if the worker events
+// arrive first, the harness will detect the error event and fail the test.
+setup({ allow_uncaught_exception: true });
+
+async_test(function(t) {
+ var worker = new Worker('./support/ErrorEvent.js');
+ worker.onmessage = t.step_func_done(function(e) {
+ var href = location.href;
+ var expected = href.substring(0, href.lastIndexOf('/')) + '/support/ErrorEvent.js';
+ assert_equals(e.data.filename, expected);
+ });
+ worker.postMessage("Error Message");
+});
+</script>
diff --git a/testing/web-platform/tests/workers/WorkerGlobalScope_ErrorEvent_lineno.htm b/testing/web-platform/tests/workers/WorkerGlobalScope_ErrorEvent_lineno.htm
new file mode 100644
index 000000000..dfbc51467
--- /dev/null
+++ b/testing/web-platform/tests/workers/WorkerGlobalScope_ErrorEvent_lineno.htm
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<title> WorkerGlobalScope onerror event handler argument: line </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+// The worker events races with the window's load event; if the worker events
+// arrive first, the harness will detect the error event and fail the test.
+setup({ allow_uncaught_exception: true });
+
+async_test(function(t) {
+ var worker = new Worker('./support/ErrorEvent.js');
+ worker.onmessage = t.step_func_done(function(e) {
+ assert_equals(e.data.lineno, 3);
+ });
+ worker.postMessage("Error Message");
+});
+</script>
diff --git a/testing/web-platform/tests/workers/WorkerGlobalScope_ErrorEvent_message.htm b/testing/web-platform/tests/workers/WorkerGlobalScope_ErrorEvent_message.htm
new file mode 100644
index 000000000..bc1d2c45b
--- /dev/null
+++ b/testing/web-platform/tests/workers/WorkerGlobalScope_ErrorEvent_message.htm
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<title> WorkerGlobalScope onerror event handler argument: message </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+// The worker events races with the window's load event; if the worker events
+// arrive first, the harness will detect the error event and fail the test.
+setup({ allow_uncaught_exception: true });
+
+async_test(function(t) {
+ var message = 'Error Message';
+ var worker = new Worker('./support/ErrorEvent.js');
+ worker.onmessage = t.step_func_done(function(e) {
+ assert_greater_than(e.data.message.indexOf(message), -1);
+ });
+ worker.postMessage(message);
+});
+</script>
diff --git a/testing/web-platform/tests/workers/WorkerGlobalScope_close.htm b/testing/web-platform/tests/workers/WorkerGlobalScope_close.htm
new file mode 100644
index 000000000..2ad5205d1
--- /dev/null
+++ b/testing/web-platform/tests/workers/WorkerGlobalScope_close.htm
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<title> WorkerGlobalScope close(): clear events queue </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var worker = new Worker('./support/WorkerClose.js');
+ worker.onmessage = t.step_func(function(e) {
+ assert_equals(e.data, "ping");
+ worker.onmessage = t.unreached_func("Unexpected message event");
+ worker.postMessage("pong");
+ setTimeout(t.step_func_done(), 100);
+ });
+ worker.postMessage("ping");
+});
+</script>
diff --git a/testing/web-platform/tests/workers/WorkerGlobalScope_importScripts.htm b/testing/web-platform/tests/workers/WorkerGlobalScope_importScripts.htm
new file mode 100644
index 000000000..1a3616df9
--- /dev/null
+++ b/testing/web-platform/tests/workers/WorkerGlobalScope_importScripts.htm
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<title> WorkerGlobalScope API: importScripts() </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var worker = new Worker("./support/ImportScripts.js");
+ worker.onmessage = t.step_func_done(function(e) {
+ assert_equals(e.data, "Pass");
+ });
+ worker.postMessage("ping");
+});
+</script>
diff --git a/testing/web-platform/tests/workers/WorkerGlobalScope_importScripts_NetworkErr.htm b/testing/web-platform/tests/workers/WorkerGlobalScope_importScripts_NetworkErr.htm
new file mode 100644
index 000000000..36fe6e0b2
--- /dev/null
+++ b/testing/web-platform/tests/workers/WorkerGlobalScope_importScripts_NetworkErr.htm
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<title> importScripts() with non-existent script file </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var worker = new Worker("./support/ImportScriptsNetworkErr.js");
+ worker.onmessage = t.step_func_done(function(e) {
+ assert_equals(e.data, "Pass");
+ });
+});
+</script>
diff --git a/testing/web-platform/tests/workers/WorkerGlobalScope_setInterval.htm b/testing/web-platform/tests/workers/WorkerGlobalScope_setInterval.htm
new file mode 100644
index 000000000..4e147fbf6
--- /dev/null
+++ b/testing/web-platform/tests/workers/WorkerGlobalScope_setInterval.htm
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<title> WorkerGlobalScope API: setInterval() </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var result = [];
+ var worker = new Worker('./support/Timer.js');
+ worker.onmessage = t.step_func(function(e) {
+ result.push(e.data);
+ if (result.length == 3) {
+ assert_array_equals(result, ["hello", "worker", "worker"]);
+ worker.onmessage = t.unreached_func('Unexpected message event');
+ setTimeout(t.step_func_done(), 100);
+ }
+ });
+ worker.postMessage("IntervalHandler");
+});
+</script>
diff --git a/testing/web-platform/tests/workers/WorkerGlobalScope_setTimeout.htm b/testing/web-platform/tests/workers/WorkerGlobalScope_setTimeout.htm
new file mode 100644
index 000000000..89fdf3d74
--- /dev/null
+++ b/testing/web-platform/tests/workers/WorkerGlobalScope_setTimeout.htm
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<title> WorkerGlobalScope API: setTimeout() </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var result = [];
+ var worker = new Worker('./support/Timer.js');
+ worker.onmessage = t.step_func(function(e) {
+ result.push(e.data);
+ if (result.length == 3) {
+ assert_array_equals(result, ["hello", "worker", "worker"]);
+ worker.onmessage = t.unreached_func('Unexpected message event');
+ setTimeout(t.step_func_done(), 100);
+ }
+ });
+ worker.postMessage("TimeoutHandler");
+});
+</script>
diff --git a/testing/web-platform/tests/workers/WorkerLocation.htm b/testing/web-platform/tests/workers/WorkerLocation.htm
new file mode 100644
index 000000000..a74f13a8b
--- /dev/null
+++ b/testing/web-platform/tests/workers/WorkerLocation.htm
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<title> WorkerLocation object </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var worker = new Worker('./support/WorkerLocation.js');
+ worker.onmessage = t.step_func_done(function(e) {
+ var href = window.location.href;
+ var ExpectedResult = href.substring(0, href.lastIndexOf('/')) + '/support/WorkerLocation.js';
+ assert_equals(e.data.location, ExpectedResult);
+ });
+});
+</script>
diff --git a/testing/web-platform/tests/workers/WorkerLocation_hash.htm b/testing/web-platform/tests/workers/WorkerLocation_hash.htm
new file mode 100644
index 000000000..74a424efc
--- /dev/null
+++ b/testing/web-platform/tests/workers/WorkerLocation_hash.htm
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<title> WorkerLocation URL decomposition IDL attribute: hash </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var worker = new Worker("./support/WorkerLocation.js#HashString");
+ worker.onmessage = t.step_func_done(function(e) {
+ assert_equals(e.data.hash, "#HashString");
+ });
+});
+</script>
diff --git a/testing/web-platform/tests/workers/WorkerLocation_hash_encoding.htm b/testing/web-platform/tests/workers/WorkerLocation_hash_encoding.htm
new file mode 100644
index 000000000..b2a171a09
--- /dev/null
+++ b/testing/web-platform/tests/workers/WorkerLocation_hash_encoding.htm
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<title> WorkerLocation.hash with url encoding string </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var worker = new Worker("./support/WorkerLocation.js#question%3f");
+ worker.onmessage = t.step_func_done(function(e) {
+ assert_equals(e.data.hash, "#question%3f");
+ });
+});
+</script>
diff --git a/testing/web-platform/tests/workers/WorkerLocation_hash_nonexist.htm b/testing/web-platform/tests/workers/WorkerLocation_hash_nonexist.htm
new file mode 100644
index 000000000..2d898c075
--- /dev/null
+++ b/testing/web-platform/tests/workers/WorkerLocation_hash_nonexist.htm
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<title> WorkerLocation.hash with no &lt;fragment&gt; component </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var worker = new Worker('./support/WorkerLocation.js');
+ worker.onmessage = t.step_func_done(function(e) {
+ assert_equals(e.data.hash, "");
+ });
+});
+</script>
diff --git a/testing/web-platform/tests/workers/WorkerLocation_host.htm b/testing/web-platform/tests/workers/WorkerLocation_host.htm
new file mode 100644
index 000000000..53286ddfc
--- /dev/null
+++ b/testing/web-platform/tests/workers/WorkerLocation_host.htm
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<title> WorkerLocation URL decomposition IDL attribute: host </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var worker = new Worker('./support/WorkerLocation.js');
+ worker.onmessage = t.step_func_done(function(e) {
+ assert_equals(e.data.host, location.host);
+ });
+});
+</script>
diff --git a/testing/web-platform/tests/workers/WorkerLocation_hostname.htm b/testing/web-platform/tests/workers/WorkerLocation_hostname.htm
new file mode 100644
index 000000000..97250805c
--- /dev/null
+++ b/testing/web-platform/tests/workers/WorkerLocation_hostname.htm
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<title> WorkerLocation URL decomposition IDL attribute: hostname </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var worker = new Worker('./support/WorkerLocation.js');
+ worker.onmessage = t.step_func_done(function(e) {
+ assert_equals(e.data.hostname, location.hostname);
+ });
+});
+</script>
diff --git a/testing/web-platform/tests/workers/WorkerLocation_href.htm b/testing/web-platform/tests/workers/WorkerLocation_href.htm
new file mode 100644
index 000000000..3ed1dbd4f
--- /dev/null
+++ b/testing/web-platform/tests/workers/WorkerLocation_href.htm
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<title> WorkerLocation href attribute </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var worker = new Worker("./support/WorkerLocation.js?srch%20#hash");
+ worker.onmessage = t.step_func_done(function(e) {
+ var href = location.href;
+ var expected = href.substring(0, href.lastIndexOf('/')) + "/support/WorkerLocation.js?srch%20#hash";
+ assert_equals(e.data.href, expected);
+ });
+});
+</script>
diff --git a/testing/web-platform/tests/workers/WorkerLocation_pathname.htm b/testing/web-platform/tests/workers/WorkerLocation_pathname.htm
new file mode 100644
index 000000000..346984511
--- /dev/null
+++ b/testing/web-platform/tests/workers/WorkerLocation_pathname.htm
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<title> WorkerLocation URL decomposition IDL attribute: pathname </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var worker = new Worker('./support/WorkerLocation.js');
+ worker.onmessage = t.step_func_done(function(e) {
+ var pathname = location.pathname;
+ var expected = pathname.substring(0, pathname.lastIndexOf('/')) + '/support/WorkerLocation.js';
+ assert_equals(e.data.pathname, expected);
+ });
+});
+</script>
diff --git a/testing/web-platform/tests/workers/WorkerLocation_port.htm b/testing/web-platform/tests/workers/WorkerLocation_port.htm
new file mode 100644
index 000000000..ef86cfacb
--- /dev/null
+++ b/testing/web-platform/tests/workers/WorkerLocation_port.htm
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<title> WorkerLocation URL decomposition IDL attribute: port </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var worker = new Worker('./support/WorkerLocation.js');
+ worker.onmessage = t.step_func_done(function(e) {
+ assert_equals(e.data.port, location.port);
+ });
+});
+</script>
diff --git a/testing/web-platform/tests/workers/WorkerLocation_protocol.htm b/testing/web-platform/tests/workers/WorkerLocation_protocol.htm
new file mode 100644
index 000000000..f792dee51
--- /dev/null
+++ b/testing/web-platform/tests/workers/WorkerLocation_protocol.htm
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<title> WorkerLocation URL decomposition IDL attribute: protocol </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var worker = new Worker('./support/WorkerLocation.js');
+ worker.onmessage = t.step_func_done(function(e) {
+ assert_equals(e.data.protocol, location.protocol);
+ });
+});
+</script>
diff --git a/testing/web-platform/tests/workers/WorkerLocation_search.htm b/testing/web-platform/tests/workers/WorkerLocation_search.htm
new file mode 100644
index 000000000..bc6add876
--- /dev/null
+++ b/testing/web-platform/tests/workers/WorkerLocation_search.htm
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<title> WorkerLocation URL decomposition IDL attribute: search </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var worker = new Worker('./support/WorkerLocation.js?SearchString');
+ worker.onmessage = t.step_func_done(function(e) {
+ assert_equals(e.data.search, '?SearchString');
+ });
+});
+</script>
diff --git a/testing/web-platform/tests/workers/WorkerLocation_search_empty.htm b/testing/web-platform/tests/workers/WorkerLocation_search_empty.htm
new file mode 100644
index 000000000..a32d43091
--- /dev/null
+++ b/testing/web-platform/tests/workers/WorkerLocation_search_empty.htm
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<title> WorkerLocation.search with empty &lt;query&gt; </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var worker = new Worker("./support/WorkerLocation.js?");
+ worker.onmessage = t.step_func_done(function(e) {
+ assert_equals(e.data.search, "");
+ });
+});
+</script>
diff --git a/testing/web-platform/tests/workers/WorkerLocation_search_fragment.htm b/testing/web-platform/tests/workers/WorkerLocation_search_fragment.htm
new file mode 100644
index 000000000..3ec4cffa6
--- /dev/null
+++ b/testing/web-platform/tests/workers/WorkerLocation_search_fragment.htm
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<title> WorkerLocation.search with &lt;fragment&gt; in &lt;query&gt; </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var worker = new Worker('./support/WorkerLocation.js?test#');
+ worker.onmessage = t.step_func_done(function(e) {
+ assert_equals(e.data.search, "?test");
+ });
+});
+</script>
diff --git a/testing/web-platform/tests/workers/WorkerLocation_search_nonexist.htm b/testing/web-platform/tests/workers/WorkerLocation_search_nonexist.htm
new file mode 100644
index 000000000..9907e6473
--- /dev/null
+++ b/testing/web-platform/tests/workers/WorkerLocation_search_nonexist.htm
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<title> WorkerLocation.search with no &lt;query&gt; component </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var worker = new Worker('./support/WorkerLocation.js');
+ worker.onmessage = t.step_func_done(function(e) {
+ assert_equals(e.data.search, "");
+ });
+});
+</script>
diff --git a/testing/web-platform/tests/workers/WorkerNavigator_appName.htm b/testing/web-platform/tests/workers/WorkerNavigator_appName.htm
new file mode 100644
index 000000000..832c46ff5
--- /dev/null
+++ b/testing/web-platform/tests/workers/WorkerNavigator_appName.htm
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<title> WorkerNavigator appName </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var worker = new Worker("./support/WorkerNavigator.js");
+ worker.onmessage = t.step_func_done(function(e) {
+ assert_equals(e.data.appName, navigator.appName);
+ });
+});
+</script>
diff --git a/testing/web-platform/tests/workers/WorkerNavigator_appVersion.htm b/testing/web-platform/tests/workers/WorkerNavigator_appVersion.htm
new file mode 100644
index 000000000..7deaa4256
--- /dev/null
+++ b/testing/web-platform/tests/workers/WorkerNavigator_appVersion.htm
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<title> WorkerNavigator appVersion </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var worker = new Worker("./support/WorkerNavigator.js");
+ worker.onmessage = t.step_func_done(function(e) {
+ assert_equals(e.data.appVersion, navigator.appVersion);
+ });
+});
+</script>
diff --git a/testing/web-platform/tests/workers/WorkerNavigator_onLine.htm b/testing/web-platform/tests/workers/WorkerNavigator_onLine.htm
new file mode 100644
index 000000000..f9e819b8a
--- /dev/null
+++ b/testing/web-platform/tests/workers/WorkerNavigator_onLine.htm
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<title> WorkerNavigator.onLine </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var worker = new Worker("./support/WorkerNavigator.js");
+ worker.onmessage = t.step_func_done(function(e) {
+ assert_equals(e.data.onLine, navigator.onLine);
+ });
+});
+</script>
diff --git a/testing/web-platform/tests/workers/WorkerNavigator_platform.htm b/testing/web-platform/tests/workers/WorkerNavigator_platform.htm
new file mode 100644
index 000000000..3a6de80eb
--- /dev/null
+++ b/testing/web-platform/tests/workers/WorkerNavigator_platform.htm
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<title> WorkerNavigator.platform </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var worker = new Worker("./support/WorkerNavigator.js");
+ worker.onmessage = t.step_func_done(function(e) {
+ assert_equals(e.data.platform, navigator.platform);
+ });
+});
+</script>
diff --git a/testing/web-platform/tests/workers/WorkerNavigator_userAgent.htm b/testing/web-platform/tests/workers/WorkerNavigator_userAgent.htm
new file mode 100644
index 000000000..8a34fb480
--- /dev/null
+++ b/testing/web-platform/tests/workers/WorkerNavigator_userAgent.htm
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<title> WorkerNavigator.userAgent </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var worker = new Worker("./support/WorkerNavigator.js");
+ worker.onmessage = t.step_func_done(function(e) {
+ assert_equals(e.data.userAgent, navigator.userAgent);
+ });
+});
+</script>
diff --git a/testing/web-platform/tests/workers/Worker_ErrorEvent_bubbles_cancelable.htm b/testing/web-platform/tests/workers/Worker_ErrorEvent_bubbles_cancelable.htm
new file mode 100644
index 000000000..4619ee7b5
--- /dev/null
+++ b/testing/web-platform/tests/workers/Worker_ErrorEvent_bubbles_cancelable.htm
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Web Workers: Worker ErrorEvent - bubbles, cancelable</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>
+// The worker events races with the window's load event; if the worker events
+// arrive first, the harness will detect the error event and fail the test.
+setup({ allow_uncaught_exception: true });
+
+async_test(function(t) {
+ var worker = new Worker('./support/ErrorEvent.js');
+ worker.onerror = t.step_func_done(function(e) {
+ assert_false(e.bubbles, "onerror on worker doesn't bubble");
+ assert_true(e.cancelable, "onerror on worker is cancelable");
+ });
+ worker.postMessage("Error Message");
+}, "ErrorEvent on worker doesn't bubble and is cancelable");
+
+</script>
diff --git a/testing/web-platform/tests/workers/Worker_ErrorEvent_error.htm b/testing/web-platform/tests/workers/Worker_ErrorEvent_error.htm
new file mode 100644
index 000000000..1c1257d1b
--- /dev/null
+++ b/testing/web-platform/tests/workers/Worker_ErrorEvent_error.htm
@@ -0,0 +1,29 @@
+<!doctype html>
+<meta charset=utf-8>
+<title></title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script>
+var t1 = async_test("Error handler outside the worker should not see the error value");
+var t2 = async_test("Error handlers inside a worker should see the error value");
+
+test(function() {
+ var worker = new Worker("support/ErrorEvent-error.js");
+ worker.onerror = t1.step_func_done(function(e) {
+ assert_true(/hello/.test(e.message));
+ assert_equals(e.error, null);
+ });
+
+ var messages = 0;
+ worker.onmessage = t2.step_func(function(e) {
+ ++messages;
+ var data = e.data;
+ assert_true(data.source == "onerror" ||
+ data.source == "event listener");
+ assert_equals(data.value, "hello");
+ if (messages == 2) {
+ t2.done();
+ }
+ });
+});
+</script>
diff --git a/testing/web-platform/tests/workers/Worker_ErrorEvent_filename.htm b/testing/web-platform/tests/workers/Worker_ErrorEvent_filename.htm
new file mode 100644
index 000000000..0faef6fea
--- /dev/null
+++ b/testing/web-platform/tests/workers/Worker_ErrorEvent_filename.htm
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<title> AbstractWorker ErrorEvent.filename </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+// The worker events races with the window's load event; if the worker events
+// arrive first, the harness will detect the error event and fail the test.
+setup({ allow_uncaught_exception: true });
+
+async_test(function(t) {
+ var worker = new Worker('./support/ErrorEvent.js');
+ worker.onerror = t.step_func_done(function(e) {
+ var href = location.href;
+ var expected = href.substring(0, href.lastIndexOf('/')) + '/support/ErrorEvent.js';
+ assert_equals(e.filename, expected);
+ });
+ worker.postMessage("Error Message");
+});
+</script>
diff --git a/testing/web-platform/tests/workers/Worker_ErrorEvent_lineno.htm b/testing/web-platform/tests/workers/Worker_ErrorEvent_lineno.htm
new file mode 100644
index 000000000..ad9817296
--- /dev/null
+++ b/testing/web-platform/tests/workers/Worker_ErrorEvent_lineno.htm
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<title> AbstractWorker ErrorEvent.lineno </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+// The worker events races with the window's load event; if the worker events
+// arrive first, the harness will detect the error event and fail the test.
+setup({ allow_uncaught_exception: true });
+
+async_test(function(t) {
+ var worker = new Worker('./support/ErrorEvent.js');
+ worker.onerror = t.step_func_done(function(e) {
+ assert_equals(e.lineno, 3);
+ });
+ worker.postMessage("Error Message");
+});
+</script>
diff --git a/testing/web-platform/tests/workers/Worker_ErrorEvent_message.htm b/testing/web-platform/tests/workers/Worker_ErrorEvent_message.htm
new file mode 100644
index 000000000..5602d9bc0
--- /dev/null
+++ b/testing/web-platform/tests/workers/Worker_ErrorEvent_message.htm
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<title> AbstractWorker ErrorEvent.message </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+// The worker events races with the window's load event; if the worker events
+// arrive first, the harness will detect the error event and fail the test.
+setup({ allow_uncaught_exception: true });
+
+async_test(function(t) {
+ var message = 'Error Message';
+ var worker = new Worker('./support/ErrorEvent.js');
+ worker.onerror = t.step_func_done(function(e) {
+ assert_greater_than(e.message.indexOf(message), -1);
+ });
+ worker.postMessage(message);
+});
+</script>
diff --git a/testing/web-platform/tests/workers/Worker_ErrorEvent_type.htm b/testing/web-platform/tests/workers/Worker_ErrorEvent_type.htm
new file mode 100644
index 000000000..3a0f85ad9
--- /dev/null
+++ b/testing/web-platform/tests/workers/Worker_ErrorEvent_type.htm
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<title> AbstractWorker ErrorEvent.type </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+// The worker events races with the window's load event; if the worker events
+// arrive first, the harness will detect the error event and fail the test.
+setup({ allow_uncaught_exception: true });
+
+async_test(function(t) {
+ var worker = new Worker('./support/ErrorEvent.js');
+ worker.onerror = t.step_func_done(function(e) {
+ assert_class_string(e, 'ErrorEvent');
+ assert_equals(e.type, 'error');
+ });
+ worker.postMessage("Error Message");
+});
+</script>
diff --git a/testing/web-platform/tests/workers/Worker_basic.htm b/testing/web-platform/tests/workers/Worker_basic.htm
new file mode 100644
index 000000000..d2b57b491
--- /dev/null
+++ b/testing/web-platform/tests/workers/Worker_basic.htm
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<title> Web Workers Basic Tests </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+function create_worker() {
+ return new Worker('./support/WorkerBasic.js');
+}
+
+test(function() {
+ var worker = create_worker();
+ assert_class_string(worker, "Worker");
+}, "Worker constructor");
+
+async_test(function(t) {
+ var worker = create_worker();
+ worker.onmessage = t.step_func_done(function(e) {
+ assert_equals(e.data, "Pass");
+ });
+ worker.postMessage("start");
+}, "MessageEvent.data");
+
+async_test(function(t) {
+ var worker = create_worker();
+ worker.addEventListener("message", t.step_func_done(function(e) {
+ assert_equals(e.type, "message");
+ }), true);
+ worker.postMessage("start");
+}, "MessageEvent.type");
+</script>
diff --git a/testing/web-platform/tests/workers/Worker_cross_origin_security_err.htm b/testing/web-platform/tests/workers/Worker_cross_origin_security_err.htm
new file mode 100644
index 000000000..647a8b81e
--- /dev/null
+++ b/testing/web-platform/tests/workers/Worker_cross_origin_security_err.htm
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<title> Worker cross-origin URL </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function(t) {
+ try {
+ var w = new Worker("ftp://example.org/support/WorkerBasic.js");
+ w.onerror = t.step_func_done(function(e) {
+ assert_true(e instanceof ErrorEvent);
+ });
+ } catch (e) {
+ t.step_func_done(function(e) { assert_true(true); });
+ }
+});
+</script>
diff --git a/testing/web-platform/tests/workers/Worker_dispatchEvent_ErrorEvent.htm b/testing/web-platform/tests/workers/Worker_dispatchEvent_ErrorEvent.htm
new file mode 100644
index 000000000..aea7e025c
--- /dev/null
+++ b/testing/web-platform/tests/workers/Worker_dispatchEvent_ErrorEvent.htm
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<title> ErrorEvent and Worker.dispatchEvent() </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var event = "error";
+ var filename = './support/ErrorEvent.js';
+ var message = 'Hello Worker';
+ var lineno = 5;
+ var colno = 6;
+ var error = new Error("test");
+ var worker = new Worker(filename);
+ worker.addEventListener(event, t.step_func_done(function(e) {
+ assert_equals(e.type, event, 'type');
+ assert_equals(e.message, message, 'message');
+ assert_equals(e.filename, filename, 'filename');
+ assert_equals(e.lineno, lineno, 'lineno');
+ assert_equals(e.colno, colno, 'colno');
+ assert_equals(e.error, error, 'error');
+ }), true);
+ var e = new ErrorEvent(event, {bubbles:true, cancelable:true, message:message, filename:filename, lineno:lineno, colno:colno, error:error});
+ worker.dispatchEvent(e);
+});
+
+test(function() {
+ var e = document.createEvent("ErrorEvent");
+ var eProto = Object.getPrototypeOf(e);
+ assert_equals(eProto, ErrorEvent.prototype);
+}, "document.createEvent('ErrorEvent')");
+
+test(function() {
+ var e = new ErrorEvent("error");
+ assert_false("initErrorEvent" in e, "should not be supported");
+}, "initErrorEvent");
+</script>
diff --git a/testing/web-platform/tests/workers/Worker_script_mimetype.htm b/testing/web-platform/tests/workers/Worker_script_mimetype.htm
new file mode 100644
index 000000000..04fe68e66
--- /dev/null
+++ b/testing/web-platform/tests/workers/Worker_script_mimetype.htm
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<title> Worker constructor with script inside text file </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var worker = new Worker('./support/WorkerText.txt');
+ worker.onmessage = t.step_func_done(function(e) {
+ assert_equals(e.data, "Pass");
+ });
+ worker.postMessage("start");
+});
+</script>
diff --git a/testing/web-platform/tests/workers/Worker_terminate_event_queue.htm b/testing/web-platform/tests/workers/Worker_terminate_event_queue.htm
new file mode 100644
index 000000000..5d9472a1c
--- /dev/null
+++ b/testing/web-platform/tests/workers/Worker_terminate_event_queue.htm
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<title> AbstractWorker terminate(): clear event queue </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function() {
+ var testResult;
+ var worker = new Worker('./support/WorkerTerminate.js');
+ worker.onmessage = this.step_func(function(e) {
+ testResult = e.data;
+ if (testResult >= 10000) {
+ worker.terminate();
+ worker.onmessage = this.unreached_func('Unexpected message event');
+ setTimeout(this.step_func_done(function() {
+ assert_equals(testResult, 10000);
+ }), 100);
+ }
+ });
+ worker.postMessage("ping");
+});
+</script>
diff --git a/testing/web-platform/tests/workers/baseurl/alpha/importScripts.html b/testing/web-platform/tests/workers/baseurl/alpha/importScripts.html
new file mode 100644
index 000000000..0fbd35b44
--- /dev/null
+++ b/testing/web-platform/tests/workers/baseurl/alpha/importScripts.html
@@ -0,0 +1,14 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>Base URL in workers: importScripts</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+async_test(function() {
+ var worker = new Worker("../beta/importScripts.py");
+ worker.onmessage = this.step_func_done(function(e) {
+ assert_equals(e.data, "gamma");
+ });
+ worker.onerror = this.unreached_func("Got error event");
+});
+</script>
diff --git a/testing/web-platform/tests/workers/baseurl/alpha/sharedworker.html b/testing/web-platform/tests/workers/baseurl/alpha/sharedworker.html
new file mode 100644
index 000000000..25d258236
--- /dev/null
+++ b/testing/web-platform/tests/workers/baseurl/alpha/sharedworker.html
@@ -0,0 +1,14 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>Base URL in workers: new SharedWorker()</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+async_test(function() {
+ var worker = new Worker("../beta/sharedworker.py");
+ worker.onmessage = this.step_func_done(function(e) {
+ assert_equals(e.data, "gamma");
+ });
+ worker.onerror = this.unreached_func("Got error event");
+});
+</script>
diff --git a/testing/web-platform/tests/workers/baseurl/alpha/worker.html b/testing/web-platform/tests/workers/baseurl/alpha/worker.html
new file mode 100644
index 000000000..284425ed3
--- /dev/null
+++ b/testing/web-platform/tests/workers/baseurl/alpha/worker.html
@@ -0,0 +1,14 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>Base URL in workers: new Worker()</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+async_test(function() {
+ var worker = new Worker("../beta/worker.py");
+ worker.onmessage = this.step_func_done(function(e) {
+ assert_equals(e.data, "gamma");
+ });
+ worker.onerror = this.unreached_func("Got error event");
+});
+</script>
diff --git a/testing/web-platform/tests/workers/baseurl/alpha/xhr.html b/testing/web-platform/tests/workers/baseurl/alpha/xhr.html
new file mode 100644
index 000000000..9a1219b45
--- /dev/null
+++ b/testing/web-platform/tests/workers/baseurl/alpha/xhr.html
@@ -0,0 +1,14 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>Base URL in workers: XHR</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+async_test(function() {
+ var worker = new Worker("../beta/xhr.py");
+ worker.onmessage = this.step_func_done(function(e) {
+ assert_equals(e.data, "gamma\n");
+ });
+ worker.onerror = this.unreached_func("Got error event");
+});
+</script>
diff --git a/testing/web-platform/tests/workers/baseurl/beta/importScripts.py b/testing/web-platform/tests/workers/baseurl/beta/importScripts.py
new file mode 100644
index 000000000..75dac194f
--- /dev/null
+++ b/testing/web-platform/tests/workers/baseurl/beta/importScripts.py
@@ -0,0 +1,3 @@
+def main(request, response):
+ return (302, "Moved"), [("Location", "../gamma/importScripts.js")], "postMessage('executed redirecting script');"
+
diff --git a/testing/web-platform/tests/workers/baseurl/beta/script.js b/testing/web-platform/tests/workers/baseurl/beta/script.js
new file mode 100644
index 000000000..8fe3dfc13
--- /dev/null
+++ b/testing/web-platform/tests/workers/baseurl/beta/script.js
@@ -0,0 +1 @@
+postMessage('beta');
diff --git a/testing/web-platform/tests/workers/baseurl/beta/sharedworker.py b/testing/web-platform/tests/workers/baseurl/beta/sharedworker.py
new file mode 100644
index 000000000..875cc9a04
--- /dev/null
+++ b/testing/web-platform/tests/workers/baseurl/beta/sharedworker.py
@@ -0,0 +1,3 @@
+def main(request, response):
+ return (302, "Moved"), [("Location", "../gamma/sharedworker.js")], "postMessage('executed redirecting script');"
+
diff --git a/testing/web-platform/tests/workers/baseurl/beta/subsharedworker.js b/testing/web-platform/tests/workers/baseurl/beta/subsharedworker.js
new file mode 100644
index 000000000..de6a8caca
--- /dev/null
+++ b/testing/web-platform/tests/workers/baseurl/beta/subsharedworker.js
@@ -0,0 +1,3 @@
+onconnect = function(e) {
+ e.source.postMessage('beta');
+}
diff --git a/testing/web-platform/tests/workers/baseurl/beta/subworker.js b/testing/web-platform/tests/workers/baseurl/beta/subworker.js
new file mode 100644
index 000000000..997cecd6c
--- /dev/null
+++ b/testing/web-platform/tests/workers/baseurl/beta/subworker.js
@@ -0,0 +1 @@
+postMessage("beta");
diff --git a/testing/web-platform/tests/workers/baseurl/beta/test.txt b/testing/web-platform/tests/workers/baseurl/beta/test.txt
new file mode 100644
index 000000000..65b2df87f
--- /dev/null
+++ b/testing/web-platform/tests/workers/baseurl/beta/test.txt
@@ -0,0 +1 @@
+beta
diff --git a/testing/web-platform/tests/workers/baseurl/beta/worker.py b/testing/web-platform/tests/workers/baseurl/beta/worker.py
new file mode 100644
index 000000000..44baf5203
--- /dev/null
+++ b/testing/web-platform/tests/workers/baseurl/beta/worker.py
@@ -0,0 +1,3 @@
+def main(request, response):
+ return (302, "Moved"), [("Location", "../gamma/worker.js")], "postMessage('executed redirecting script');"
+
diff --git a/testing/web-platform/tests/workers/baseurl/beta/xhr.py b/testing/web-platform/tests/workers/baseurl/beta/xhr.py
new file mode 100644
index 000000000..de3f04ed0
--- /dev/null
+++ b/testing/web-platform/tests/workers/baseurl/beta/xhr.py
@@ -0,0 +1,3 @@
+def main(request, response):
+ return (302, "Moved"), [("Location", "../gamma/xhr.js")], "postMessage('executed redirecting script');"
+
diff --git a/testing/web-platform/tests/workers/baseurl/gamma/importScripts.js b/testing/web-platform/tests/workers/baseurl/gamma/importScripts.js
new file mode 100644
index 000000000..3f7685645
--- /dev/null
+++ b/testing/web-platform/tests/workers/baseurl/gamma/importScripts.js
@@ -0,0 +1 @@
+importScripts("script.js");
diff --git a/testing/web-platform/tests/workers/baseurl/gamma/script.js b/testing/web-platform/tests/workers/baseurl/gamma/script.js
new file mode 100644
index 000000000..dddf2240c
--- /dev/null
+++ b/testing/web-platform/tests/workers/baseurl/gamma/script.js
@@ -0,0 +1 @@
+postMessage('gamma');
diff --git a/testing/web-platform/tests/workers/baseurl/gamma/sharedworker.js b/testing/web-platform/tests/workers/baseurl/gamma/sharedworker.js
new file mode 100644
index 000000000..d0718cfde
--- /dev/null
+++ b/testing/web-platform/tests/workers/baseurl/gamma/sharedworker.js
@@ -0,0 +1,4 @@
+var worker = new SharedWorker("subsharedworker.js");
+worker.port.onmessage = function(e) {
+ postMessage(e.data);
+}
diff --git a/testing/web-platform/tests/workers/baseurl/gamma/subsharedworker.js b/testing/web-platform/tests/workers/baseurl/gamma/subsharedworker.js
new file mode 100644
index 000000000..e23602ff9
--- /dev/null
+++ b/testing/web-platform/tests/workers/baseurl/gamma/subsharedworker.js
@@ -0,0 +1,3 @@
+onconnect = function(e) {
+ e.source.postMessage('gamma');
+}
diff --git a/testing/web-platform/tests/workers/baseurl/gamma/subworker.js b/testing/web-platform/tests/workers/baseurl/gamma/subworker.js
new file mode 100644
index 000000000..44407358e
--- /dev/null
+++ b/testing/web-platform/tests/workers/baseurl/gamma/subworker.js
@@ -0,0 +1 @@
+postMessage("gamma");
diff --git a/testing/web-platform/tests/workers/baseurl/gamma/test.txt b/testing/web-platform/tests/workers/baseurl/gamma/test.txt
new file mode 100644
index 000000000..af17f6cc8
--- /dev/null
+++ b/testing/web-platform/tests/workers/baseurl/gamma/test.txt
@@ -0,0 +1 @@
+gamma
diff --git a/testing/web-platform/tests/workers/baseurl/gamma/worker.js b/testing/web-platform/tests/workers/baseurl/gamma/worker.js
new file mode 100644
index 000000000..8cfbcaef3
--- /dev/null
+++ b/testing/web-platform/tests/workers/baseurl/gamma/worker.js
@@ -0,0 +1,4 @@
+var worker = new Worker("subworker.js");
+worker.onmessage = function(e) {
+ postMessage(e.data);
+}
diff --git a/testing/web-platform/tests/workers/baseurl/gamma/xhr.js b/testing/web-platform/tests/workers/baseurl/gamma/xhr.js
new file mode 100644
index 000000000..70f331565
--- /dev/null
+++ b/testing/web-platform/tests/workers/baseurl/gamma/xhr.js
@@ -0,0 +1,4 @@
+var x = new XMLHttpRequest();
+x.open("GET", "test.txt", false);
+x.send();
+postMessage(x.response);
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 000000000..c3f67beea
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/1
@@ -0,0 +1,3 @@
+onconnect = function(e) {
+ e.ports[0].postMessage(['1', self.name]);
+} \ No newline at end of file
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 000000000..e74e66072
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/URLMismatchError.htm
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Web Workers: SharedWorker - throw URLMismatchError</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>
+
+ test(function() {
+ var worker = new SharedWorker('shared-worker.js', 'name');
+
+ assert_throws("URLMismatchError", function() {
+ new SharedWorker('some-other-url.js', 'name');
+ });
+
+ }, "Create SharedWorker with different URLs but same name");
+
+</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 000000000..a9719d9de
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/connect-event.html
@@ -0,0 +1,26 @@
+<!--
+onconnect = function(e) {
+ e.ports[0].postMessage([e.data === '', e instanceof MessageEvent, e.ports.length == 1]);
+};
+/*
+-->
+<!doctype html>
+<title>connect event</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+(async_test()).step(function() {
+ var worker = new SharedWorker('#');
+ worker.port.addEventListener('message', this.step_func(function(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");
+ this.done();
+ }), false);
+ worker.port.start();
+});
+</script>
+<!--
+*/
+//-->
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 000000000..9e2732923
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/dummy-name.html
@@ -0,0 +1,17 @@
+<!--
+/*
+-->
+<!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>
+<div id="log"></div>
+<script>
+test(function() {
+ var worker = new SharedWorker('#', '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 000000000..e9aff9c5b
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/dummy-shared-worker.html
@@ -0,0 +1,17 @@
+<!--
+/*
+-->
+<!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>
+<div id="log"></div>
+<script>
+test(function() {
+ var worker = new SharedWorker('#');
+});
+</script>
+<!--
+*/
+//-->
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 000000000..95ff6d1ad
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/empty-name.html
@@ -0,0 +1,17 @@
+<!--
+/*
+-->
+<!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>
+<div id="log"></div>
+<script>
+test(function() {
+ var worker = new SharedWorker('#', '');
+});
+</script>
+<!--
+*/
+//-->
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 000000000..af4eb1d45
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/global-members.html
@@ -0,0 +1,34 @@
+<!--
+var expected = 'self location close onerror importScripts navigator addEventListener removeEventListener dispatchEvent name applicationCache onconnect setTimeout clearTimeout setInterval clearInterval'.split(' ');
+var log = '';
+for (var i = 0; i < expected.length; ++i) {
+ if (!(expected[i] in self))
+ log += expected[i] + ' did not exist\n';
+}
+onconnect = function(e) {
+ e.ports[0].postMessage(log);
+};
+/*
+-->
+<!doctype html>
+<title>members of SharedWorkerGlobalScope</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+(async_test()).step(function() {
+ var worker = new SharedWorker('#');
+ worker.port.addEventListener('message', this.step_func(function(e) {
+ assert_equals(e.data, '');
+ this.done();
+ }), false);
+ worker.port.start();
+});
+</script>
+<!--
+*/
+//-->
+
+
+
+
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 000000000..e91b2dc6a
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/interface-objects.html
@@ -0,0 +1,41 @@
+<!--
+var prt;
+function handleCall(e) {
+ var log = [];
+ for (var 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 = function(e) {
+ prt = e.ports[0];
+ prt.onmessage = handleCall;
+};
+/*
+-->
+<!doctype html>
+<title>expected interface objects/constructors</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+(async_test()).step(function() {
+ var expected = 'XMLHttpRequest WebSocket EventSource MessageChannel Worker SharedWorker ApplicationCache'.split(' ');
+ var supported = [];
+ for (var i = 0; i < expected.length; ++i) {
+ if (expected[i] in window)
+ supported.push(expected[i]);
+ }
+ var worker = new SharedWorker('#');
+ worker.port.start();
+ worker.port.postMessage(supported);
+ worker.port.addEventListener('message', this.step_func(function(e) {
+ assert_equals(e.data, '');
+ this.done();
+ }), false);
+});
+</script>
+<!--
+*/
+//-->
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 000000000..823e16c7c
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/name.html
@@ -0,0 +1,24 @@
+<!--
+onconnect = function(e) {
+ e.ports[0].postMessage(self.name);
+}
+/*
+-->
+<!doctype html>
+<title>self.name</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+(async_test()).step(function() {
+ var worker = new SharedWorker('#', 'hello');
+ worker.port.addEventListener('message', this.step_func(function(e) {
+ assert_equals(e.data, 'hello');
+ this.done();
+ }), false);
+ worker.port.start();
+});
+</script>
+<!--
+*/
+//--> \ No newline at end of file
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 000000000..eaee870db
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/no-arguments-ctor.html
@@ -0,0 +1,20 @@
+<!--
+/*
+-->
+<!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>
+<div id="log"></div>
+<script>
+test(function() {
+ assert_throws(new TypeError(), function() {
+ var 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 000000000..5c38505b6
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/null
@@ -0,0 +1,3 @@
+onconnect = function(e) {
+ e.ports[0].postMessage(['null', self.name]);
+} \ No newline at end of file
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 000000000..c711b2cb5
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/null-arguments.html
@@ -0,0 +1,25 @@
+<!--
+onconnect = function(e) {
+ e.ports[0].postMessage(['FAIL', self.name]);
+}
+/*
+-->
+<!doctype html>
+<title>null as arguments</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+(async_test()).step(function() {
+ var worker = new SharedWorker(null, null);
+ worker.port.addEventListener('message', this.step_func(function(e) {
+ assert_equals(e.data[0], 'null', 'first arg');
+ assert_equals(e.data[1], 'null', 'second arg');
+ this.done();
+ }), false);
+ worker.port.start();
+});
+</script>
+<!--
+*/
+//--> \ No newline at end of file
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 000000000..1a4cfb2ea
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/number-arguments.html
@@ -0,0 +1,25 @@
+<!--
+onconnect = function(e) {
+ e.ports[0].postMessage(['FAIL', self.name]);
+}
+/*
+-->
+<!doctype html>
+<title>1 as arguments</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+(async_test()).step(function() {
+ var worker = new SharedWorker(1, 1);
+ worker.port.addEventListener('message', this.step_func(function(e) {
+ assert_equals(e.data[0], '1', 'first arg');
+ assert_equals(e.data[1], '1', 'second arg');
+ this.done();
+ }), false);
+ worker.port.start();
+});
+</script>
+<!--
+*/
+//--> \ No newline at end of file
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 000000000..a2f4df0bf
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/port-onmessage.html
@@ -0,0 +1,23 @@
+<!--
+onconnect = function(e) {
+ e.ports[0].postMessage(true);
+}
+/*
+-->
+<!doctype html>
+<title>worker.port.onmessage</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+(async_test()).step(function() {
+ var worker = new SharedWorker('#', '');
+ worker.port.onmessage = this.step_func(function(e) {
+ assert_true(e.data);
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//-->
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 000000000..f8a676dd2
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/port-properties.html
@@ -0,0 +1,26 @@
+<!--
+/*
+-->
+<!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>
+<div id="log"></div>
+<script>
+test(function() {
+ var worker = new SharedWorker('#', '');
+ 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 000000000..f087ab0f6
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/port-readonly.html
@@ -0,0 +1,21 @@
+<!--
+/*
+-->
+<!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>
+<div id="log"></div>
+<script>
+test(function() {
+ var worker = new SharedWorker('#', '');
+ var 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 000000000..2e0dd8db3
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/same-origin.html
@@ -0,0 +1,67 @@
+<!--
+/*
+-->
+<!doctype html>
+<title>same-origin checks</title>
+<link rel=help href="http://www.whatwg.org/html/#dom-sharedworker">
+<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 testSharedWorkerHelper(t, script) {
+ try {
+ var worker = new SharedWorker(script, '');
+ worker.onerror = t.step_func_done(function(e) {
+ assert_true(e instanceof ErrorEvent);
+ });
+ } catch (e) {
+ t.step_func_done(function(e) { assert_true(true); });
+ }
+}
+
+test(function() {
+ assert_throws("SecurityError", function() { new SharedWorker('unsupported:', ''); });
+}, "unsupported_scheme");
+
+async_test(function() {
+ var worker = new SharedWorker('data:,onconnect = function(e) { e.ports[0].postMessage(1); }', '');
+ worker.port.onmessage = this.step_func_done(function(e) {
+ assert_equals(e.data, 1);
+ });
+}, "data_url");
+
+async_test(function(t) {
+ testSharedWorkerHelper(this, 'javascript:""');
+}, "javascript_url");
+
+async_test(function(t) {
+ testSharedWorkerHelper(this, 'about:blank');
+}, "about_blank");
+
+async_test(function(t) {
+ testSharedWorkerHelper(this, 'http://www.opera.com/');
+}, "opera_com");
+
+async_test(function(t) {
+ testSharedWorkerHelper(this, location.protocol+'//'+location.hostname+':81/');
+}, "port_81");
+
+async_test(function(t) {
+ testSharedWorkerHelper(this, 'https://'+location.hostname+':80/');
+}, "https_port_80");
+
+async_test(function(t) {
+ testSharedWorkerHelper(this, 'https://'+location.hostname+':8000/');
+}, "https_port_8000");
+
+async_test(function(t) {
+ testSharedWorkerHelper(this, '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 000000000..8c79ff295
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/setting-port-members.html
@@ -0,0 +1,59 @@
+<!--
+/*
+-->
+<!doctype html>
+<title>setting members of worker.port</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+setup(function() {
+ window.worker = new SharedWorker('#', '');
+});
+test(function() {
+ worker.port.postMessage = 1;
+ assert_equals(worker.port.postMessage, 1);
+}, 'postMessage');
+test(function() {
+ worker.port.start = 1;
+ assert_equals(worker.port.start, 1);
+}, 'start');
+test(function() {
+ worker.port.close = 1;
+ assert_equals(worker.port.close, 1);
+}, 'close');
+test(function() {
+ var f = function(){};
+ worker.port.onmessage = f;
+ assert_equals(worker.port.onmessage, f, 'function(){}');
+ 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;
+ worker.port.onmessage = {handleEvent:function(){}};
+ assert_equals(worker.port.onmessage, null, '{handleEvent:function(){}}');
+ 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(function() {
+ worker.port.addEventListener = 1;
+ assert_equals(worker.port.addEventListener, 1);
+}, 'addEventListener');
+test(function() {
+ worker.port.removeEventListener = 1;
+ assert_equals(worker.port.removeEventListener, 1);
+}, 'removeEventListener');
+test(function() {
+ 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 000000000..babebb1ce
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/shared-worker.js
@@ -0,0 +1,6 @@
+onconnect = function(e) {
+ var port = e.ports[0];
+ port.onmessage = function(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 000000000..3fe840d30
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/undefined
@@ -0,0 +1,3 @@
+onconnect = function(e) {
+ e.ports[0].postMessage(['undefined', self.name]);
+} \ No newline at end of file
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 000000000..b9a3b3692
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/undefined-arguments.html
@@ -0,0 +1,25 @@
+<!--
+onconnect = function(e) {
+ e.ports[0].postMessage(['FAIL', self.name]);
+}
+/*
+-->
+<!doctype html>
+<title>undefined as arguments</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+(async_test()).step(function() {
+ var worker = new SharedWorker(undefined, undefined);
+ worker.port.addEventListener('message', this.step_func(function(e) {
+ assert_equals(e.data[0], 'undefined', 'first arg');
+ assert_equals(e.data[1], 'undefined', 'second arg');
+ this.done();
+ }), false);
+ worker.port.start();
+});
+</script>
+<!--
+*/
+//--> \ No newline at end of file
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 000000000..39739022d
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/unexpected-global-properties.html
@@ -0,0 +1,30 @@
+<!--
+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'.split(' '); // iterated window in opera and removed expected ones
+var log = '';
+for (var i = 0; i < unexpected.length; ++i) {
+ if (unexpected[i] in self)
+ log += unexpected[i] + ' ';
+}
+onconnect = function(e) {
+ e.ports[0].postMessage(log);
+};
+/*
+-->
+<!doctype html>
+<title>unexpected members/interface objects/constructors</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+(async_test()).step(function() {
+ var worker = new SharedWorker('#');
+ worker.port.addEventListener('message', this.step_func(function(e) {
+ assert_equals(e.data, '');
+ this.done();
+ }), false);
+ worker.port.start();
+});
+</script>
+<!--
+*/
+//-->
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 000000000..2ca3d93d3
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/SharedWorker/unresolvable-url.html
@@ -0,0 +1,19 @@
+<!--
+/*
+-->
+<!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>
+<div id="log"></div>
+<script>
+test(function() {
+ assert_throws("SyntaxError", function() {
+ var 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 000000000..ea0b7c8f4
--- /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/AbstractWorker.onerror.html b/testing/web-platform/tests/workers/constructors/Worker/AbstractWorker.onerror.html
new file mode 100644
index 000000000..c40424d65
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/Worker/AbstractWorker.onerror.html
@@ -0,0 +1,48 @@
+<!--
+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
+/*
+-->
+<!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('#');
+ 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 + '#', '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>
+<!--
+*/
+//-->
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 000000000..168fc91ae
--- /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 000000000..2ef466ccd
--- /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/ctor-1.html b/testing/web-platform/tests/workers/constructors/Worker/ctor-1.html
new file mode 100644
index 000000000..bd865261f
--- /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 000000000..94ab71aef
--- /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 000000000..2d9eb6e65
--- /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 000000000..0ce41b59e
--- /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/no-arguments-ctor.html b/testing/web-platform/tests/workers/constructors/Worker/no-arguments-ctor.html
new file mode 100644
index 000000000..770c7cc93
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/Worker/no-arguments-ctor.html
@@ -0,0 +1,13 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>without arguments</title>
+<link rel=help href="http://dev.w3.org/2006/webapi/WebIDL/#es-interface-call">
+<link rel=help href="http://www.whatwg.org/html/#dedicated-workers-and-the-worker-interface">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+test(function() {
+ assert_throws(new TypeError(), function() { new Worker(); });
+});
+</script>
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 000000000..6d079b514
--- /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/resolve-empty-string.html b/testing/web-platform/tests/workers/constructors/Worker/resolve-empty-string.html
new file mode 100644
index 000000000..0426223e0
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/Worker/resolve-empty-string.html
@@ -0,0 +1,22 @@
+<!--
+postMessage('ok');
+/*
+-->
+<!doctype html>
+<meta charset=utf-8>
+<title>resolve the empty string</title>
+<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('');
+ worker.addEventListener('message', t.step_func_done(function(e) {
+ assert_equals(e.data, 'ok');
+ }), false);
+});
+</script>
+<!--
+*/
+//-->
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 000000000..9b0148da3
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/Worker/same-origin.html
@@ -0,0 +1,63 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>same-origin checks; the script is in a script element</title>
+<link rel=help href="http://www.whatwg.org/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 testSharedWorkerHelper(t, script) {
+ try {
+ var worker = new SharedWorker(script, '');
+ worker.onerror = t.step_func_done(function(e) {
+ assert_true(e instanceof ErrorEvent);
+ });
+ } catch (e) {
+ t.step_func_done(function(e) { assert_true(true); });
+ }
+}
+
+test(function() {
+ assert_throws("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) {
+ testSharedWorkerHelper(t, 'about:blank');
+}, "about_blank");
+
+async_test(function(t) {
+ testSharedWorkerHelper(t, 'http://www.example.invalid/');
+}, "example_invalid");
+
+async_test(function(t) {
+ testSharedWorkerHelper(t, location.protocol+'//'+location.hostname+':81/');
+}, "port_81");
+
+async_test(function(t) {
+ testSharedWorkerHelper(t, 'https://'+location.hostname+':80/');
+}, "https_port_80");
+
+async_test(function(t) {
+ testSharedWorkerHelper(t, 'https://'+location.hostname+':8000/');
+}, "https_port_8000");
+
+async_test(function(t) {
+ testSharedWorkerHelper(t, 'http://'+location.hostname+':8012/');
+}, "http_post_8012");
+
+async_test(function(t) {
+ testSharedWorkerHelper(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 000000000..19bbea58e
--- /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 000000000..52f9707df
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/Worker/terminate.html
@@ -0,0 +1,44 @@
+<!--
+(function f() {
+ postMessage(1);
+ setTimeout(f, 0);
+})();
+/*
+-->
+<!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('#');
+ 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>
+<!--
+*/
+//-->
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 000000000..bc7f482e9
--- /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/unexpected-self-properties.worker.js b/testing/web-platform/tests/workers/constructors/Worker/unexpected-self-properties.worker.js
new file mode 100644
index 000000000..aba850116
--- /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', 'name', '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/unresolvable-url.html b/testing/web-platform/tests/workers/constructors/Worker/unresolvable-url.html
new file mode 100644
index 000000000..8c04b0087
--- /dev/null
+++ b/testing/web-platform/tests/workers/constructors/Worker/unresolvable-url.html
@@ -0,0 +1,12 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>unresolvable url</title>
+<link rel=help href="http://www.whatwg.org/html/#dom-worker">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+test(function() {
+ assert_throws("SyntaxError", function() { new Worker('http://invalid url/'); });
+});
+</script>
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 000000000..94ce2a71f
--- /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>
diff --git a/testing/web-platform/tests/workers/interfaces.idl b/testing/web-platform/tests/workers/interfaces.idl
new file mode 100644
index 000000000..228efba28
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces.idl
@@ -0,0 +1,106 @@
+// -----------------------------------------------------------------------------
+// DOM
+// -----------------------------------------------------------------------------
+[Exposed=(Window,Worker)]
+interface EventTarget {
+ void addEventListener(DOMString type, EventListener? callback, optional boolean capture = false);
+ void removeEventListener(DOMString type, EventListener? callback, optional boolean capture = false);
+ boolean dispatchEvent(Event event);
+};
+
+callback interface EventListener {
+ void handleEvent(Event event);
+};
+
+// -----------------------------------------------------------------------------
+// HTML
+// -----------------------------------------------------------------------------
+[TreatNonCallableAsNull]
+callback EventHandlerNonNull = any (Event event);
+typedef EventHandlerNonNull? EventHandler;
+
+[TreatNonCallableAsNull]
+callback OnErrorEventHandlerNonNull = any ((Event or DOMString) event, optional DOMString source, optional unsigned long lineno, optional unsigned long column, optional any error);
+typedef OnErrorEventHandlerNonNull? OnErrorEventHandler;
+
+[Exposed=Worker]
+interface WorkerGlobalScope : EventTarget {
+ readonly attribute WorkerGlobalScope self;
+ readonly attribute WorkerLocation location;
+
+ void close();
+ attribute OnErrorEventHandler onerror;
+ attribute EventHandler onlanguagechange;
+ attribute EventHandler onoffline;
+ attribute EventHandler ononline;
+};
+
+[Global=(Worker,DedicatedWorker),Exposed=DedicatedWorker]
+/*sealed*/ interface DedicatedWorkerGlobalScope : WorkerGlobalScope {
+ void postMessage(any message, optional sequence<Transferable> transfer);
+ attribute EventHandler onmessage;
+};
+
+//[Exposed=Worker]
+partial interface WorkerGlobalScope { // not obsolete
+ void importScripts(DOMString... urls);
+ readonly attribute WorkerNavigator navigator;
+};
+WorkerGlobalScope implements WindowTimers;
+WorkerGlobalScope implements WindowBase64;
+
+[NoInterfaceObject, Exposed=(Window,Worker)]
+interface WindowTimers {
+ long setTimeout(Function handler, optional long timeout = 0, any... arguments);
+ long setTimeout(DOMString handler, optional long timeout = 0, any... arguments);
+ void clearTimeout(optional long handle = 0);
+ long setInterval(Function handler, optional long timeout = 0, any... arguments);
+ long setInterval(DOMString handler, optional long timeout = 0, any... arguments);
+ void clearInterval(optional long handle = 0);
+};
+
+[NoInterfaceObject, Exposed=(Window,Worker)]
+interface WindowBase64 {
+ DOMString btoa(DOMString btoa);
+ DOMString atob(DOMString atob);
+};
+
+[Exposed=Worker]
+interface WorkerNavigator {};
+WorkerNavigator implements NavigatorID;
+WorkerNavigator implements NavigatorLanguage;
+WorkerNavigator implements NavigatorOnLine;
+
+[NoInterfaceObject, Exposed=(Window,Worker)]
+interface NavigatorID {
+ readonly attribute DOMString appCodeName; // constant "Mozilla"
+ readonly attribute DOMString appName;
+ readonly attribute DOMString appVersion;
+ readonly attribute DOMString platform;
+ readonly attribute DOMString product; // constant "Gecko"
+ readonly attribute DOMString userAgent;
+};
+
+[NoInterfaceObject, Exposed=(Window,Worker)]
+interface NavigatorLanguage {
+ readonly attribute DOMString? language;
+ readonly attribute DOMString[] languages;
+};
+
+[NoInterfaceObject, Exposed=(Window,Worker)]
+interface NavigatorOnLine {
+ readonly attribute boolean onLine;
+};
+
+[Exposed=Worker]
+interface WorkerLocation {
+ stringifier readonly attribute USVString href;
+ readonly attribute USVString origin;
+ readonly attribute USVString protocol;
+ readonly attribute USVString host;
+ readonly attribute USVString hostname;
+ readonly attribute USVString port;
+ readonly attribute USVString pathname;
+ readonly attribute USVString search;
+ readonly attribute USVString hash;
+};
diff --git a/testing/web-platform/tests/workers/interfaces.worker.js b/testing/web-platform/tests/workers/interfaces.worker.js
new file mode 100644
index 000000000..f07669ba7
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces.worker.js
@@ -0,0 +1,20 @@
+"use strict";
+
+importScripts("/resources/testharness.js");
+importScripts("/resources/WebIDLParser.js", "/resources/idlharness.js");
+
+var request = new XMLHttpRequest();
+request.onload = function() {
+ var idlArray = new IdlArray();
+ var idls = request.responseText;
+ idlArray.add_idls(idls);
+ idlArray.add_objects({
+ DedicatedWorkerGlobalScope: ['self'],
+ WorkerNavigator: ['self.navigator'],
+ WorkerLocation: ['self.location'],
+ });
+ idlArray.test();
+ done();
+};
+request.open("GET", "interfaces.idl");
+request.send();
diff --git a/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/EventTarget.worker.js b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/EventTarget.worker.js
new file mode 100644
index 000000000..954c46c07
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/EventTarget.worker.js
@@ -0,0 +1,23 @@
+importScripts("/resources/testharness.js");
+
+test(function(t) {
+ var i = 0;
+ addEventListener("message", function listener(evt) {
+ t.step(function() {
+ ++i;
+ removeEventListener("message", listener, true);
+ });
+ }, true);
+ self.dispatchEvent(new Event("message"));
+ self.dispatchEvent(new Event("message"));
+ assert_equals(i, 1);
+}, "removeEventListener");
+
+test(function() {
+ addEventListener("message", this.step_func(function(evt) {
+ assert_equals(evt.target, self);
+ }), true);
+ self.dispatchEvent(new Event("message"));
+}, "target");
+
+done();
diff --git a/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/onmessage.worker.js b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/onmessage.worker.js
new file mode 100644
index 000000000..6f285caac
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/onmessage.worker.js
@@ -0,0 +1,40 @@
+importScripts("/resources/testharness.js");
+
+test(function() {
+ self.onmessage = 1;
+ assert_equals(self.onmessage, null,
+ "attribute should return null after being set to a primitive");
+}, "Setting onmessage to 1");
+
+test(function() {
+ var object = {
+ handleEvent: this.unreached_func()
+ };
+ self.onmessage = object;
+ assert_equals(self.onmessage, object,
+ "attribute should return the object it was set to.");
+
+ self.dispatchEvent(new Event("message"));
+}, "Setting onmessage to an object");
+
+test(function() {
+ var triggered = false;
+ var f = function(e) { triggered = true; };
+ self.onmessage = f;
+ assert_equals(self.onmessage, f,
+ "attribute should return the function it was set to.");
+
+ self.dispatchEvent(new Event("message"));
+ assert_true(triggered, "event handler should have been triggered");
+}, "Setting onmessage to a function");
+
+
+test(function() {
+ assert_not_equals(self.onmessage, null,
+ "attribute should not return null after being set to a function");
+ self.onmessage = 1;
+ assert_equals(self.onmessage, null,
+ "attribute should return null after being set to a primitive");
+}, "Setting onmessage to 1 (again)");
+
+done();
diff --git a/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/event-ports-dedicated.html b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/event-ports-dedicated.html
new file mode 100644
index 000000000..7ae4b0704
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/event-ports-dedicated.html
@@ -0,0 +1,25 @@
+<!--
+onmessage = function(e) {
+ postMessage(e.ports instanceof Array && e.ports.length === 0);
+}
+/*
+-->
+<!doctype html>
+<title>e.ports in dedicated worker</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+(async_test()).step(function() {
+ var worker = new Worker('#');
+ worker.postMessage(1);
+ worker.onmessage = this.step_func(function(e) {
+ assert_true(e.data);
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//-->
+
diff --git a/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/imagedata-cloned-canvas-in-array.html b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/imagedata-cloned-canvas-in-array.html
new file mode 100644
index 000000000..204130154
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/imagedata-cloned-canvas-in-array.html
@@ -0,0 +1,39 @@
+<!--
+onmessage = function(e) {
+ function processPixels(imagedata) {
+ var pixeldata = imagedata.data;
+ for (var i = 0; i < pixeldata.length; i = i+4) {
+ pixeldata[i] = 128;
+ }
+ postMessage(imagedata);
+ }
+ processPixels(e.data[0]);
+}
+
+/*
+-->
+<!doctype html>
+<title>posting an imagedata (from a cloned canvas) in an array</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+(async_test()).step(function() {
+ var worker = new Worker('#');
+ var canvas = document.createElement('canvas');
+ var clone = canvas.cloneNode(true);
+ var ctx = clone.getContext('2d');
+ var imagedata = ctx.getImageData(0, 0, 300, 150);
+ worker.postMessage([imagedata]);
+ worker.onmessage = this.step_func(function(e) {
+ var pixeldata = e.data.data;
+ for (var i = 0; i < pixeldata.length; i++) {
+ assert_equals(pixeldata[i], (i % 4 == 0) ? 128 : 0);
+ }
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//--> \ No newline at end of file
diff --git a/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/message-event.html b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/message-event.html
new file mode 100644
index 000000000..91ec63268
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/message-event.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>'message' event properties</title>
+<link rel=help href="http://www.whatwg.org/html/#dom-dedicatedworkerglobalscope-postmessage">
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<div id=log></div>
+<script>
+async_test("Properties of the 'message' event").step(function() {
+ var worker = new Worker("message-event.js");
+ worker.onmessage = this.step_func_done(function (evt) {
+ assert_class_string(evt, "MessageEvent");
+ assert_equals(evt.type, "message");
+ assert_false(evt.bubbles, "bubbles should be false");
+ assert_false(evt.cancelable, "cancelable should be false");
+ assert_equals(evt.data, "test");
+ assert_equals(evt.origin, "", "origin");
+ assert_equals(evt.lastEventId, "", "lastEventId");
+ assert_equals(evt.source, null, "source");
+ assert_array_equals(evt.ports, [], "ports");
+ });
+});
+</script>
diff --git a/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/message-event.js b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/message-event.js
new file mode 100644
index 000000000..54a250005
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/message-event.js
@@ -0,0 +1 @@
+postMessage("test");
diff --git a/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/return-value.worker.js b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/return-value.worker.js
new file mode 100644
index 000000000..521251699
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/return-value.worker.js
@@ -0,0 +1,8 @@
+importScripts("/resources/testharness.js");
+
+test(function() {
+ var rv = postMessage(1);
+ assert_equals(rv, undefined);
+}, "return value of postMessage");
+
+done();
diff --git a/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/second-argument-null-in-array.html b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/second-argument-null-in-array.html
new file mode 100644
index 000000000..df4c9f83e
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/second-argument-null-in-array.html
@@ -0,0 +1,26 @@
+<!--
+try {
+ postMessage(false, [null]);
+} catch(e) {
+ postMessage(e instanceof TypeError);
+}
+/*
+-->
+<!doctype html>
+<title>Using [null] in postMessage's second argument</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+(async_test()).step(function() {
+ var worker = new Worker('#');
+ worker.onmessage = this.step_func(function(e) {
+ assert_true(e.data);
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//-->
+
diff --git a/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/second-argument-null.html b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/second-argument-null.html
new file mode 100644
index 000000000..e81a56bad
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/second-argument-null.html
@@ -0,0 +1,25 @@
+<!--
+try {
+ postMessage(1, null);
+} catch(e) {
+ postMessage(e instanceof TypeError);
+}
+/*
+-->
+<!doctype html>
+<title>Using null in postMessage's second argument</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+(async_test()).step(function() {
+ var worker = new Worker('#');
+ worker.onmessage = this.step_func(function(e) {
+ assert_true(e.data);
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/second-argument-undefined.html b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/second-argument-undefined.html
new file mode 100644
index 000000000..7d01eba7a
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/second-argument-undefined.html
@@ -0,0 +1,25 @@
+<!--
+try {
+ postMessage(1, undefined);
+} catch(e) {
+ postMessage(''+e);
+}
+/*
+-->
+<!doctype html>
+<title>Using undefined in postMessage's second argument</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+(async_test()).step(function() {
+ var worker = new Worker('#');
+ worker.onmessage = this.step_func(function(e) {
+ assert_equals(e.data, 1);
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/setting-postMessage.html b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/setting-postMessage.html
new file mode 100644
index 000000000..d1a3f0f5c
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/setting-postMessage.html
@@ -0,0 +1,24 @@
+<!--
+var x = postMessage;
+postMessage = 1;
+x(postMessage == 1);
+
+/*
+-->
+<!doctype html>
+<title>setting postMessage</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+(async_test()).step(function() {
+ var worker = new Worker('#');
+ worker.onmessage = this.step_func(function(e) {
+ assert_true(e.data);
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/structured-clone-imagedata.html b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/structured-clone-imagedata.html
new file mode 100644
index 000000000..c0ded6a28
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/structured-clone-imagedata.html
@@ -0,0 +1,30 @@
+<!--
+onmessage = function(e) {
+ var imagedata = e.data;
+ imagedata.data[0] = 128;
+ postMessage(imagedata);
+}
+
+/*
+-->
+<!doctype html>
+<title>structured clone of ImageData</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+(async_test()).step(function() {
+ var worker = new Worker('#');
+ var ctx = document.createElement('canvas').getContext('2d');
+ var imagedata = ctx.getImageData(0, 0, 300, 150);
+ worker.postMessage(imagedata);
+ worker.onmessage = this.step_func(function(e) {
+ assert_equals(''+e.data, '[object ImageData]');
+ assert_equals(e.data.data[0], 128);
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/structured-clone-message.html b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/structured-clone-message.html
new file mode 100644
index 000000000..ba357421f
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/structured-clone-message.html
@@ -0,0 +1,58 @@
+<!--
+var err = new Error('foo');
+var date = new Date();
+// commented out bits are either tested elsewhere or not supported yet. or uncloneable.
+var tests = [undefined, null, false, true, 1, NaN, Infinity, 'foo', date, /foo/, /* ImageData, File, FileData, FileList,*/ null/*self*/,
+ [undefined, null, false, true, 1, NaN, Infinity, 'foo', /*date, /foo/,*/ null/*self*/, /*[], {},*/ null/*err*/],
+ {a:undefined, b:null, c:false, d:true, e:1, f:NaN, g:Infinity, h:'foo', /*i:date, j:/foo/,*/ k:null/*self*/, /*l:[], m:{},*/ n:null/*err*/},
+ null/*err*/];
+for (var i = 0; i < tests.length; ++i) {
+ try {
+ postMessage(tests[i]);
+ } catch(e) {
+ postMessage(''+e);
+ }
+}
+/*
+-->
+<!doctype html>
+<title>structured clone of message</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+var wrapper_test = async_test();
+var tests = [
+ {test:async_test('undefined'), check:function(e) { assert_equals(e.data, undefined); }},
+ {test:async_test('null'), check:function(e) { assert_equals(e.data, null); }},
+ {test:async_test('false'), check:function(e) { assert_false(e.data); }},
+ {test:async_test('true'), check:function(e) { assert_true(e.data); }},
+ {test:async_test('1'), check:function(e) { assert_equals(e.data, 1); }},
+ {test:async_test('NaN'), check:function(e) { assert_equals(e.data, NaN); }},
+ {test:async_test('Infinity'), check:function(e) { assert_equals(e.data, Infinity); }},
+ {test:async_test('string'), check:function(e) { assert_equals(e.data, 'foo'); }},
+ {test:async_test('date'), check:function(e) { assert_equals(e.data instanceof Date, true); }},
+ {test:async_test('regexp'), check:function(e) { assert_equals('' + e.data, '/foo/'); assert_equals(e.data instanceof RegExp, true, 'e.data instanceof RegExp'); }},
+ {test:async_test('self'), check:function(e) { assert_equals(e.data, null); }},
+ {test:async_test('array'), check:function(e) { assert_array_equals(e.data, [undefined, null, false, true, 1, NaN, Infinity, 'foo', null, null]); }},
+ {test:async_test('object'), check:function(e) { assert_object_equals(e.data, {a:undefined, b:null, c:false, d:true, e:1, f:NaN, g:Infinity, h:'foo', k:null, n:null}); }},
+ {test:async_test('error'), check:function(e) { assert_equals(e.data, null, 'new Error()'); }},
+ {test:wrapper_test, check:function(e) { assert_unreached(); }}
+];
+// make wrapper_test pass after 500ms
+setTimeout(tests[tests.length-1].test.step_func(function() {
+ this.done();
+}), 500);
+
+wrapper_test.step(function() {
+ var worker = new Worker('#');
+ var i = 0;
+ worker.onmessage = function(e) {
+ tests[i].test.step(function() { tests[i].check(e); this.done(); });
+ i++;
+ };
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/interfaces/SharedWorkerGlobalScope/name/getting.html b/testing/web-platform/tests/workers/interfaces/SharedWorkerGlobalScope/name/getting.html
new file mode 100644
index 000000000..bfe81a8a9
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/SharedWorkerGlobalScope/name/getting.html
@@ -0,0 +1,34 @@
+<!--
+addEventListener('connect', function(e) {
+ var passed;
+ switch (location.hash) {
+ case '#1': passed = name == ''; break;
+ case '#2': passed = name == 'a'; break;
+ case '#3': passed = name == '0'; break;
+ }
+ e.ports[0].postMessage(passed);
+}, false);
+/*
+-->
+<!doctype html>
+<title>getting name</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+var tests = [['#1', ''], ['#2', 'a'], ['#3', -0]];
+tests.forEach(function(t) {
+ async_test(function() {
+ var w = new SharedWorker(t[0], t[1]);
+ w.port.onmessage = this.step_func(function(e) {
+ assert_true(e.data);
+ this.done();
+ });
+ });
+});
+</script>
+<!--
+*/
+//-->
+
+
diff --git a/testing/web-platform/tests/workers/interfaces/SharedWorkerGlobalScope/name/setting.html b/testing/web-platform/tests/workers/interfaces/SharedWorkerGlobalScope/name/setting.html
new file mode 100644
index 000000000..39cdf7b67
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/SharedWorkerGlobalScope/name/setting.html
@@ -0,0 +1,25 @@
+<!--
+addEventListener('connect', function(e) {
+ name = 1;
+ e.ports[0].postMessage(name);
+}, false);
+/*
+-->
+<!doctype html>
+<title>setting name</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(function() {
+ var w1 = new SharedWorker('#1', 'x');
+ w1.port.addEventListener('message', this.step_func(function(e) {
+ assert_equals(e.data, 'x');
+ this.done();
+ }), false);
+ w1.port.start();
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/interfaces/SharedWorkerGlobalScope/onconnect.html b/testing/web-platform/tests/workers/interfaces/SharedWorkerGlobalScope/onconnect.html
new file mode 100644
index 000000000..2ad155bf7
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/SharedWorkerGlobalScope/onconnect.html
@@ -0,0 +1,39 @@
+<!--
+var results = [];
+try {
+ self.onconnect = 1;
+ results.push(String(onconnect));
+} catch(e) {
+ results.push(''+e);
+}
+try {
+ self.onconnect = {handleEvent:function(){}};
+ results.push(String(onconnect));
+} catch(e) {
+ results.push(''+e);
+}
+var f = function(e) {
+ results.push(e.data);
+ e.ports[0].postMessage(results);
+};
+onconnect = f;
+results.push(typeof onconnect);
+/*
+-->
+<!doctype html>
+<title>onconnect</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(function() {
+ var w1 = new SharedWorker('#', '');
+ w1.port.addEventListener('message', this.step_func(function(e) {
+ assert_array_equals(e.data, ['null', 'null', 'function', '']);
+ }), false);
+ w1.port.start();
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/close/incoming-message.html b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/close/incoming-message.html
new file mode 100644
index 000000000..d65695632
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/close/incoming-message.html
@@ -0,0 +1,29 @@
+<!--
+onmessage = function(e) {
+ postMessage(1);
+ throw new Error();
+}
+close();
+/*
+-->
+<!doctype html>
+<title>close() and incoming message</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+var worker = new Worker('#');
+worker.onmessage = function(e) {
+ assert_unreached("Got message");
+};
+worker.onerror = function(e) {
+ assert_unreached("Got error");
+};
+worker.postMessage(1);
+setTimeout(done, 2000);
+</script>
+<!--
+*/
+//-->
+
+
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/close/sending-messages.html b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/close/sending-messages.html
new file mode 100644
index 000000000..983c422cc
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/close/sending-messages.html
@@ -0,0 +1,27 @@
+<!--
+postMessage(1);
+close();
+postMessage(2);
+/*
+-->
+<!doctype html>
+<title>close() and sending messages</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(function() {
+ var worker = new Worker('#');
+ var i = 0;
+ worker.onmessage = this.step_func(function(e) {
+ i++;
+ assert_equals(e.data, i);
+ if (i == 2) {
+ this.done();
+ }
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/close/setInterval.html b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/close/setInterval.html
new file mode 100644
index 000000000..1d7d178d2
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/close/setInterval.html
@@ -0,0 +1,34 @@
+<!--
+var interval1 = setInterval(function() {
+ clearInterval(interval1);
+ postMessage(1);
+ throw new Error();
+}, 10);
+close();
+var interval2 = setInterval(function() {
+ clearInterval(interval2);
+ postMessage(1);
+ throw new Error();
+}, 10);
+/*
+-->
+<!doctype html>
+<title>close() and setInterval</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+var worker = new Worker('#');
+worker.onmessage = function(e) {
+ assert_unreached("Got message");
+};
+worker.onerror = function(e) {
+ assert_unreached("Got error");
+};
+setTimeout(done, 2000);
+</script>
+<!--
+*/
+//-->
+
+
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/close/setTimeout.html b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/close/setTimeout.html
new file mode 100644
index 000000000..c2fa10dfc
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/close/setTimeout.html
@@ -0,0 +1,28 @@
+<!--
+function x() {
+ postMessage(1);
+ throw new Error();
+}
+setTimeout(x, 0);
+close();
+setTimeout(x, 0);
+/*
+-->
+<!doctype html>
+<title>close() and setTimeout</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+var worker = new Worker('#');
+worker.onmessage = function(e) {
+ assert_unreached("Got message");
+};
+worker.onerror = function(e) {
+ assert_unreached("Got error");
+};
+setTimeout(done, 2000);
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/helper-redirect.py b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/helper-redirect.py
new file mode 100644
index 000000000..eb1599a57
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/helper-redirect.py
@@ -0,0 +1,3 @@
+def main(request, response):
+ response.status = 302
+ response.headers.append("Location", "post-location-members.js?a")
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/members.html b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/members.html
new file mode 100644
index 000000000..31ddf37a1
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/members.html
@@ -0,0 +1,31 @@
+<!--
+postMessage([null, location.href, location.protocol, location.host,
+ location.hostname, location.port, location.pathname,
+ location.search, location.hash]);
+/*
+-->
+<!doctype html>
+<title>members of WorkerLocation</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(function() {
+ var worker = new Worker('#');
+ worker.onmessage = this.step_func(function(e) {
+ assert_equals(e.data[0], null);
+ assert_equals(e.data[1], location.href + '#', 'href');
+ assert_equals(e.data[2], location.protocol, 'protocol');
+ assert_equals(e.data[3], location.host, 'host');
+ assert_equals(e.data[4], location.hostname, 'hostname');
+ assert_equals(e.data[5], location.port, 'port');
+ assert_equals(e.data[6], location.pathname, 'pathname');
+ assert_equals(e.data[7], location.search, 'search');
+ assert_equals(e.data[8], '', 'hash');
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/post-location-members.js b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/post-location-members.js
new file mode 100644
index 000000000..e850b76b6
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/post-location-members.js
@@ -0,0 +1,8 @@
+postMessage([location.href,
+ location.protocol,
+ location.host,
+ location.hostname,
+ location.port,
+ location.pathname,
+ location.search,
+ location.hash]); \ No newline at end of file
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/redirect.html b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/redirect.html
new file mode 100644
index 000000000..2fd16a4c1
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/redirect.html
@@ -0,0 +1,28 @@
+<!--
+/*
+-->
+<!doctype html>
+<title>location with a worker in separate file that redirects</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(function() {
+ var worker = new Worker('helper-redirect.py?fail');
+ worker.onmessage = this.step_func_done(function(e) {
+ assert_equals(e.data[0], location.href.replace(/\/[^\/]+$/, '/post-location-members.js?a'));
+ assert_equals(e.data[1], location.protocol);
+ assert_equals(e.data[2], location.host);
+ assert_equals(e.data[3], location.hostname);
+ assert_equals(e.data[4], location.port);
+ assert_equals(e.data[5], location.pathname.replace(/\/[^\/]+$/, '/post-location-members.js'));
+ assert_equals(e.data[6], '?a');
+ assert_equals(e.data[7], '');
+ });
+});
+</script>
+<!--
+*/
+//-->
+
+
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/returns-same-object.html b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/returns-same-object.html
new file mode 100644
index 000000000..40559c166
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/returns-same-object.html
@@ -0,0 +1,21 @@
+<!--
+postMessage(location === location);
+/*
+-->
+<!doctype html>
+<title>location === location</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(function() {
+ var worker = new Worker('#');
+ worker.onmessage = this.step_func(function(e) {
+ assert_true(e.data);
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/setting-members.html b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/setting-members.html
new file mode 100644
index 000000000..d2f470ffc
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/setting-members.html
@@ -0,0 +1,43 @@
+<!--
+var exceptions = [];
+try { location.href = 1; } catch(e) { exceptions.push('href'); }
+try { location.protocol = 1; } catch(e) { exceptions.push('protocol'); }
+try { location.host = 1; } catch(e) { exceptions.push('host'); }
+try { location.hostname = 1; } catch(e) { exceptions.push('hostname');}
+try { location.port = 1; } catch(e) { exceptions.push('port'); }
+try { location.pathname = 1; } catch(e) { exceptions.push('pathname'); }
+try { location.search = 1; } catch(e) { exceptions.push('search'); }
+try { location.hash = 1; } catch(e) { exceptions.push('hash'); }
+
+postMessage([null, location.href, location.protocol, location.host,
+ location.hostname, location.port, location.pathname,
+ location.search, location.hash, exceptions]);
+/*
+-->
+<!doctype html>
+<title>setting members of WorkerLocation</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(function() {
+ var worker = new Worker('#');
+ worker.onmessage = this.step_func(function(e) {
+ assert_equals(e.data[0], null);
+ assert_equals(e.data[1], location.href + '#', 'href');
+ assert_equals(e.data[2], location.protocol, 'protocol');
+ assert_equals(e.data[3], location.host, 'host');
+ assert_equals(e.data[4], location.hostname, 'hostname');
+ assert_equals(e.data[5], location.port, 'port');
+ assert_equals(e.data[6], location.pathname, 'pathname');
+ assert_equals(e.data[7], location.search, 'search');
+ assert_equals(e.data[8], '', 'hash');
+ assert_array_equals(e.data[9], [], 'number of exceptions');
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//-->
+
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/worker-separate-file.html b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/worker-separate-file.html
new file mode 100644
index 000000000..ac8e64dcc
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/location/worker-separate-file.html
@@ -0,0 +1,28 @@
+<!--
+/*
+-->
+<!doctype html>
+<title>location with a worker in separate file</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(function() {
+ var worker = new Worker('post-location-members.js?a#b?c');
+ worker.onmessage = this.step_func(function(e) {
+ assert_equals(e.data[0], location.href.replace(/\/[^\/]+$/, '/post-location-members.js?a#b?c'));
+ assert_equals(e.data[1], location.protocol);
+ assert_equals(e.data[2], location.host);
+ assert_equals(e.data[3], location.hostname);
+ assert_equals(e.data[4], location.port);
+ assert_equals(e.data[5], location.pathname.replace(/\/[^\/]+$/, '/post-location-members.js'));
+ assert_equals(e.data[6], '?a');
+ assert_equals(e.data[7], '#b?c');
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//-->
+
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/onerror/exception-in-onerror.html b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/onerror/exception-in-onerror.html
new file mode 100644
index 000000000..4b5af71d5
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/onerror/exception-in-onerror.html
@@ -0,0 +1,32 @@
+<!--
+onerror = function(a, b, c, d) {
+ y(); // the error is "not handled"
+}
+function x() {
+ y();
+}
+x();
+/*
+-->
+<!doctype html>
+<title>onerror, "not handled" with an error in the onerror function</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(function() {
+ var worker = new Worker('#');
+ worker.onerror = this.step_func(function(e) {
+ assert_true(e instanceof ErrorEvent, 'e instanceof ErrorEvent');
+ assert_equals(typeof e.message, 'string', 'typeof e.message');
+ assert_equals(e.filename, document.URL+'#', 'e.filename');
+ assert_equals(typeof e.lineno, 'number', 'typeof e.lineno');
+ assert_equals(typeof e.colno, 'number', 'typeof e.column');
+ e.preventDefault(); // "handled"
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/onerror/handled.html b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/onerror/handled.html
new file mode 100644
index 000000000..56fee8e06
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/onerror/handled.html
@@ -0,0 +1,36 @@
+<!--
+onerror = function(a, b, c, d) {
+ postMessage([a, b, c, d]);
+ return true; // the error is "handled"
+}
+function x() {
+ y();
+}
+x();
+/*
+-->
+<!doctype html>
+<title>onerror, "handled"</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(function() {
+ var worker = new Worker('#');
+ worker.onmessage = this.step_func(function(e) {
+ assert_equals(typeof e.data[0], 'string', 'first argument');
+ assert_equals(e.data[1], document.URL+'#', 'second argument');
+ assert_equals(typeof e.data[2], 'number', 'third argument');
+ assert_equals(typeof e.data[3], 'number', 'fourth argument');
+ setTimeout(this.step_func(function() {
+ this.done();
+ }), 100);
+ });
+ worker.onerror = this.step_func(function(e) {
+ assert_unreached();
+ });
+});
+</script>
+<!--
+*/
+//--> \ No newline at end of file
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/onerror/not-handled.html b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/onerror/not-handled.html
new file mode 100644
index 000000000..f6107ada4
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/onerror/not-handled.html
@@ -0,0 +1,32 @@
+<!--
+onerror = function(a, b, c, d) {
+ return false; // the error is "not handled"
+}
+function x() {
+ y();
+}
+x();
+/*
+-->
+<!doctype html>
+<title>onerror, "not handled"</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(function() {
+ var worker = new Worker('#');
+ worker.onerror = this.step_func(function(e) {
+ assert_true(e instanceof ErrorEvent, 'e instanceof ErrorEvent');
+ assert_equals(typeof e.message, 'string', 'typeof e.message');
+ assert_equals(e.filename, document.URL+'#', 'e.filename');
+ assert_equals(typeof e.lineno, 'number', 'typeof e.lineno');
+ assert_equals(typeof e.colno, 'number', 'typeof e.column');
+ e.preventDefault(); // "handled"
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/onerror/propagate-to-window-onerror.html b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/onerror/propagate-to-window-onerror.html
new file mode 100644
index 000000000..b6a61e235
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/onerror/propagate-to-window-onerror.html
@@ -0,0 +1,31 @@
+<!--
+function x() {
+ y();
+}
+x();
+/*
+-->
+<!doctype html>
+<title>onerror, "not handled" with only window.onerror defined</title>
+<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('#');
+ window.onerror = this.step_func(function(a, b, c, d) {
+ assert_equals(typeof a, 'string', 'first argument');
+ assert_equals(b, document.URL+'#', 'second argument');
+ assert_equals(typeof c, 'number', 'third argument');
+ assert_equals(typeof d, 'number', 'fourth argument');
+ this.done();
+ return true; // "handled"
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/self.html b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/self.html
new file mode 100644
index 000000000..39c2c36c0
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerGlobalScope/self.html
@@ -0,0 +1,39 @@
+<!--
+var results = [];
+function check(func, msg) {
+ try {
+ results.push([func(), msg]);
+ } catch(ex) {
+ results.push([String(ex), msg]);
+ }
+}
+check(function() { return self === self; }, 'self === self');
+check(function() { return self instanceof WorkerGlobalScope; }, 'self instanceof WorkerGlobalScope');
+check(function() { return 'self' in self; }, '\'self\' in self');
+check(function() {
+ var x = self;
+ self = 1;
+ return x === self;
+}, 'self = 1');
+postMessage(results);
+/*
+-->
+<!doctype html>
+<title>self</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(function() {
+ var worker = new Worker('#');
+ worker.onmessage = this.step_func(function(e) {
+ for (var i = 0; i < e.data.length; ++i) {
+ assert_true(e.data[i][0], e.data[i][1]);
+ }
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//--> \ No newline at end of file
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/WindowTimers/001.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/WindowTimers/001.html
new file mode 100644
index 000000000..a80897518
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/WindowTimers/001.html
@@ -0,0 +1,23 @@
+<!--
+setTimeout(function() { postMessage(1) }, 10);
+/*
+-->
+<!doctype html>
+<title>setTimeout</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function() {
+ var worker = new Worker('#');
+ worker.onmessage = this.step_func(function(e) {
+ assert_equals(e.data, 1);
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//-->
+
+
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/WindowTimers/002.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/WindowTimers/002.html
new file mode 100644
index 000000000..06685a905
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/WindowTimers/002.html
@@ -0,0 +1,21 @@
+<!--
+var t = setTimeout(function() { postMessage(1); }, 10);
+clearTimeout(t);
+/*
+-->
+<!doctype html>
+<title>clearTimeout</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function() {
+ var worker = new Worker('#');
+ var gotMessage = false;
+ worker.onmessage = function() { gotMessage = true; };
+ setTimeout(this.step_func(function() { assert_false(gotMessage); this.done(); }), 100);
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/WindowTimers/003.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/WindowTimers/003.html
new file mode 100644
index 000000000..942f139fa
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/WindowTimers/003.html
@@ -0,0 +1,22 @@
+<!--
+setInterval(function() { postMessage(1); }, 10);
+/*
+-->
+<!doctype html>
+<title>setInterval</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function() {
+ var worker = new Worker('#');
+ worker.onmessage = this.step_func(function(e) {
+ assert_equals(e.data, 1);
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//-->
+
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/WindowTimers/004.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/WindowTimers/004.html
new file mode 100644
index 000000000..5548eec4a
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/WindowTimers/004.html
@@ -0,0 +1,23 @@
+<!--
+var t = setInterval(function() {
+ postMessage(1);
+}, 10);
+clearInterval(t);
+/*
+-->
+<!doctype html>
+<title>clearInterval</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function() {
+ var worker = new Worker('#');
+ var i = 0;
+ worker.onmessage = function() { i++; }
+ setTimeout(this.step_func(function() { assert_equals(i, 0); this.done(); }), 100);
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/001.worker.js b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/001.worker.js
new file mode 100644
index 000000000..aa86c8ef1
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/001.worker.js
@@ -0,0 +1,7 @@
+importScripts("/resources/testharness.js");
+
+test(function() {
+ importScripts();
+});
+
+done();
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/002.worker.js b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/002.worker.js
new file mode 100644
index 000000000..2cecbcb53
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/002.worker.js
@@ -0,0 +1,11 @@
+importScripts("/resources/testharness.js");
+
+test(function() {
+ var ran = false;
+ assert_throws("SyntaxError", function() {
+ importScripts('data:text/javascript,ran=true','http://foo bar');
+ });
+ assert_false(ran, 'first argument to importScripts ran');
+});
+
+done();
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/003.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/003.html
new file mode 100644
index 000000000..7ff30ae2a
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/003.html
@@ -0,0 +1,28 @@
+<!--
+var x = 'a';
+try {
+ importScripts('data:text/javascript,x+="b"',
+ 'data:text/javascript,x+="c"');
+} catch(e) {
+ x += "d"
+}
+postMessage(x);
+/*
+-->
+<!doctype html>
+<title>importScripts running scripts</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(function() {
+ var worker = new Worker('#');
+ worker.onmessage = this.step_func(function(e) {
+ assert_equals(e.data, "abc");
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/004.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/004.html
new file mode 100644
index 000000000..2d39d3ce7
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/004.html
@@ -0,0 +1,34 @@
+<!--
+var x = '';
+var exception;
+try {
+ importScripts('data:text/javascript,x+="first script successful. "',
+ 'data:text/javascript,x+="FAIL (second script). "; for(;) break;', // doesn't compile
+ 'data:text/javascript,x+="FAIL (third script)"');
+} catch(ex) {
+ if (ex instanceof SyntaxError)
+ exception = true;
+ else
+ exception = String(ex);
+}
+postMessage([x, exception]);
+/*
+-->
+<!doctype html>
+<title>importScripts broken script</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(function() {
+ var worker = new Worker('#');
+ worker.onmessage = this.step_func(function(e) {
+ assert_equals(e.data[0], "first script successful. ");
+ assert_true(e.data[1], 'expected SyntaxError');
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/005.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/005.html
new file mode 100644
index 000000000..f8abe14c2
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/005.html
@@ -0,0 +1,30 @@
+<!--
+var x;
+var y;
+try {
+ importScripts('data:text/javascript,x={',
+ 'data:text/javascript,}');
+} catch(e) {
+ y = true;
+}
+postMessage([x, y]);
+/*
+-->
+<!doctype html>
+<title>importScripts separate scripts</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(function() {
+ var worker = new Worker('#');
+ worker.onmessage = this.step_func(function(e) {
+ assert_equals(e.data[0], undefined);
+ assert_true(e.data[1]);
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/006.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/006.html
new file mode 100644
index 000000000..06aea9696
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/006.html
@@ -0,0 +1,33 @@
+<!--
+var x;
+var y;
+var z;
+try {
+ importScripts('data:text/javascript,x=1',
+ 'data:text/javascript,throw 2',
+ 'data:text/javascript,z=3');
+} catch(e) {
+ y = e;
+}
+postMessage([x, y, z]);
+/*
+-->
+<!doctype html>
+<title>importScripts uncaught exception</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(function() {
+ var worker = new Worker('#');
+ worker.onmessage = this.step_func(function(e) {
+ assert_equals(e.data[0], 1);
+ assert_equals(e.data[1], 2);
+ assert_equals(e.data[2], undefined);
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/007.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/007.html
new file mode 100644
index 000000000..128fb1b64
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/007.html
@@ -0,0 +1,25 @@
+<!--
+importScripts('data:text/javascript,postMessage(1)');
+postMessage(2);
+/*
+-->
+<!doctype html>
+<title>postMessage in importScripts</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(function() {
+ var worker = new Worker('#');
+ var i = 0;
+ worker.onmessage = this.step_func(function(e) {
+ i++;
+ assert_equals(e.data, i);
+ if (i == 2)
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/008.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/008.html
new file mode 100644
index 000000000..07b800ebb
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/008.html
@@ -0,0 +1,23 @@
+<!--
+var log = postMessage;
+importScripts('data:text/javascript,function run() { log(true) }');
+run();
+/*
+-->
+<!doctype html>
+<title>variables and functions crossing importScripts boundary</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(function() {
+ var worker = new Worker('#');
+ worker.onmessage = this.step_func(function(e) {
+ assert_true(e.data);
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/009.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/009.html
new file mode 100644
index 000000000..95d3839dc
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/009.html
@@ -0,0 +1,29 @@
+<!--
+var log = postMessage;
+importScripts('data:text/javascript,function run() { for(var i = 0; i < 1000; ++i) { if (i == 500) log(true); } return 1; }');
+postMessage(run());
+/*
+-->
+<!doctype html>
+<title>variables and functions crossing importScripts boundary, take 2</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(function() {
+ var worker = new Worker('#');
+ var i = 0;
+ worker.onmessage = this.step_func(function(e) {
+ i++;
+ if (i == 1) {
+ assert_true(e.data);
+ } else {
+ assert_equals(e.data, 1);
+ this.done();
+ }
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/010.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/010.html
new file mode 100644
index 000000000..9c76e7d4d
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/010.html
@@ -0,0 +1,34 @@
+<!--
+// prevent recursion
+if ('beenThere' in self) {
+ throw 'undefined stringified to the empty string';
+}
+beenThere = true;
+try {
+ importScripts(undefined);
+ postMessage(got);
+} catch(ex) {
+ postMessage(String(ex));
+}
+/*
+-->
+<!doctype html>
+<title>importScripts(undefined)</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(function() {
+ var worker = new Worker('#');
+ worker.onmessage = this.step_func(function(e) {
+ assert_equals(e.data, 'undefined');
+ this.done();
+ })
+ worker.onerror = this.step_func(function(e) {
+ assert_unreached(e.message);
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/011.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/011.html
new file mode 100644
index 000000000..46499318f
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/011.html
@@ -0,0 +1,34 @@
+<!--
+// prevent recursion
+if ('beenThere' in self) {
+ throw 'null stringified to the empty string';
+}
+beenThere = true;
+try {
+ importScripts(null);
+ postMessage(got);
+} catch(ex) {
+ postMessage(String(ex));
+}
+/*
+-->
+<!doctype html>
+<title>importScripts(null)</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(function() {
+ var worker = new Worker('#');
+ worker.onmessage = this.step_func(function(e) {
+ assert_equals(e.data, 'null');
+ this.done();
+ });
+ worker.onerror = this.step_func(function(e) {
+ assert_unreached(e.message);
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/012.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/012.html
new file mode 100644
index 000000000..f7622bdc9
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/012.html
@@ -0,0 +1,34 @@
+<!--
+// prevent recursion
+if ('beenThere' in self) {
+ throw '1 stringified to the empty string';
+}
+beenThere = true;
+try {
+ importScripts(1);
+ postMessage(got);
+} catch(ex) {
+ postMessage(String(ex));
+}
+/*
+-->
+<!doctype html>
+<title>importScripts(1)</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(function() {
+ var worker = new Worker('#');
+ worker.onmessage = this.step_func(function(e) {
+ assert_equals(e.data, '1');
+ this.done();
+ });
+ worker.onerror = this.step_func(function(e) {
+ assert_unreached(e.message);
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/1 b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/1
new file mode 100644
index 000000000..18cea4ff0
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/1
@@ -0,0 +1 @@
+var got = '1'; \ No newline at end of file
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/null b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/null
new file mode 100644
index 000000000..8e54b66c5
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/null
@@ -0,0 +1 @@
+var got = 'null'; \ No newline at end of file
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/undefined b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/undefined
new file mode 100644
index 000000000..f99ba4be7
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/importScripts/undefined
@@ -0,0 +1 @@
+var got = 'undefined'; \ No newline at end of file
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/002.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/002.html
new file mode 100644
index 000000000..d3aa2ec65
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/002.html
@@ -0,0 +1,21 @@
+<!--
+postMessage(navigator.appName);
+/*
+-->
+<!doctype html>
+<title>navigator.appName</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function() {
+ var worker = new Worker('#');
+ worker.onmessage = this.step_func(function(e) {
+ assert_equals(e.data, navigator.appName);
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/003.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/003.html
new file mode 100644
index 000000000..a2e5c9487
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/003.html
@@ -0,0 +1,21 @@
+<!--
+postMessage(navigator.appVersion);
+/*
+-->
+<!doctype html>
+<title>navigator.appVersion</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function() {
+ var worker = new Worker('#');
+ worker.onmessage = this.step_func(function(e) {
+ assert_equals(e.data, navigator.appVersion);
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/004.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/004.html
new file mode 100644
index 000000000..2231c4ab8
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/004.html
@@ -0,0 +1,21 @@
+<!--
+postMessage(navigator.platform);
+/*
+-->
+<!doctype html>
+<title>navigator.platform</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function() {
+ var worker = new Worker('#');
+ worker.onmessage = this.step_func(function(e) {
+ assert_equals(e.data, navigator.platform);
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/005.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/005.html
new file mode 100644
index 000000000..b3d99588f
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/005.html
@@ -0,0 +1,21 @@
+<!--
+postMessage(navigator.userAgent);
+/*
+-->
+<!doctype html>
+<title>navigator.userAgent</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function() {
+ var worker = new Worker('#');
+ worker.onmessage = this.step_func(function(e) {
+ assert_equals(e.data, navigator.userAgent);
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/006.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/006.html
new file mode 100644
index 000000000..c027d630d
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/006.html
@@ -0,0 +1,21 @@
+<!--
+postMessage(navigator.onLine);
+/*
+-->
+<!doctype html>
+<title>navigator.onLine</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function() {
+ var worker = new Worker('#');
+ worker.onmessage = this.step_func(function(e) {
+ assert_equals(e.data, navigator.onLine);
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/007.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/007.html
new file mode 100644
index 000000000..a6afc5637
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/007.html
@@ -0,0 +1,30 @@
+<!--
+var log = [];
+var neverEncounteredValue = "This is not the value you are looking for.";
+for (x in navigator) {
+ // this should silently fail and not throw per webidl
+ navigator[x] = neverEncounteredValue;
+ if (navigator[x] === neverEncounteredValue)
+ log.push(x);
+}
+postMessage(log.join(', '));
+/*
+-->
+<!doctype html>
+<title>readonlyness of members of Navigator</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function() {
+ var worker = new Worker('#');
+ worker.onmessage = this.step_func(function(e) {
+ assert_equals(e.data, '');
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//-->
+
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/language.html b/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/language.html
new file mode 100644
index 000000000..f1aa446cb
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/language.html
@@ -0,0 +1,21 @@
+<!--
+postMessage(navigator.language);
+/*
+-->
+<!doctype html>
+<title>navigator.language</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function() {
+ var worker = new Worker('#');
+ worker.onmessage = this.step_func(function(e) {
+ assert_equals(e.data, navigator.language);
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/window-only.worker.js b/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/window-only.worker.js
new file mode 100644
index 000000000..7095281ec
--- /dev/null
+++ b/testing/web-platform/tests/workers/interfaces/WorkerUtils/navigator/window-only.worker.js
@@ -0,0 +1,22 @@
+importScripts("/resources/testharness.js");
+
+var properties = [
+ "appCodeName",
+ "product",
+ "productSub",
+ "vendor",
+ "vendorSub",
+
+ // Only exist in Window scopes if navigator compatibility mode is Gecko;
+ // never exist in workers.
+ "taintEnabled",
+ "oscpu",
+];
+
+properties.forEach(function(property) {
+ test(function() {
+ assert_false(property in navigator);
+ }, "NavigatorID properties exposed only for Window: " + property);
+});
+
+done();
diff --git a/testing/web-platform/tests/workers/nested_worker.worker.js b/testing/web-platform/tests/workers/nested_worker.worker.js
new file mode 100644
index 000000000..8848fa216
--- /dev/null
+++ b/testing/web-platform/tests/workers/nested_worker.worker.js
@@ -0,0 +1,11 @@
+importScripts("/resources/testharness.js");
+
+async_test(function() {
+ var worker1 = new Worker("support/WorkerBasic.js");
+ worker1.postMessage("ping");
+ worker1.onmessage = this.step_func_done(function(evt) {
+ assert_equals(evt.data, "Pass");
+ worker1.terminate();
+ done();
+ });
+}, "Nested worker");
diff --git a/testing/web-platform/tests/workers/non-automated/application-cache-dedicated.html b/testing/web-platform/tests/workers/non-automated/application-cache-dedicated.html
new file mode 100644
index 000000000..704ecbcd7
--- /dev/null
+++ b/testing/web-platform/tests/workers/non-automated/application-cache-dedicated.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<html manifest=cache.manifest>
+<title>cache manifest</title>
+<p>Script did not run.</p>
+<p>To run this test again, delete private data and then load this test again.</p>
+<script>
+var p = document.querySelector('p');
+if (sessionStorage.testHasBeenLoadedBefore) {
+ var worker = new Worker('application-cache-dedicated.js');
+ worker.onmessage = function(e) {
+ p.textContent = 'PASS';
+ }
+ setTimeout(function(){
+ if (p.textContent != 'PASS')
+ p.textContent = 'FAIL (got no message from worker)';
+ }, 250);
+} else {
+ sessionStorage.testHasBeenLoadedBefore = true;
+ p.textContent = 'Enable offline mode and then reload this test. It should say PASS.';
+}
+</script>
diff --git a/testing/web-platform/tests/workers/non-automated/application-cache-dedicated.js b/testing/web-platform/tests/workers/non-automated/application-cache-dedicated.js
new file mode 100644
index 000000000..2318c2e26
--- /dev/null
+++ b/testing/web-platform/tests/workers/non-automated/application-cache-dedicated.js
@@ -0,0 +1 @@
+postMessage(1); \ No newline at end of file
diff --git a/testing/web-platform/tests/workers/non-automated/cache.manifest b/testing/web-platform/tests/workers/non-automated/cache.manifest
new file mode 100644
index 000000000..8d80e03b2
--- /dev/null
+++ b/testing/web-platform/tests/workers/non-automated/cache.manifest
@@ -0,0 +1,3 @@
+CACHE MANIFEST
+application-cache-dedicated.html
+application-cache-dedicated.js
diff --git a/testing/web-platform/tests/workers/non-automated/infinite-nested.html b/testing/web-platform/tests/workers/non-automated/infinite-nested.html
new file mode 100644
index 000000000..3ff3edb35
--- /dev/null
+++ b/testing/web-platform/tests/workers/non-automated/infinite-nested.html
@@ -0,0 +1,12 @@
+<!doctype html>
+<title>infinite nested workers</title>
+<p>There number below should be increasing (ideally never-ending).</p>
+<div>0</div>
+<script>
+var worker = new Worker('infinite-nested.js');
+var div = document.getElementsByTagName('div')[0];
+var i = 0;
+worker.onmessage = function(e) {
+ div.textContent = i++;
+}
+</script> \ No newline at end of file
diff --git a/testing/web-platform/tests/workers/non-automated/infinite-nested.js b/testing/web-platform/tests/workers/non-automated/infinite-nested.js
new file mode 100644
index 000000000..137dd0a2e
--- /dev/null
+++ b/testing/web-platform/tests/workers/non-automated/infinite-nested.js
@@ -0,0 +1,5 @@
+postMessage(1);
+var w = new Worker('infinite-nested.js');
+w.onmessage = function(e) {
+ postMessage(e.data);
+} \ No newline at end of file
diff --git a/testing/web-platform/tests/workers/non-automated/infinite-sibling-and-nested.html b/testing/web-platform/tests/workers/non-automated/infinite-sibling-and-nested.html
new file mode 100644
index 000000000..463546cc9
--- /dev/null
+++ b/testing/web-platform/tests/workers/non-automated/infinite-sibling-and-nested.html
@@ -0,0 +1,12 @@
+<!doctype html>
+<title>infinite sibling and nested workers</title>
+<p>The number below should be increasing (ideally never-ending).</p>
+<div>0</div>
+<script>
+var worker = new Worker('infinite-sibling-and-nested.js');
+var div = document.getElementsByTagName('div')[0];
+var i = 0;
+worker.onmessage = function(e) {
+ div.textContent = i + e.data;
+}
+</script>
diff --git a/testing/web-platform/tests/workers/non-automated/infinite-sibling-and-nested.js b/testing/web-platform/tests/workers/non-automated/infinite-sibling-and-nested.js
new file mode 100644
index 000000000..cf7b794a4
--- /dev/null
+++ b/testing/web-platform/tests/workers/non-automated/infinite-sibling-and-nested.js
@@ -0,0 +1,8 @@
+function createWorker() {
+ var worker = new Worker('infinite-nested.js?' + Math.random());
+ worker.onmessage = function(e) {
+ postMessage(e.data);
+ createWorker();
+ }
+}
+createWorker(); \ No newline at end of file
diff --git a/testing/web-platform/tests/workers/non-automated/infinite-sibling.html b/testing/web-platform/tests/workers/non-automated/infinite-sibling.html
new file mode 100644
index 000000000..edcb8d707
--- /dev/null
+++ b/testing/web-platform/tests/workers/non-automated/infinite-sibling.html
@@ -0,0 +1,12 @@
+<!doctype html>
+<title>infinite sibling workers</title>
+<p>The number below should be increasing (ideally never-ending).</p>
+<div>0</div>
+<script>
+var worker = new Worker('infinite-sibling.js');
+var div = document.getElementsByTagName('div')[0];
+var i = 0;
+worker.onmessage = function(e) {
+ div.textContent = i + e.data;
+}
+</script>
diff --git a/testing/web-platform/tests/workers/non-automated/infinite-sibling.js b/testing/web-platform/tests/workers/non-automated/infinite-sibling.js
new file mode 100644
index 000000000..6424f7009
--- /dev/null
+++ b/testing/web-platform/tests/workers/non-automated/infinite-sibling.js
@@ -0,0 +1,8 @@
+function createWorker() {
+ var worker = new Worker('post-a-1.js?' + Math.random());
+ worker.onmessage = function(e) {
+ postMessage(e.data);
+ createWorker();
+ }
+}
+createWorker(); \ No newline at end of file
diff --git a/testing/web-platform/tests/workers/non-automated/navigator-onLine.html b/testing/web-platform/tests/workers/non-automated/navigator-onLine.html
new file mode 100644
index 000000000..d71aeaf0a
--- /dev/null
+++ b/testing/web-platform/tests/workers/non-automated/navigator-onLine.html
@@ -0,0 +1,46 @@
+<!--
+if ('onmessage' in self) { // dedicated worker
+ onmessage = function(e) {
+ postMessage(navigator.onLine);
+ }
+} else { // shared worker
+ onconnect = function(e) {
+ e.ports[0].onmessage = function(e) {
+ this.postMessage(navigator.onLine);
+ }
+ }
+}
+/*
+-->
+<!doctype html>
+<title>navigator.onLine in dedicated worker</title>
+<pre>Log:
+</pre>
+<script>
+var pre = document.querySelector('pre');
+var worker, shared;
+try { worker = new Worker('#'); } catch(e) { pre.textContent += '\nnew Worker threw: ' + e.message; }
+try { shared = new SharedWorker('#', ''); } catch(e) { pre.textContent += '\nnew SharedWorker threw: ' + e.message; }
+if (worker) {
+ worker.onmessage = function(e) {
+ pre.textContent += '\ndedicated worker: ' + e.data;
+ }
+}
+if (shared) {
+ shared.port.onmessage = function(e) {
+ pre.textContent += '\nshared worker: ' + e.data;
+ }
+}
+function update() {
+ pre.textContent += '\n\n' + new Date() + '\n<script>: ' + navigator.onLine;
+ if (worker) worker.postMessage(1);
+ if (shared) shared.port.postMessage(1);
+}
+update();
+ononline = onoffline = update;
+</script>
+<p>As you go online and offline, the log should be filled with the correct status of navigator.onLine.</p>
+<p><button onclick="update()">Check navigator.onLine status</button></p>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/non-automated/post-a-1.js b/testing/web-platform/tests/workers/non-automated/post-a-1.js
new file mode 100644
index 000000000..2318c2e26
--- /dev/null
+++ b/testing/web-platform/tests/workers/non-automated/post-a-1.js
@@ -0,0 +1 @@
+postMessage(1); \ No newline at end of file
diff --git a/testing/web-platform/tests/workers/postMessage_DataCloneErr.htm b/testing/web-platform/tests/workers/postMessage_DataCloneErr.htm
new file mode 100644
index 000000000..24093ce4e
--- /dev/null
+++ b/testing/web-platform/tests/workers/postMessage_DataCloneErr.htm
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<title> postMessage() with WorkerNavigator </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var worker = new Worker("./support/WorkerDataCloneErr.js");
+ worker.onmessage = t.step_func_done(function(e) {
+ assert_equals(e.data, "Pass");
+ });
+});
+</script>
diff --git a/testing/web-platform/tests/workers/postMessage_clone_port.htm b/testing/web-platform/tests/workers/postMessage_clone_port.htm
new file mode 100644
index 000000000..b1d7b84e3
--- /dev/null
+++ b/testing/web-platform/tests/workers/postMessage_clone_port.htm
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<title> postMessage(): clone a port </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var channelA = new MessageChannel();
+ var channelB = new MessageChannel();
+ var originalPort = channelB.port2;
+ channelA.port2.onmessage = t.step_func(function(e) {
+ assert_equals(e.data, "ports");
+ var clonedPort = e.ports[0];
+ assert_not_equals(clonedPort, originalPort, "new cloned port object should not equal to the original port!");
+ clonedPort.onmessage = t.step_func_done(function(e) {
+ assert_equals(e.data, "ping", "Data sent through remote port is received by the new cloned port");
+ });
+ });
+ channelA.port1.postMessage("ports", [channelB.port2]);
+ channelB.port1.postMessage("ping");
+});
+</script>
diff --git a/testing/web-platform/tests/workers/postMessage_clone_port_error.htm b/testing/web-platform/tests/workers/postMessage_clone_port_error.htm
new file mode 100644
index 000000000..30012962d
--- /dev/null
+++ b/testing/web-platform/tests/workers/postMessage_clone_port_error.htm
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<title> postMessage(): cloning source port </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+test(function() {
+ var channel = new MessageChannel();
+ channel.port1.start();
+ assert_throws("DataCloneError", function() {
+ channel.port1.postMessage("ports", [channel.port1]);
+ });
+});
+</script>
diff --git a/testing/web-platform/tests/workers/postMessage_event_properties.htm b/testing/web-platform/tests/workers/postMessage_event_properties.htm
new file mode 100644
index 000000000..8122413de
--- /dev/null
+++ b/testing/web-platform/tests/workers/postMessage_event_properties.htm
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<title> postMessage(): MessageEvent properties </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var channel = new MessageChannel();
+ var targetPort = channel.port2;
+ targetPort.start();
+ targetPort.addEventListener("message", t.step_func_done(function (evt) {
+ assert_class_string(evt, "MessageEvent");
+ assert_equals(evt.type, "message");
+ assert_false(evt.bubbles, "bubbles should be false");
+ assert_false(evt.cancelable, "cancelable should be false");
+ assert_equals(evt.data, "ping", "data");
+ assert_equals(evt.origin, "", "origin");
+ assert_equals(evt.lastEventId, "", "lastEventId");
+ assert_equals(evt.source, null, "source");
+ assert_array_equals(evt.ports, [], "ports");
+ }), true);
+ channel.port1.postMessage("ping");
+});
+</script>
diff --git a/testing/web-platform/tests/workers/postMessage_ports_readonly_array.htm b/testing/web-platform/tests/workers/postMessage_ports_readonly_array.htm
new file mode 100644
index 000000000..5e2b9054a
--- /dev/null
+++ b/testing/web-platform/tests/workers/postMessage_ports_readonly_array.htm
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<title> postMessage(): read-only ports array </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var channel = new MessageChannel();
+ var targetPort = channel.port2;
+ targetPort.start();
+ targetPort.addEventListener("message", t.step_func_done(function(e) {
+ var channel3 = new MessageChannel();
+ e.ports.push(channel3.port1);
+ e.ports.push(channel3.port1);
+ assert_equals(e.ports.length, 1, "ports is a read only array with length == 1.");
+ }), true);
+ var channel2 = new MessageChannel();
+ channel.port1.postMessage("ports", [channel2.port1]);
+});
+</script>
diff --git a/testing/web-platform/tests/workers/postMessage_target_source.htm b/testing/web-platform/tests/workers/postMessage_target_source.htm
new file mode 100644
index 000000000..7d684916d
--- /dev/null
+++ b/testing/web-platform/tests/workers/postMessage_target_source.htm
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<title> postMessage(): target port and source port </title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var channel = new MessageChannel();
+ var source = channel.port1;
+ var target = channel.port2;
+ target.start();
+ target.addEventListener("message", t.step_func_done(function(e) {
+ assert_equals(e.target, target);
+ assert_not_equals(e.target, source);
+ }), true);
+ source.postMessage("ping");
+});
+</script>
diff --git a/testing/web-platform/tests/workers/semantics/encodings/001.html b/testing/web-platform/tests/workers/semantics/encodings/001.html
new file mode 100644
index 000000000..0ebec0b03
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/encodings/001.html
@@ -0,0 +1,21 @@
+<!--
+postMessage('Ã¥');
+/*
+-->
+<!doctype html>
+<title>encoding, dedicated worker</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function() {
+ var worker = new Worker('#');
+ worker.onmessage = this.step_func(function(e) {
+ assert_equals(e.data, '\u00e5');
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//--> \ No newline at end of file
diff --git a/testing/web-platform/tests/workers/semantics/encodings/001.html.headers b/testing/web-platform/tests/workers/semantics/encodings/001.html.headers
new file mode 100644
index 000000000..2340a89c9
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/encodings/001.html.headers
@@ -0,0 +1 @@
+Content-Type: text/html; charset=windows-1252
diff --git a/testing/web-platform/tests/workers/semantics/encodings/002.html b/testing/web-platform/tests/workers/semantics/encodings/002.html
new file mode 100644
index 000000000..fdcc4f0a2
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/encodings/002.html
@@ -0,0 +1,23 @@
+<!--
+onconnect = function(e) {
+ e.ports[0].postMessage('Ã¥');
+}
+/*
+-->
+<!doctype html>
+<title>encoding, shared worker</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function() {
+ var worker = new SharedWorker('#', '');
+ worker.port.onmessage = this.step_func(function(e) {
+ assert_equals(e.data, '\u00e5');
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//--> \ No newline at end of file
diff --git a/testing/web-platform/tests/workers/semantics/encodings/002.html.headers b/testing/web-platform/tests/workers/semantics/encodings/002.html.headers
new file mode 100644
index 000000000..2340a89c9
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/encodings/002.html.headers
@@ -0,0 +1 @@
+Content-Type: text/html; charset=windows-1252
diff --git a/testing/web-platform/tests/workers/semantics/encodings/003-1.py b/testing/web-platform/tests/workers/semantics/encodings/003-1.py
new file mode 100644
index 000000000..1e899aac2
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/encodings/003-1.py
@@ -0,0 +1,4 @@
+ # -*- coding: utf-8 -*-
+
+def main(request, response):
+ return "PASS" if request.GET.first('x') == 'Ã¥' else "FAIL"
diff --git a/testing/web-platform/tests/workers/semantics/encodings/003.html b/testing/web-platform/tests/workers/semantics/encodings/003.html
new file mode 100644
index 000000000..a0f964c3c
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/encodings/003.html
@@ -0,0 +1,26 @@
+<!--
+var xhr = new XMLHttpRequest();
+xhr.open('GET', '003-1.py?x=Ã¥', false);
+xhr.send();
+var passed = xhr.responseText == 'PASS';
+postMessage(passed);
+
+/*
+-->
+<!doctype html>
+<title>URL encoding, dedicated worker</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function() {
+ var worker = new Worker('#');
+ worker.onmessage = this.step_func(function(e) {
+ assert_true(e.data);
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/semantics/encodings/004.html b/testing/web-platform/tests/workers/semantics/encodings/004.html
new file mode 100644
index 000000000..bb1442633
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/encodings/004.html
@@ -0,0 +1,27 @@
+<!--
+onconnect = function(e) {
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', '003-1.py?x=Ã¥', false);
+ xhr.send();
+ var passed = xhr.responseText == 'PASS';
+ e.ports[0].postMessage(passed);
+}
+/*
+-->
+<!doctype html>
+<title>URL encoding, shared worker</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function() {
+ var worker = new SharedWorker('#');
+ worker.port.onmessage = this.step_func(function(e) {
+ assert_true(e.data);
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//--> \ No newline at end of file
diff --git a/testing/web-platform/tests/workers/semantics/encodings/004.worker.js b/testing/web-platform/tests/workers/semantics/encodings/004.worker.js
new file mode 100644
index 000000000..28489a572
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/encodings/004.worker.js
@@ -0,0 +1,5 @@
+importScripts("/resources/testharness.js");
+test(function() {
+ assert_equals("ÿ", "\ufffd");
+}, "Decoding invalid utf-8");
+done();
diff --git a/testing/web-platform/tests/workers/semantics/interface-objects/001.worker.js b/testing/web-platform/tests/workers/semantics/interface-objects/001.worker.js
new file mode 100644
index 000000000..23df42036
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/interface-objects/001.worker.js
@@ -0,0 +1,79 @@
+importScripts("/resources/testharness.js");
+var expected = [
+ // https://html.spec.whatwg.org/
+ "WorkerGlobalScope",
+ "DedicatedWorkerGlobalScope",
+ "Worker",
+ "SharedWorker",
+ "MessagePort",
+ "MessageEvent",
+ "WorkerNavigator",
+ "MessageChannel",
+ "WorkerLocation",
+ "ImageData",
+ "ImageBitmap",
+ "CanvasPath",
+ "Path2D",
+ "PromiseRejectionEvent",
+ "EventSource",
+ "WebSocket",
+ "CloseEvent",
+ "BroadcastChannel",
+ // https://tc39.github.io/ecma262/
+ "ArrayBuffer",
+ "Int8Array",
+ "Uint8Array",
+ "Uint8ClampedArray",
+ "Int16Array",
+ "Uint16Array",
+ "Int32Array",
+ "Uint32Array",
+ "Float32Array",
+ "Float64Array",
+ "DataView",
+ // https://xhr.spec.whatwg.org/
+ "XMLHttpRequestEventTarget",
+ "XMLHttpRequestUpload",
+ "XMLHttpRequest",
+ "ProgressEvent",
+ "FormData",
+ // https://url.spec.whatwg.org/
+ "URL",
+ "URLSearchParams",
+ // https://w3c.github.io/FileAPI/
+ "File",
+ "Blob",
+ "FileList",
+ "FileReader",
+ "FileReaderSync",
+ // https://dom.spec.whatwg.org/
+ "EventTarget",
+ "ErrorEvent",
+ "Event",
+ "CustomEvent",
+ // http://heycam.github.io/webidl/
+ "DOMException",
+ // https://streams.spec.whatwg.org/
+ "ReadableStream",
+ "WritableStream",
+ "ByteLengthQueuingStrategy",
+ "CountQueuingStrategy",
+ // http://w3c.github.io/IndexedDB/
+ "IDBRequest",
+ "IDBOpenDBRequest",
+ "IDBVersionChangeEvent",
+ "IDBFactory",
+ "IDBDatabase",
+ "IDBObjectStore",
+ "IDBIndex",
+ "IDBKeyRange",
+ "IDBCursor",
+ "IDBCursorWithValue",
+ "IDBTransaction",
+];
+for (var i = 0; i < expected.length; ++i) {
+ test(function () {
+ assert_own_property(self, expected[i]);
+ }, "The " + expected[i] + " interface object should be exposed.");
+}
+done();
diff --git a/testing/web-platform/tests/workers/semantics/interface-objects/002.worker.js b/testing/web-platform/tests/workers/semantics/interface-objects/002.worker.js
new file mode 100644
index 000000000..0f514988b
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/interface-objects/002.worker.js
@@ -0,0 +1,49 @@
+importScripts("/resources/testharness.js");
+var unexpected = [
+ // https://html.spec.whatwg.org/
+ "SharedWorkerGlobalScope",
+ "AbstractView",
+ "AbstractWorker",
+ "ApplicationCache",
+ "Location",
+ "Navigator",
+ "Audio",
+ "HTMLCanvasElement",
+ "Path",
+ "TextMetrics",
+ "CanvasProxy",
+ "CanvasRenderingContext2D",
+ "DrawingStyle",
+ "CanvasGradient",
+ "CanvasPattern",
+ "PopStateEvent",
+ "HashChangeEvent",
+ "PageTransitionEvent",
+ // https://dom.spec.whatwg.org/
+ "DOMImplementation",
+ // https://streams.spec.whatwg.org/
+ "ReadableStreamDefaultReader",
+ "ReadableStreamBYOBReader",
+ "ReadableStreamDefaultController",
+ "ReadableByteStreamController",
+ "WritableStreamDefaultWriter",
+ "WritableStreamDefaultController",
+ // http://w3c.github.io/IndexedDB/
+ "IDBEnvironment",
+ // https://www.w3.org/TR/2010/NOTE-webdatabase-20101118/
+ "Database",
+ // https://w3c.github.io/uievents/
+ "UIEvent",
+ "FocusEvent",
+ "MouseEvent",
+ "WheelEvent",
+ "InputEvent",
+ "KeyboardEvent",
+ "CompositionEvent",
+];
+for (var i = 0; i < unexpected.length; ++i) {
+ test(function () {
+ assert_false(unexpected[i] in self);
+ }, "The " + unexpected[i] + " interface object should not be exposed.");
+}
+done();
diff --git a/testing/web-platform/tests/workers/semantics/interface-objects/003.html b/testing/web-platform/tests/workers/semantics/interface-objects/003.html
new file mode 100644
index 000000000..5277825db
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/interface-objects/003.html
@@ -0,0 +1,106 @@
+<!--
+onconnect = function(e) {
+ var expected = [
+ // https://html.spec.whatwg.org/
+ "ApplicationCache",
+ "WorkerGlobalScope",
+ "SharedWorkerGlobalScope",
+ "Worker",
+ "SharedWorker",
+ "MessagePort",
+ "MessageEvent",
+ "WorkerNavigator",
+ "MessageChannel",
+ "WorkerLocation",
+ "ImageData",
+ "ImageBitmap",
+ "CanvasPath",
+ "Path2D",
+ "PromiseRejectionEvent",
+ "EventSource",
+ "WebSocket",
+ "CloseEvent",
+ "BroadcastChannel",
+ // https://tc39.github.io/ecma262/
+ "ArrayBuffer",
+ "Int8Array",
+ "Uint8Array",
+ "Uint8ClampedArray",
+ "Int16Array",
+ "Uint16Array",
+ "Int32Array",
+ "Uint32Array",
+ "Float32Array",
+ "Float64Array",
+ "DataView",
+ // https://xhr.spec.whatwg.org/
+ "XMLHttpRequestEventTarget",
+ "XMLHttpRequestUpload",
+ "XMLHttpRequest",
+ "ProgressEvent",
+ "FormData",
+ // https://url.spec.whatwg.org/
+ "URL",
+ "URLSearchParams",
+ // https://w3c.github.io/FileAPI/
+ "File",
+ "Blob",
+ "FileList",
+ "FileReader",
+ "FileReaderSync",
+ // https://dom.spec.whatwg.org/
+ "EventTarget",
+ "ErrorEvent",
+ "Event",
+ "CustomEvent",
+ // http://heycam.github.io/webidl/
+ "DOMException",
+ // https://streams.spec.whatwg.org/
+ "ReadableStream",
+ "WritableStream",
+ "ByteLengthQueuingStrategy",
+ "CountQueuingStrategy",
+ // http://w3c.github.io/IndexedDB/
+ "IDBRequest",
+ "IDBOpenDBRequest",
+ "IDBVersionChangeEvent",
+ "IDBFactory",
+ "IDBDatabase",
+ "IDBObjectStore",
+ "IDBIndex",
+ "IDBKeyRange",
+ "IDBCursor",
+ "IDBCursorWithValue",
+ "IDBTransaction",
+ ];
+ var result = [];
+ for (var i = 0; i < expected.length; ++i) {
+ result.push([expected[i], expected[i] in self]);
+ }
+ e.ports[0].postMessage(result);
+}
+/*
+-->
+<!doctype html>
+<title>available interface objects in shared worker</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+setup(function() {
+ window.worker = new SharedWorker('#');
+ worker.port.onmessage = function(e) {
+ var result = e.data;
+ for (var i = 0; i < result.length; ++i) {
+ test(function() {
+ assert_true(result[i][1]);
+ }, "The " + result[i][0] + " interface object should be exposed");
+ }
+ done();
+ }
+}, {explicit_done: true});
+</script>
+<!--
+*/
+//-->
+
diff --git a/testing/web-platform/tests/workers/semantics/interface-objects/004.html b/testing/web-platform/tests/workers/semantics/interface-objects/004.html
new file mode 100644
index 000000000..2e4387ede
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/interface-objects/004.html
@@ -0,0 +1,73 @@
+<!--
+onconnect = function(e) {
+ var unexpected = [
+ // https://html.spec.whatwg.org/
+ "DedicatedWorkerGlobalScope",
+ "AbstractView",
+ "AbstractWorker",
+ "Location",
+ "Navigator",
+ "DOMImplementation",
+ "Audio",
+ "HTMLCanvasElement",
+ "Path",
+ "TextMetrics",
+ "CanvasProxy",
+ "CanvasRenderingContext2D",
+ "DrawingStyle",
+ "CanvasGradient",
+ "CanvasPattern",
+ "PopStateEvent",
+ "HashChangeEvent",
+ "PageTransitionEvent",
+ // https://streams.spec.whatwg.org/
+ "ReadableStreamDefaultReader",
+ "ReadableStreamBYOBReader",
+ "ReadableStreamDefaultController",
+ "ReadableByteStreamController",
+ "WritableStreamDefaultWriter",
+ "WritableStreamDefaultController",
+ // http://w3c.github.io/IndexedDB/
+ "IDBEnvironment",
+ // https://www.w3.org/TR/2010/NOTE-webdatabase-20101118/
+ "Database",
+ // https://w3c.github.io/uievents/
+ "UIEvent",
+ "FocusEvent",
+ "MouseEvent",
+ "WheelEvent",
+ "InputEvent",
+ "KeyboardEvent",
+ "CompositionEvent",
+ ];
+ var result = [];
+ for (var i = 0; i < unexpected.length; ++i) {
+ result.push([unexpected[i], unexpected[i] in self]);
+ }
+ e.ports[0].postMessage(result);
+}
+/*
+-->
+<!doctype html>
+<title>unavailable interface objects in shared worker</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+setup(function() {
+ window.worker = new SharedWorker('#');
+ worker.port.onmessage = function(e) {
+ var result = e.data;
+ for (var i = 0; i < result.length; ++i) {
+ test(function() {
+ assert_false(result[i][1]);
+ }, "The " + result[i][0] + " interface object should not be exposed");
+ }
+ done();
+ }
+}, {explicit_done: true});
+</script>
+<!--
+*/
+//-->
+
diff --git a/testing/web-platform/tests/workers/semantics/multiple-workers/001.html b/testing/web-platform/tests/workers/semantics/multiple-workers/001.html
new file mode 100644
index 000000000..82ddcc3c1
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/multiple-workers/001.html
@@ -0,0 +1,41 @@
+<!--
+if ('onmessage' in self) { // dedicated worker
+ onmessage = function(e) {
+ postMessage(e.data);
+ }
+} else { // shared worker
+ onconnect = function(e) {
+ e.ports[0].onmessage = function(e) {
+ this.postMessage(e.data);
+ }
+ }
+}
+/*
+-->
+<!doctype html>
+<title>dedicated and shared worker in same page</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function() {
+ var worker = new Worker('#');
+ worker.onmessage = this.step_func(function(e) {
+ assert_equals(e.data, 'dedicated');
+ this.done();
+ });
+ worker.postMessage('dedicated');
+}, 'dedicated');
+async_test(function() {
+ var shared = new SharedWorker('#', '');
+ shared.port.onmessage = this.step_func(function(e) {
+ assert_equals(e.data, 'shared');
+ this.done();
+ });
+ shared.port.postMessage('shared');
+}, 'shared');
+</script>
+<!--
+*/
+//-->
+
diff --git a/testing/web-platform/tests/workers/semantics/multiple-workers/002.html b/testing/web-platform/tests/workers/semantics/multiple-workers/002.html
new file mode 100644
index 000000000..9ab1f54f4
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/multiple-workers/002.html
@@ -0,0 +1,28 @@
+<!--
+postMessage(1);
+/*
+-->
+<!doctype html>
+<title>creating 3 sibling dedicated workers</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function(t) {
+ var w1 = new Worker('#');
+ var w2 = new Worker('#');
+ var w3 = new Worker('#');
+ var got = [false, false, false];
+ var check_done = t.step_func(function() {
+ if (got.every(function(x) {return x})) {
+ t.done();
+ }
+ });
+ w1.onmessage = t.step_func(function(e) {got[0] = true; check_done()});
+ w2.onmessage = t.step_func(function(e) {got[1] = true; check_done()});
+ w3.onmessage = t.step_func(function(e) {got[2] = true; check_done()});
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/semantics/multiple-workers/003.html b/testing/web-platform/tests/workers/semantics/multiple-workers/003.html
new file mode 100644
index 000000000..85c688bc0
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/multiple-workers/003.html
@@ -0,0 +1,34 @@
+<!--
+if (location.hash == '#1') {
+ var w2 = new Worker('#2');
+ w2.onmessage = function(e) {
+ postMessage('1'+e.data);
+ }
+} else if (location.hash == '#2') {
+ var w3 = new Worker('#3');
+ w3.onmessage = function(e) {
+ postMessage('2'+e.data);
+ }
+} else {
+ postMessage('3');
+}
+
+/*
+-->
+<!doctype html>
+<title>creating 3 nested dedicated workers</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function() {
+ var w1 = new Worker('#1');
+ w1.onmessage = this.step_func(function(e) {
+ assert_equals(e.data, '123');
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/semantics/multiple-workers/004-1.html b/testing/web-platform/tests/workers/semantics/multiple-workers/004-1.html
new file mode 100644
index 000000000..eac038c5b
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/multiple-workers/004-1.html
@@ -0,0 +1,7 @@
+<!doctype html>
+<title></title>
+<script>
+window.onload = function() {
+ var w=new SharedWorker('004-2.js', 'x');
+};
+</script>
diff --git a/testing/web-platform/tests/workers/semantics/multiple-workers/004-2.js b/testing/web-platform/tests/workers/semantics/multiple-workers/004-2.js
new file mode 100644
index 000000000..e59cd6927
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/multiple-workers/004-2.js
@@ -0,0 +1,6 @@
+var port;
+onconnect = function(e) {
+ if (!port)
+ port = e.ports[0];
+ port.postMessage(1);
+} \ No newline at end of file
diff --git a/testing/web-platform/tests/workers/semantics/multiple-workers/004.html b/testing/web-platform/tests/workers/semantics/multiple-workers/004.html
new file mode 100644
index 000000000..c47337008
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/multiple-workers/004.html
@@ -0,0 +1,34 @@
+<!doctype html>
+<title>shared worker with multiple documents</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+var i = 0;
+var load_count = 0;
+
+var w1 = new SharedWorker('004-2.js', 'x');
+w1.port.onmessage = function(e) {
+ i++;
+ check_result();
+};
+
+
+function iframe_loaded() {
+ load_count++;
+ check_result();
+}
+
+function check_result() {
+ //timeout to allow for extra, unexpected, messages to arrive
+ if (i == 3 && load_count == 2) {
+ setTimeout(function() {
+ assert_equals(load_count, 2);
+ assert_equals(i, 3);
+ done();
+ }, 500);
+ }
+}
+</script>
+<iframe src=004-1.html onload="iframe_loaded()"></iframe>
+<iframe src=004-1.html onload="iframe_loaded()"></iframe>
diff --git a/testing/web-platform/tests/workers/semantics/multiple-workers/005.html b/testing/web-platform/tests/workers/semantics/multiple-workers/005.html
new file mode 100644
index 000000000..289c25ec6
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/multiple-workers/005.html
@@ -0,0 +1,37 @@
+<!--
+if (location.hash == '#1') {
+ var w2 = new SharedWorker('#2');
+ w2.port.onmessage = function(e) {
+ postMessage('1'+e.data);
+ }
+} else if (location.hash == '#2') {
+ onconnect = function(e) {
+ var port = e.ports[0];
+ var w3 = new Worker('#3');
+ w3.onmessage = function(e) {
+ port.postMessage('2'+e.data);
+ }
+ }
+} else {
+ postMessage('3');
+}
+
+/*
+-->
+<!doctype html>
+<title>dedicated worker in shared worker in dedicated worker</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function() {
+ var w1 = new Worker('#1');
+ w1.onmessage = this.step_func(function(e) {
+ assert_equals(e.data, '123');
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/semantics/multiple-workers/006-1.js b/testing/web-platform/tests/workers/semantics/multiple-workers/006-1.js
new file mode 100644
index 000000000..6c1ed9323
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/multiple-workers/006-1.js
@@ -0,0 +1,3 @@
+ onconnect = function(e) {
+ e.ports[0].postMessage('3');
+ } \ No newline at end of file
diff --git a/testing/web-platform/tests/workers/semantics/multiple-workers/006.html b/testing/web-platform/tests/workers/semantics/multiple-workers/006.html
new file mode 100644
index 000000000..ef2124256
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/multiple-workers/006.html
@@ -0,0 +1,35 @@
+<!--
+if (location.hash == '#1') {
+ onconnect = function(e) {
+ var port = e.ports[0];
+ var w2 = new Worker('#2');
+ w2.onmessage = function(e) {
+ port.postMessage('1'+e.data);
+ }
+ }
+} else if (location.hash == '#2') {
+ var w3 = new SharedWorker('006-1.js');
+ w3.port.onmessage = function(e) {
+ postMessage('2'+e.data);
+ }
+}
+
+/*
+-->
+<!doctype html>
+<title>shared worker in dedicated worker in shared worker</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function() {
+ var w1 = new SharedWorker('#1');
+ w1.port.onmessage = this.step_func(function(e) {
+ assert_equals(e.data, '123');
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/semantics/multiple-workers/007.html b/testing/web-platform/tests/workers/semantics/multiple-workers/007.html
new file mode 100644
index 000000000..e99345073
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/multiple-workers/007.html
@@ -0,0 +1,39 @@
+<!--
+if (location.hash == '#1') {
+ onconnect = function(e) {
+ var port = e.ports[0];
+ var w2 = new Worker('#2');
+ w2.onmessage = function(e) {
+ port.postMessage('1'+e.data);
+ }
+ }
+} else if (location.hash == '#2') {
+ var w3 = new SharedWorker('#3');
+ w3.port.onmessage = function(e) {
+ postMessage('2'+e.data);
+ }
+} else {
+ onconnect = function(e) {
+ e.ports[0].postMessage('3');
+ }
+}
+
+/*
+-->
+<!doctype html>
+<title>shared worker in dedicated worker in shared worker</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function() {
+ var w1 = new SharedWorker('#1');
+ w1.port.onmessage = this.step_func(function(e) {
+ assert_equals(e.data, '123');
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/semantics/multiple-workers/008-1.html b/testing/web-platform/tests/workers/semantics/multiple-workers/008-1.html
new file mode 100644
index 000000000..82a8a3835
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/multiple-workers/008-1.html
@@ -0,0 +1,8 @@
+<!doctype html>
+<title>008-1</title>
+<script>
+var w1 = new SharedWorker('008.html#');
+w1.port.onmessage = function(e) {
+ e.ports[0].postMessage(2);
+}
+</script> \ No newline at end of file
diff --git a/testing/web-platform/tests/workers/semantics/multiple-workers/008.html b/testing/web-platform/tests/workers/semantics/multiple-workers/008.html
new file mode 100644
index 000000000..fbb41e0d0
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/multiple-workers/008.html
@@ -0,0 +1,31 @@
+<!--
+var channel = new MessageChannel();
+var i = 0;
+onconnect = function(e) {
+ i++;
+ e.ports[0].postMessage(1, [channel['port' + i]]);
+}
+
+/*
+-->
+<!doctype html>
+<title>messagechannel in shared worker</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<iframe src=008-1.html></iframe>
+<script>
+var t = async_test();
+onload = t.step_func(function() {
+ var w1 = new SharedWorker('#');
+ w1.port.onmessage = this.step_func(function(e) {
+ e.ports[0].onmessage = this.step_func(function(e) {
+ assert_equals(e.data, 2);
+ this.done();
+ });
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/semantics/navigation/001-1.html b/testing/web-platform/tests/workers/semantics/navigation/001-1.html
new file mode 100644
index 000000000..9d7ecee17
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/navigation/001-1.html
@@ -0,0 +1,23 @@
+<!--
+setInterval(function() { postMessage(new Date()) }, 10)
+/*
+-->
+<!doctype html>
+<title>001-1</title>
+<script>
+onload = function() {
+ var worker = new Worker('#');
+ worker.onmessage = function(e) {
+ var started = !!parent.date;
+ parent.date = e.data;
+ if (!started) {
+ parent.start_test()
+ }
+ }
+}
+</script>
+<a href='data:text/html,<title>foo</title><script>onload=function(){parent.after_load()}</script>'>link</a>
+<!--
+*/
+//-->
+
diff --git a/testing/web-platform/tests/workers/semantics/navigation/001.html b/testing/web-platform/tests/workers/semantics/navigation/001.html
new file mode 100644
index 000000000..658df0624
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/navigation/001.html
@@ -0,0 +1,36 @@
+<!--
+
+/*
+-->
+<!doctype html>
+<title>navigating</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+var date;
+var newDate;
+</script>
+<iframe></iframe>
+<script>
+var iframe = document.querySelector('iframe');
+onload = function() {
+ iframe.src = "001-1.html?" + Math.random();
+};
+var start_test = function() {
+ window[0].document.links[0].click();
+};
+var after_load = function() {
+ history.back();
+ newDate = new Date();
+ setTimeout(function() {
+ assert_greater_than(Number(date), Number(newDate));
+ assert_equals(window[0].document.title, '001-1');
+ done();
+ }, 2000);
+};
+</script>
+<!--
+*/
+//-->
+
diff --git a/testing/web-platform/tests/workers/semantics/navigation/002.html b/testing/web-platform/tests/workers/semantics/navigation/002.html
new file mode 100644
index 000000000..c0d5eb5c0
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/navigation/002.html
@@ -0,0 +1,36 @@
+<!--
+
+/*
+-->
+<!doctype html>
+<title>navigating 2</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+var date;
+var newDate;
+</script>
+<iframe></iframe>
+<script>
+var t = async_test();
+var iframe = document.querySelector('iframe');
+onload = t.step_func(function() {
+ iframe.src = "001-1.html?" + Math.random();
+});
+var start_test = t.step_func(function() {
+ window[0].document.links[0].click();
+});
+var after_load = t.step_func(function() {
+ newDate = new Date();
+ setTimeout(this.step_func(function() {
+ assert_less_than(Number(date), Number(newDate));
+ assert_equals(window[0].document.title, 'foo');
+ this.done();
+ }), 500);
+});
+</script>
+<!--
+*/
+//-->
+
diff --git a/testing/web-platform/tests/workers/semantics/reporting-errors/001.html b/testing/web-platform/tests/workers/semantics/reporting-errors/001.html
new file mode 100644
index 000000000..adba81f63
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/reporting-errors/001.html
@@ -0,0 +1,53 @@
+<!--
+var port;
+var timeout;
+onerror = function(a,b,c,d,e) {
+ // will return undefined, thus the error is "not handled"
+ // so error should be reported to the user, but this test doesn't check
+ // that.
+ // just make sure that this method is invoked with five arguments
+ clearTimeout(timeout);
+ var log = '';
+ if (arguments.length != 5)
+ log += 'got ' + arguments.length + ' arguments, expected 5. ';
+ if (typeof a != 'string')
+ log += 'first argument wasn\'t a string. ';
+ if (b != location.href)
+ log += 'second argument was ' + b + ', expected ' + location.href + '. ';
+ if (typeof c != 'number')
+ log += 'third argument wasn\'t a number. ';
+ if (typeof d != 'number')
+ log += 'fourth argument wasn\'t a number. ';
+ if (e != 42)
+ log += 'fifth argument wasn\'t the thrown exception. ';
+ port.postMessage(log);
+}
+onconnect = function (e) {
+ port = e.ports[0];
+ timeout = setTimeout(function() { port.postMessage('self.onerror was not invoked'); }, 250);
+ throw 42; // will "report the error"
+}
+
+
+/*
+-->
+<!doctype html>
+<title>shared worker, not handled</title>
+<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() {
+ window.onerror = this.step_func(function(a) {
+ assert_unreached('window.onerror invoked: ' + a);
+ });
+ var worker = new SharedWorker('#', '');
+ worker.port.onmessage = this.step_func_done(function(e) {
+ assert_equals(e.data, '');
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/semantics/reporting-errors/002.html b/testing/web-platform/tests/workers/semantics/reporting-errors/002.html
new file mode 100644
index 000000000..c2cd377b4
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/reporting-errors/002.html
@@ -0,0 +1,59 @@
+<!--
+var port;
+var timeout;
+addEventListener('error', function(e) {
+ // event is not canceled, thus the error is "not handled"
+ // so error should be reported to the user, but this test doesn't check
+ // that.
+ // just make sure that this event has the right properties
+ clearTimeout(timeout);
+ var log = '';
+ if (!self.ErrorEvent || Object.getPrototypeOf(e) != ErrorEvent.prototype)
+ log += 'event should be an ErrorEvent. ';
+ if (e.bubbles)
+ log += 'event should not bubble. ';
+ if (!e.cancelable)
+ log += 'event should be cancelable. ';
+ if (!e.isTrusted)
+ log += 'event should be trusted. ';
+ if (typeof e.message != 'string')
+ log += 'message wasn\'t a string. ';
+ if (e.filename != location.href)
+ log += 'filename was ' + e.filename + ', expected ' + location.href + '. ';
+ if (typeof e.lineno != 'number')
+ log += 'lineno wasn\'t a number. ';
+ if (typeof e.colno != 'number')
+ log += 'colno argument wasn\'t a number. ';
+ if (e.error != 42)
+ log += 'fifth argument wasn\'t the thrown exception. ';
+ port.postMessage(log);
+}, false);
+onconnect = function (e) {
+ port = e.ports[0];
+ timeout = setTimeout(function() { port.postMessage('No error event fired'); }, 250);
+ throw 42; // will "report the error"
+}
+
+
+/*
+-->
+<!doctype html>
+<title>shared worker, addEventListener</title>
+<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() {
+ window.onerror = this.step_func(function(a) {
+ assert_unreached('window.onerror invoked: ' + a);
+ });
+ var worker = new SharedWorker('#', '');
+ worker.port.onmessage = this.step_func_done(function(e) {
+ assert_equals(e.data, '');
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/semantics/reporting-errors/003.html b/testing/web-platform/tests/workers/semantics/reporting-errors/003.html
new file mode 100644
index 000000000..1b01c7caf
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/reporting-errors/003.html
@@ -0,0 +1,39 @@
+<!--
+onconnect = function (e) {
+ setTimeout(function() { e.ports[0].postMessage(''); }, 250);
+ y(); // will "report the error"
+ // onerror is null so it'll be "not handled", and the error should be
+ // reported to the user, although we don't test that here
+ // make sure we don't fire an error event on the message port or the
+ // SharedWorker object
+}
+
+
+/*
+-->
+<!doctype html>
+<title>shared worker, no error event on worker or port</title>
+<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() {
+ window.onerror = this.step_func(function(a) {
+ assert_unreached('window.onerror invoked: ' + a);
+ });
+ var worker = new SharedWorker('#', '');
+ worker.addEventListener('error', this.step_func(function(e) {
+ assert_unreached('error on worker');
+ }), false);
+ worker.port.addEventListener('error', this.step_func(function(e) {
+ assert_unreached('error on port');
+ }), false);
+ worker.port.onmessage = this.step_func_done(function(e) {
+ assert_equals(e.data, '');
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/semantics/reporting-errors/004-1.html b/testing/web-platform/tests/workers/semantics/reporting-errors/004-1.html
new file mode 100644
index 000000000..676c21e60
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/reporting-errors/004-1.html
@@ -0,0 +1,18 @@
+<!doctype html>
+<script>
+parent.t.step(function() {
+ window.onerror = this.step_func(function(a) {
+ assert_unreached('(inner) window.onerror invoked: ' + a);
+ });
+ var worker = new SharedWorker('004.html#', '');
+ worker.addEventListener('error', this.step_func(function(e) {
+ parent.assert_unreached('(inner) error on worker');
+ }), false);
+ worker.port.addEventListener('error', this.step_func(function(e) {
+ parent.assert_unreached('(inner) error on port');
+ }), false);
+ worker.port.onmessage = this.step_func_done(function(e) {
+ parent.assert_equals(e.data, 2);
+ });
+});
+</script>
diff --git a/testing/web-platform/tests/workers/semantics/reporting-errors/004.html b/testing/web-platform/tests/workers/semantics/reporting-errors/004.html
new file mode 100644
index 000000000..1dd1eb3b5
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/reporting-errors/004.html
@@ -0,0 +1,39 @@
+<!--
+var i = 0;
+onconnect = function (e) {
+ i++;
+ setTimeout(function() { e.ports[0].postMessage(i); }, 250);
+ y(); // will "report the error"
+}
+
+/*
+-->
+<!doctype html>
+<title>shared worker in two documents and window.onerror</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+setup({allow_uncaught_exception:true});
+var t = async_test(function() {
+ window.onerror = this.step_func(function(a) {
+ assert_unreached('(outer) window.onerror invoked: ' + a);
+ });
+ var worker = new SharedWorker('#', '');
+ worker.addEventListener('error', this.step_func(function(e) {
+ assert_unreached('(outer) error on worker');
+ }), false);
+ worker.port.addEventListener('error', this.step_func(function(e) {
+ assert_unreached('(outer) error on port');
+ }), false);
+ worker.port.onmessage = this.step_func(function(e) {
+ assert_equals(e.data, 1);
+ var iframe = document.createElement('iframe');
+ iframe.src = '004-1.html';
+ document.body.appendChild(iframe);
+ });
+});
+</script>
+<!--
+*/
+//-->
diff --git a/testing/web-platform/tests/workers/semantics/run-a-worker/001.html b/testing/web-platform/tests/workers/semantics/run-a-worker/001.html
new file mode 100644
index 000000000..aa0fc67ef
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/run-a-worker/001.html
@@ -0,0 +1,22 @@
+<!--
+postMessage(this === self);
+
+/*
+-->
+<!doctype html>
+<title>worker global scope, dedicated worker</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function() {
+ var worker = new Worker('#');
+ worker.onmessage = this.step_func(function(e) {
+ assert_true(e.data);
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//--> \ No newline at end of file
diff --git a/testing/web-platform/tests/workers/semantics/run-a-worker/002.html b/testing/web-platform/tests/workers/semantics/run-a-worker/002.html
new file mode 100644
index 000000000..3617ad727
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/run-a-worker/002.html
@@ -0,0 +1,24 @@
+<!--
+var passed = this === self;
+onconnect = function(e) {
+ e.ports[0].postMessage(passed);
+}
+/*
+-->
+<!doctype html>
+<title>worker global scope, shared worker</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+async_test(function() {
+ var worker = new SharedWorker('#');
+ worker.port.onmessage = this.step_func(function(e) {
+ assert_true(e.data);
+ this.done();
+ });
+});
+</script>
+<!--
+*/
+//--> \ No newline at end of file
diff --git a/testing/web-platform/tests/workers/semantics/run-a-worker/003.html b/testing/web-platform/tests/workers/semantics/run-a-worker/003.html
new file mode 100644
index 000000000..8c2f07ee7
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/run-a-worker/003.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<title>handling for 404 response</title>
+<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('404_worker');
+ worker.onerror = this.step_func(function(e) { this.done(); });
+}, 'worker');
+
+async_test(function() {
+ var shared = new SharedWorker('404_shared');
+ // NOTE: this handler will not fire, as runtime scripting errors
+ // are not forwarded to SharedWorker objects, but instead reported to the user directly.
+ shared.onerror = this.step_func(function(e) { assert_unreached(); }, shared, 'error');
+ step_timeout(this.step_func(function() { this.done(); }), 5000);
+}, 'shared');
+</script>
diff --git a/testing/web-platform/tests/workers/semantics/structured-clone/common.js b/testing/web-platform/tests/workers/semantics/structured-clone/common.js
new file mode 100644
index 000000000..56c2a3004
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/structured-clone/common.js
@@ -0,0 +1,596 @@
+function createWorker(msg) {
+ // `type` is defined in the test case itself
+ if (type == 'dedicated')
+ return new Worker('dedicated.js#'+encodeURIComponent(msg));
+ else if (type == 'shared')
+ return (new SharedWorker('shared.js#'+encodeURIComponent(msg))).port;
+ else
+ assert_unreached('invalid or missing `type`');
+}
+
+function check(msg, input, callback, test_obj) {
+ if (!test_obj)
+ test_obj = async_test(msg);
+ test_obj.step(function() {
+ var w = createWorker(msg);
+ if (typeof input === 'function')
+ input = this.step(input);
+ w.postMessage(input);
+ w.onmessage = this.step_func(function(ev) { callback(ev.data, input, this); });
+ });
+}
+
+function compare_primitive(actual, input, test_obj) {
+ assert_equals(actual, input);
+ if (test_obj)
+ test_obj.done();
+}
+function compare_Array(callback, callback_is_async) {
+ return function(actual, input, test_obj) {
+ if (typeof actual === 'string')
+ assert_unreached(actual);
+ assert_true(actual instanceof Array, 'instanceof Array');
+ assert_not_equals(actual, input);
+ assert_equals(actual.length, input.length, 'length');
+ callback(actual, input);
+ if (test_obj && !callback_is_async)
+ test_obj.done();
+ }
+}
+
+function compare_Object(callback, callback_is_async) {
+ return function(actual, input, test_obj) {
+ if (typeof actual === 'string')
+ assert_unreached(actual);
+ assert_true(actual instanceof Object, 'instanceof Object');
+ assert_false(actual instanceof Array, 'instanceof Array');
+ assert_not_equals(actual, input);
+ callback(actual, input);
+ if (test_obj && !callback_is_async)
+ test_obj.done();
+ }
+}
+
+function enumerate_props(compare_func, test_obj) {
+ return function(actual, input) {
+ for (var x in input) {
+ compare_func(actual[x], input[x], test_obj);
+ }
+ };
+}
+
+check('primitive undefined', undefined, compare_primitive);
+check('primitive null', null, compare_primitive);
+check('primitive true', true, compare_primitive);
+check('primitive false', false, compare_primitive);
+check('primitive string, empty string', '', compare_primitive);
+check('primitive string, lone high surrogate', '\uD800', compare_primitive);
+check('primitive string, lone low surrogate', '\uDC00', compare_primitive);
+check('primitive string, NUL', '\u0000', compare_primitive);
+check('primitive string, astral character', '\uDBFF\uDFFD', compare_primitive);
+check('primitive number, 0.2', 0.2, compare_primitive);
+check('primitive number, 0', 0, compare_primitive);
+check('primitive number, -0', -0, compare_primitive);
+check('primitive number, NaN', NaN, compare_primitive);
+check('primitive number, Infinity', Infinity, compare_primitive);
+check('primitive number, -Infinity', -Infinity, compare_primitive);
+check('primitive number, 9007199254740992', 9007199254740992, compare_primitive);
+check('primitive number, -9007199254740992', -9007199254740992, compare_primitive);
+check('primitive number, 9007199254740994', 9007199254740994, compare_primitive);
+check('primitive number, -9007199254740994', -9007199254740994, compare_primitive);
+
+check('Array primitives', [undefined,
+ null,
+ true,
+ false,
+ '',
+ '\uD800',
+ '\uDC00',
+ '\u0000',
+ '\uDBFF\uDFFD',
+ 0.2,
+ 0,
+ -0,
+ NaN,
+ Infinity,
+ -Infinity,
+ 9007199254740992,
+ -9007199254740992,
+ 9007199254740994,
+ -9007199254740994], compare_Array(enumerate_props(compare_primitive)));
+check('Object primitives', {'undefined':undefined,
+ 'null':null,
+ 'true':true,
+ 'false':false,
+ 'empty':'',
+ 'high surrogate':'\uD800',
+ 'low surrogate':'\uDC00',
+ 'nul':'\u0000',
+ 'astral':'\uDBFF\uDFFD',
+ '0.2':0.2,
+ '0':0,
+ '-0':-0,
+ 'NaN':NaN,
+ 'Infinity':Infinity,
+ '-Infinity':-Infinity,
+ '9007199254740992':9007199254740992,
+ '-9007199254740992':-9007199254740992,
+ '9007199254740994':9007199254740994,
+ '-9007199254740994':-9007199254740994}, compare_Object(enumerate_props(compare_primitive)));
+
+function compare_Boolean(actual, input, test_obj) {
+ if (typeof actual === 'string')
+ assert_unreached(actual);
+ assert_true(actual instanceof Boolean, 'instanceof Boolean');
+ assert_equals(String(actual), String(input), 'converted to primitive');
+ assert_not_equals(actual, input);
+ if (test_obj)
+ test_obj.done();
+}
+check('Boolean true', new Boolean(true), compare_Boolean);
+check('Boolean false', new Boolean(false), compare_Boolean);
+check('Array Boolean objects', [new Boolean(true), new Boolean(false)], compare_Array(enumerate_props(compare_Boolean)));
+check('Object Boolean objects', {'true':new Boolean(true), 'false':new Boolean(false)}, compare_Object(enumerate_props(compare_Boolean)));
+
+function compare_obj(what) {
+ var Type = window[what];
+ return function(actual, input, test_obj) {
+ if (typeof actual === 'string')
+ assert_unreached(actual);
+ assert_true(actual instanceof Type, 'instanceof '+what);
+ assert_equals(Type(actual), Type(input), 'converted to primitive');
+ assert_not_equals(actual, input);
+ if (test_obj)
+ test_obj.done();
+ };
+}
+check('String empty string', new String(''), compare_obj('String'));
+check('String lone high surrogate', new String('\uD800'), compare_obj('String'));
+check('String lone low surrogate', new String('\uDC00'), compare_obj('String'));
+check('String NUL', new String('\u0000'), compare_obj('String'));
+check('String astral character', new String('\uDBFF\uDFFD'), compare_obj('String'));
+check('Array String objects', [new String(''),
+ new String('\uD800'),
+ new String('\uDC00'),
+ new String('\u0000'),
+ new String('\uDBFF\uDFFD')], compare_Array(enumerate_props(compare_obj('String'))));
+check('Object String objects', {'empty':new String(''),
+ 'high surrogate':new String('\uD800'),
+ 'low surrogate':new String('\uDC00'),
+ 'nul':new String('\u0000'),
+ 'astral':new String('\uDBFF\uDFFD')}, compare_Object(enumerate_props(compare_obj('String'))));
+
+check('Number 0.2', new Number(0.2), compare_obj('Number'));
+check('Number 0', new Number(0), compare_obj('Number'));
+check('Number -0', new Number(-0), compare_obj('Number'));
+check('Number NaN', new Number(NaN), compare_obj('Number'));
+check('Number Infinity', new Number(Infinity), compare_obj('Number'));
+check('Number -Infinity', new Number(-Infinity), compare_obj('Number'));
+check('Number 9007199254740992', new Number(9007199254740992), compare_obj('Number'));
+check('Number -9007199254740992', new Number(-9007199254740992), compare_obj('Number'));
+check('Number 9007199254740994', new Number(9007199254740994), compare_obj('Number'));
+check('Number -9007199254740994', new Number(-9007199254740994), compare_obj('Number'));
+check('Array Number objects', [new Number(0.2),
+ new Number(0),
+ new Number(-0),
+ new Number(NaN),
+ new Number(Infinity),
+ new Number(-Infinity),
+ new Number(9007199254740992),
+ new Number(-9007199254740992),
+ new Number(9007199254740994),
+ new Number(-9007199254740994)], compare_Array(enumerate_props(compare_obj('Number'))));
+check('Object Number objects', {'0.2':new Number(0.2),
+ '0':new Number(0),
+ '-0':new Number(-0),
+ 'NaN':new Number(NaN),
+ 'Infinity':new Number(Infinity),
+ '-Infinity':new Number(-Infinity),
+ '9007199254740992':new Number(9007199254740992),
+ '-9007199254740992':new Number(-9007199254740992),
+ '9007199254740994':new Number(9007199254740994),
+ '-9007199254740994':new Number(-9007199254740994)}, compare_Object(enumerate_props(compare_obj('Number'))));
+
+function compare_Date(actual, input, test_obj) {
+ if (typeof actual === 'string')
+ assert_unreached(actual);
+ assert_true(actual instanceof Date, 'instanceof Date');
+ assert_equals(Number(actual), Number(input), 'converted to primitive');
+ assert_not_equals(actual, input);
+ if (test_obj)
+ test_obj.done();
+}
+check('Date 0', new Date(0), compare_Date);
+check('Date -0', new Date(-0), compare_Date);
+check('Date -8.64e15', new Date(-8.64e15), compare_Date);
+check('Date 8.64e15', new Date(8.64e15), compare_Date);
+check('Array Date objects', [new Date(0),
+ new Date(-0),
+ new Date(-8.64e15),
+ new Date(8.64e15)], compare_Array(enumerate_props(compare_Date)));
+check('Object Date objects', {'0':new Date(0),
+ '-0':new Date(-0),
+ '-8.64e15':new Date(-8.64e15),
+ '8.64e15':new Date(8.64e15)}, compare_Object(enumerate_props(compare_Date)));
+
+function compare_RegExp(expected_source) {
+ // XXX ES6 spec doesn't define exact serialization for `source` (it allows several ways to escape)
+ return function(actual, input, test_obj) {
+ if (typeof actual === 'string')
+ assert_unreached(actual);
+ assert_true(actual instanceof RegExp, 'instanceof RegExp');
+ assert_equals(actual.global, input.global, 'global');
+ assert_equals(actual.ignoreCase, input.ignoreCase, 'ignoreCase');
+ assert_equals(actual.multiline, input.multiline, 'multiline');
+ assert_equals(actual.source, expected_source, 'source');
+ assert_equals(actual.sticky, input.sticky, 'sticky');
+ assert_equals(actual.unicode, input.unicode, 'unicode');
+ assert_equals(actual.lastIndex, 0, 'lastIndex');
+ assert_not_equals(actual, input);
+ if (test_obj)
+ test_obj.done();
+ }
+}
+function func_RegExp_flags_lastIndex() {
+ var r = /foo/gim;
+ r.lastIndex = 2;
+ return r;
+}
+function func_RegExp_sticky() {
+ return new RegExp('foo', 'y');
+}
+function func_RegExp_unicode() {
+ return new RegExp('foo', 'u');
+}
+check('RegExp flags and lastIndex', func_RegExp_flags_lastIndex, compare_RegExp('foo'));
+check('RegExp sticky flag', func_RegExp_sticky, compare_RegExp('foo'));
+check('RegExp unicode flag', func_RegExp_unicode, compare_RegExp('foo'));
+check('RegExp empty', new RegExp(''), compare_RegExp('(?:)'));
+check('RegExp slash', new RegExp('/'), compare_RegExp('\\/'));
+check('RegExp new line', new RegExp('\n'), compare_RegExp('\\n'));
+check('Array RegExp object, RegExp flags and lastIndex', [func_RegExp_flags_lastIndex()], compare_Array(enumerate_props(compare_RegExp('foo'))));
+check('Array RegExp object, RegExp sticky flag', function() { return [func_RegExp_sticky()]; }, compare_Array(enumerate_props(compare_RegExp('foo'))));
+check('Array RegExp object, RegExp unicode flag', function() { return [func_RegExp_unicode()]; }, compare_Array(enumerate_props(compare_RegExp('foo'))));
+check('Array RegExp object, RegExp empty', [new RegExp('')], compare_Array(enumerate_props(compare_RegExp('(?:)'))));
+check('Array RegExp object, RegExp slash', [new RegExp('/')], compare_Array(enumerate_props(compare_RegExp('\\/'))));
+check('Array RegExp object, RegExp new line', [new RegExp('\n')], compare_Array(enumerate_props(compare_RegExp('\\n'))));
+check('Object RegExp object, RegExp flags and lastIndex', {'x':func_RegExp_flags_lastIndex()}, compare_Object(enumerate_props(compare_RegExp('foo'))));
+check('Object RegExp object, RegExp sticky flag', function() { return {'x':func_RegExp_sticky()}; }, compare_Object(enumerate_props(compare_RegExp('foo'))));
+check('Object RegExp object, RegExp unicode flag', function() { return {'x':func_RegExp_unicode()}; }, compare_Object(enumerate_props(compare_RegExp('foo'))));
+check('Object RegExp object, RegExp empty', {'x':new RegExp('')}, compare_Object(enumerate_props(compare_RegExp('(?:)'))));
+check('Object RegExp object, RegExp slash', {'x':new RegExp('/')}, compare_Object(enumerate_props(compare_RegExp('\\/'))));
+check('Object RegExp object, RegExp new line', {'x':new RegExp('\n')}, compare_Object(enumerate_props(compare_RegExp('\\n'))));
+
+function compare_Blob(actual, input, test_obj, expect_File) {
+ if (typeof actual === 'string')
+ assert_unreached(actual);
+ assert_true(actual instanceof Blob, 'instanceof Blob');
+ if (!expect_File)
+ assert_false(actual instanceof File, 'instanceof File');
+ assert_equals(actual.size, input.size, 'size');
+ assert_equals(actual.type, input.type, 'type');
+ assert_not_equals(actual, input);
+ var ev_reader = new FileReader();
+ var input_reader = new FileReader();
+ var read_count = 0;
+ var read_done = test_obj.step_func(function() {
+ read_count++;
+ if (read_count == 2) {
+ var ev_result = ev_reader.result;
+ var input_result = input_reader.result;
+ assert_equals(ev_result.byteLength, input_result.byteLength, 'byteLength');
+ var ev_view = new DataView(ev_result);
+ var input_view = new DataView(input_result);
+ for (var i = 0; i < ev_result.byteLength; ++i) {
+ assert_equals(ev_view.getUint8(i), input_view.getUint8(i), 'getUint8('+i+')');
+ }
+ if (test_obj)
+ test_obj.done();
+ }
+ });
+ var read_error = test_obj.step_func(function() { assert_unreached('FileReader error'); });
+ ev_reader.readAsArrayBuffer(actual);
+ ev_reader.onload = read_done;
+ ev_reader.onabort = ev_reader.onerror = read_error;
+ input_reader.readAsArrayBuffer(input);
+ input_reader.onload = read_done;
+ input_reader.onabort = input_reader.onerror = read_error;
+}
+function func_Blob_basic() {
+ return new Blob(['foo'], {type:'text/x-bar'});
+}
+check('Blob basic', func_Blob_basic, compare_Blob);
+
+function b(str) {
+ return parseInt(str, 2);
+}
+function encode_cesu8(codeunits) {
+ // http://www.unicode.org/reports/tr26/ section 2.2
+ // only the 3-byte form is supported
+ var rv = [];
+ codeunits.forEach(function(codeunit) {
+ rv.push(b('11100000') + ((codeunit & b('1111000000000000')) >> 12));
+ rv.push(b('10000000') + ((codeunit & b('0000111111000000')) >> 6));
+ rv.push(b('10000000') + (codeunit & b('0000000000111111')));
+ });
+ return rv;
+}
+function func_Blob_bytes(arr) {
+ return function() {
+ var buffer = new ArrayBuffer(arr.length);
+ var view = new DataView(buffer);
+ for (var i = 0; i < arr.length; ++i) {
+ view.setUint8(i, arr[i]);
+ }
+ return new Blob([view]);
+ };
+}
+check('Blob unpaired high surrogate (invalid utf-8)', func_Blob_bytes(encode_cesu8([0xD800])), compare_Blob);
+check('Blob unpaired low surrogate (invalid utf-8)', func_Blob_bytes(encode_cesu8([0xDC00])), compare_Blob);
+check('Blob paired surrogates (invalid utf-8)', func_Blob_bytes(encode_cesu8([0xD800, 0xDC00])), compare_Blob);
+
+function func_Blob_empty() {
+ return new Blob(['']);
+}
+check('Blob empty', func_Blob_empty , compare_Blob);
+function func_Blob_NUL() {
+ return new Blob(['\u0000']);
+}
+check('Blob NUL', func_Blob_NUL, compare_Blob);
+
+async_test(function(test_obj) {
+ check(test_obj.name, [test_obj.step(func_Blob_basic)], compare_Array(enumerate_props(compare_Blob, test_obj), true), test_obj);
+}, 'Array Blob object, Blob basic');
+async_test(function(test_obj) {
+ check(test_obj.name, [test_obj.step(func_Blob_bytes([0xD800]))], compare_Array(enumerate_props(compare_Blob, test_obj), true), test_obj);
+}, 'Array Blob object, Blob unpaired high surrogate (invalid utf-8)');
+async_test(function(test_obj) {
+ check(test_obj.name, [test_obj.step(func_Blob_bytes([0xDC00]))], compare_Array(enumerate_props(compare_Blob, test_obj), true), test_obj);
+}, 'Array Blob object, Blob unpaired low surrogate (invalid utf-8)');
+async_test(function(test_obj) {
+ check(test_obj.name, [test_obj.step(func_Blob_bytes([0xD800, 0xDC00]))], compare_Array(enumerate_props(compare_Blob, test_obj), true), test_obj);
+}, 'Array Blob object, Blob paired surrogates (invalid utf-8)');
+async_test(function(test_obj) {
+ check(test_obj.name, [test_obj.step(func_Blob_empty)], compare_Array(enumerate_props(compare_Blob, test_obj), true), test_obj);
+}, 'Array Blob object, Blob empty');
+async_test(function(test_obj) {
+ check(test_obj.name, [test_obj.step(func_Blob_NUL)], compare_Array(enumerate_props(compare_Blob, test_obj), true), test_obj);
+}, 'Array Blob object, Blob NUL');
+
+async_test(function(test_obj) {
+ check(test_obj.name, {'x':test_obj.step(func_Blob_basic)}, compare_Object(enumerate_props(compare_Blob, test_obj), true), test_obj);
+}, 'Object Blob object, Blob basic');
+async_test(function(test_obj) {
+ check(test_obj.name, {'x':test_obj.step(func_Blob_bytes([0xD800]))}, compare_Object(enumerate_props(compare_Blob, test_obj), true), test_obj);
+}, 'Object Blob object, Blob unpaired high surrogate (invalid utf-8)');
+async_test(function(test_obj) {
+ check(test_obj.name, {'x':test_obj.step(func_Blob_bytes([0xDC00]))}, compare_Object(enumerate_props(compare_Blob, test_obj), true), test_obj);
+}, 'Object Blob object, Blob unpaired low surrogate (invalid utf-8)');
+async_test(function(test_obj) {
+ check(test_obj.name, {'x':test_obj.step(func_Blob_bytes([0xD800, 0xDC00]))}, compare_Object(enumerate_props(compare_Blob, test_obj), true), test_obj);
+}, 'Object Blob object, Blob paired surrogates (invalid utf-8)');
+async_test(function(test_obj) {
+ check(test_obj.name, {'x':test_obj.step(func_Blob_empty)}, compare_Object(enumerate_props(compare_Blob, test_obj), true), test_obj);
+}, 'Object Blob object, Blob empty');
+async_test(function(test_obj) {
+ check(test_obj.name, {'x':test_obj.step(func_Blob_NUL)}, compare_Object(enumerate_props(compare_Blob, test_obj), true), test_obj);
+}, 'Object Blob object, Blob NUL');
+
+function compare_File(actual, input, test_obj) {
+ assert_true(actual instanceof File, 'instanceof File');
+ assert_equals(actual.name, input.name, 'name');
+ assert_equals(actual.lastModified, input.lastModified, 'lastModified');
+ compare_Blob(actual, input, test_obj, true);
+}
+function func_File_basic() {
+ return new File(['foo'], 'bar', {type:'text/x-bar', lastModified:42});
+}
+check('File basic', func_File_basic, compare_File);
+
+function compare_FileList(actual, input, test_obj) {
+ if (typeof actual === 'string')
+ assert_unreached(actual);
+ assert_true(actual instanceof FileList, 'instanceof FileList');
+ assert_equals(actual.length, input.length, 'length');
+ assert_not_equals(actual, input);
+ // XXX when there's a way to populate or construct a FileList,
+ // check the items in the FileList
+ if (test_obj)
+ test_obj.done();
+}
+function func_FileList_empty() {
+ var input = document.createElement('input');
+ input.type = 'file';
+ return input.files;
+}
+check('FileList empty', func_FileList_empty, compare_FileList);
+check('Array FileList object, FileList empty', [func_FileList_empty], compare_Array(enumerate_props(compare_FileList)));
+check('Object FileList object, FileList empty', {'x':func_FileList_empty}, compare_Object(enumerate_props(compare_FileList)));
+
+function compare_ArrayBufferView(view) {
+ var Type = window[view];
+ return function(actual, input, test_obj) {
+ if (typeof actual === 'string')
+ assert_unreached(actual);
+ assert_true(actual instanceof Type, 'instanceof '+view);
+ assert_equals(actual.length, input.length, 'length');
+ assert_not_equals(actual.buffer, input.buffer, 'buffer');
+ for (var i = 0; i < actual.length; ++i) {
+ assert_equals(actual[i], input[i], 'actual['+i+']');
+ }
+ if (test_obj)
+ test_obj.done();
+ };
+}
+function compare_ImageData(actual, input, test_obj) {
+ if (typeof actual === 'string')
+ assert_unreached(actual);
+ assert_equals(actual.width, input.width, 'width');
+ assert_equals(actual.height, input.height, 'height');
+ assert_not_equals(actual.data, input.data, 'data');
+ compare_ArrayBufferView('Uint8ClampedArray')(actual.data, input.data, null);
+ if (test_obj)
+ test_obj.done();
+}
+function func_ImageData_1x1_transparent_black() {
+ var canvas = document.createElement('canvas');
+ var ctx = canvas.getContext('2d');
+ return ctx.createImageData(1, 1);
+}
+check('ImageData 1x1 transparent black', func_ImageData_1x1_transparent_black, compare_ImageData);
+function func_ImageData_1x1_non_transparent_non_black() {
+ var canvas = document.createElement('canvas');
+ var ctx = canvas.getContext('2d');
+ var imagedata = ctx.createImageData(1, 1);
+ imagedata.data[0] = 100;
+ imagedata.data[1] = 101;
+ imagedata.data[2] = 102;
+ imagedata.data[3] = 103;
+ return imagedata;
+}
+check('ImageData 1x1 non-transparent non-black', func_ImageData_1x1_non_transparent_non_black, compare_ImageData);
+async_test(function(test_obj) {
+ check(test_obj.name, [test_obj.step(func_ImageData_1x1_transparent_black)], compare_Array(enumerate_props(compare_ImageData)), test_obj);
+}, 'Array ImageData object, ImageData 1x1 transparent black');
+async_test(function(test_obj) {
+ check(test_obj.name, [test_obj.step(func_ImageData_1x1_non_transparent_non_black)], compare_Array(enumerate_props(compare_ImageData)), test_obj);
+}, 'Array ImageData object, ImageData 1x1 non-transparent non-black');
+async_test(function(test_obj) {
+ check(test_obj.name, {'x':test_obj.step(func_ImageData_1x1_transparent_black)}, compare_Object(enumerate_props(compare_ImageData)), test_obj);
+}, 'Object ImageData object, ImageData 1x1 transparent black');
+async_test(function(test_obj) {
+ check(test_obj.name, {'x':test_obj.step(func_ImageData_1x1_non_transparent_non_black)}, compare_Object(enumerate_props(compare_ImageData)), test_obj);
+}, 'Object ImageData object, ImageData 1x1 non-transparent non-black');
+
+function compare_ImageBitmap(actual, input, test_obj) {
+ if (typeof actual === 'string')
+ assert_unreached(actual);
+ assert_equals(actual instanceof ImageBitmap, 'instanceof ImageBitmap');
+ assert_not_equals(actual, input);
+ // XXX paint the ImageBitmap on a canvas and check the data
+ if (test_obj)
+ test_obj.done();
+}
+function get_canvas_1x1_transparent_black() {
+ var canvas = document.createElement('canvas');
+ canvas.width = 1;
+ canvas.height = 1;
+ return canvas;
+}
+async_test(function(test_obj) {
+ var canvas = get_canvas_1x1_transparent_black();
+ createImageBitmap(canvas, function(image) { check(test_obj.name, image, compare_ImageBitmap, test_obj); });
+}, 'ImageBitmap 1x1 transparent black');
+function get_canvas_1x1_non_transparent_non_black() {
+ var canvas = document.createElement('canvas');
+ canvas.width = 1;
+ canvas.height = 1;
+ var ctx = canvas.getContext('2d');
+ var imagedata = ctx.getImageData(0, 0, 1, 1);
+ imagedata.data[0] = 100;
+ imagedata.data[1] = 101;
+ imagedata.data[2] = 102;
+ imagedata.data[3] = 103;
+ return canvas;
+}
+async_test(function(test_obj) {
+ var canvas = get_canvas_1x1_non_transparent_non_black();
+ createImageBitmap(canvas, function(image) { check(test_obj.name, image, compare_ImageBitmap, test_obj); });
+}, 'ImageBitmap 1x1 non-transparent non-black');
+
+async_test(function(test_obj) {
+ var canvas = get_canvas_1x1_transparent_black();
+ createImageBitmap(canvas, function(image) { check(test_obj.name, [image], compare_Array(enumerate_props(compare_ImageBitmap)), test_obj); });
+}, 'Array ImageBitmap object, ImageBitmap 1x1 transparent black');
+async_test(function(test_obj) {
+ var canvas = get_canvas_1x1_non_transparent_non_black();
+ createImageBitmap(canvas, function(image) { check(test_obj.name, [image], compare_Array(enumerate_props(compare_ImageBitmap)), test_obj); });
+}, 'Array ImageBitmap object, ImageBitmap 1x1 non-transparent non-black');
+
+async_test(function(test_obj) {
+ var canvas = get_canvas_1x1_transparent_black();
+ createImageBitmap(canvas, function(image) { check(test_obj.name, {'x':image}, compare_Object(enumerate_props(compare_ImageBitmap)), test_obj); });
+}, 'Object ImageBitmap object, ImageBitmap 1x1 transparent black');
+async_test(function(test_obj) {
+ var canvas = get_canvas_1x1_non_transparent_non_black();
+ createImageBitmap(canvas, function(image) { check(test_obj.name, {'x':image}, compare_Object(enumerate_props(compare_ImageBitmap)), test_obj); });
+}, 'Object ImageBitmap object, ImageBitmap 1x1 non-transparent non-black');
+
+check('Array sparse', new Array(10), compare_Array(enumerate_props(compare_primitive)));
+check('Array with non-index property', function() {
+ var rv = [];
+ rv.foo = 'bar';
+ return rv;
+}, compare_Array(enumerate_props(compare_primitive)));
+check('Object with index property and length', {'0':'foo', 'length':1}, compare_Object(enumerate_props(compare_primitive)));
+function check_circular_property(prop) {
+ return function(actual) {
+ assert_equals(actual[prop], actual);
+ };
+}
+check('Array with circular reference', function() {
+ var rv = [];
+ rv[0] = rv;
+ return rv;
+}, compare_Array(check_circular_property('0')));
+check('Object with circular reference', function() {
+ var rv = {};
+ rv['x'] = rv;
+ return rv;
+}, compare_Object(check_circular_property('x')));
+function check_identical_property_values(prop1, prop2) {
+ return function(actual) {
+ assert_equals(actual[prop1], actual[prop2]);
+ };
+}
+check('Array with identical property values', function() {
+ var obj = {}
+ return [obj, obj];
+}, compare_Array(check_identical_property_values('0', '1')));
+check('Object with identical property values', function() {
+ var obj = {}
+ return {'x':obj, 'y':obj};
+}, compare_Object(check_identical_property_values('x', 'y')));
+
+function check_absent_property(prop) {
+ return function(actual) {
+ assert_false(prop in actual);
+ };
+}
+check('Object with property on prototype', function() {
+ var Foo = function() {};
+ Foo.prototype = {'foo':'bar'};
+ return new Foo();
+}, compare_Object(check_absent_property('foo')));
+
+check('Object with non-enumerable property', function() {
+ var rv = {};
+ Object.defineProperty(rv, 'foo', {value:'bar', enumerable:false, writable:true, configurable:true});
+ return rv;
+}, compare_Object(check_absent_property('foo')));
+
+function check_writable_property(prop) {
+ return function(actual, input) {
+ assert_equals(actual[prop], input[prop]);
+ actual[prop] += ' baz';
+ assert_equals(actual[prop], input[prop] + ' baz');
+ };
+}
+check('Object with non-writable property', function() {
+ var rv = {};
+ Object.defineProperty(rv, 'foo', {value:'bar', enumerable:true, writable:false, configurable:true});
+ return rv;
+}, compare_Object(check_writable_property('foo')));
+
+function check_configurable_property(prop) {
+ return function(actual, input) {
+ assert_equals(actual[prop], input[prop]);
+ delete actual[prop];
+ assert_false('prop' in actual);
+ };
+}
+check('Object with non-configurable property', function() {
+ var rv = {};
+ Object.defineProperty(rv, 'foo', {value:'bar', enumerable:true, writable:true, configurable:false});
+ return rv;
+}, compare_Object(check_configurable_property('foo')));
diff --git a/testing/web-platform/tests/workers/semantics/structured-clone/dedicated.html b/testing/web-platform/tests/workers/semantics/structured-clone/dedicated.html
new file mode 100644
index 000000000..5dd8c3561
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/structured-clone/dedicated.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<title>structured clone to dedicated worker</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+var type = 'dedicated';
+</script>
+<script src="common.js"></script>
diff --git a/testing/web-platform/tests/workers/semantics/structured-clone/dedicated.js b/testing/web-platform/tests/workers/semantics/structured-clone/dedicated.js
new file mode 100644
index 000000000..4744578b2
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/structured-clone/dedicated.js
@@ -0,0 +1,4 @@
+importScripts('worker-common.js');
+onmessage = function(ev) {
+ check(ev.data, self);
+};
diff --git a/testing/web-platform/tests/workers/semantics/structured-clone/shared.html b/testing/web-platform/tests/workers/semantics/structured-clone/shared.html
new file mode 100644
index 000000000..6f74354d4
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/structured-clone/shared.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<title>structured clone to shared worker</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+var type = 'shared';
+</script>
+<script src="common.js"></script>
diff --git a/testing/web-platform/tests/workers/semantics/structured-clone/shared.js b/testing/web-platform/tests/workers/semantics/structured-clone/shared.js
new file mode 100644
index 000000000..372a9ec98
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/structured-clone/shared.js
@@ -0,0 +1,6 @@
+importScripts('worker-common.js');
+onconnect = function(connect_ev) {
+ connect_ev.ports[0].onmessage = function(message_ev) {
+ check(message_ev.data, this);
+ };
+};
diff --git a/testing/web-platform/tests/workers/semantics/structured-clone/worker-common.js b/testing/web-platform/tests/workers/semantics/structured-clone/worker-common.js
new file mode 100644
index 000000000..fd63ff5a5
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/structured-clone/worker-common.js
@@ -0,0 +1,1018 @@
+var msg = decodeURIComponent(location.hash.substr(1));
+
+var log = [];
+function check_true(actual, msg) {
+ if (actual !== true) {
+ log.push(msg);
+ return false;
+ }
+ return true;
+}
+
+function check_Blob(msg, input, port, expect_File, orig_input) {
+ expect_File = !!expect_File;
+ orig_input = orig_input || input;
+ try {
+ var expected;
+ switch (msg) {
+ case 'Blob basic':
+ case 'File basic':
+ expected = [0x66, 0x6F, 0x6F];
+ expected.type = 'text/x-bar';
+ if (expect_File) {
+ expected.name = 'bar';
+ expected.lastModified = 42;
+ }
+ break;
+ case 'Blob unpaired high surrogate (invalid utf-8)':
+ expected = [0xED, 0xA0, 0x80];
+ expected.type = '';
+ break;
+ case 'Blob unpaired low surrogate (invalid utf-8)':
+ expected = [0xED, 0xB0, 0x80];
+ expected.type = '';
+ break;
+ case 'Blob paired surrogates (invalid utf-8)':
+ expected = [0xED, 0xA0, 0x80, 0xED, 0xB0, 0x80];
+ expected.type = '';
+ break;
+ case 'Blob empty':
+ expected = [];
+ expected.type = '';
+ break;
+ case 'Blob NUL':
+ var expected = [0x00];
+ expected.type = '';
+ break;
+ default:
+ check_true(false, 'check_Blob: unknown test');
+ return;
+ break;
+ }
+ if (check_true(input instanceof Blob, 'input instanceof Blob') &&
+ check_true((input instanceof File) == expect_File, '(input instanceof File) == expect_File') &&
+ check_true(input.size === expected.length, 'input.size === expected.length') &&
+ check_true(input.type === expected.type, 'input.type === expected.type')) {
+ if (!expect_File || (check_true(input.name === expected.name, 'input.name === expected.name') &&
+ check_true(input.lastModified === expected.lastModified))) {
+ var reader = new FileReader();
+ var read_done = function() {
+ try {
+ var result = reader.result;
+ check_true(result.byteLength === expected.length, 'result.byteLength === expected.length')
+ var view = new DataView(result);
+ for (var i = 0; i < result.byteLength; ++i) {
+ check_true(view.getUint8(i) === expected[i], 'view.getUint8('+i+') === expected['+i+']')
+ }
+ if (log.length === 0) {
+ port.postMessage(orig_input);
+ } else {
+ port.postMessage('FAIL '+log);
+ }
+ close();
+ } catch(ex) {
+ postMessage('FAIL '+ex);
+ close();
+ }
+ }
+ var read_error = function() { port.postMessage('FAIL (got FileReader error)'); close(); };
+ reader.readAsArrayBuffer(input);
+ reader.onload = read_done;
+ reader.onabort = reader.onerror = read_error;
+ }
+ } else {
+ port.postMessage('FAIL '+log);
+ close();
+ }
+ } catch(ex) {
+ postMessage('FAIL '+ex);
+ close();
+ }
+}
+
+function check_ImageData(input, expected) {
+ if (check_true(input instanceof ImageData, 'input instanceof ImageData') &&
+ check_true(input.width === expected.width, 'input.width === '+expected.width) &&
+ check_true(input.height === expected.height, 'input.height === '+expected.height) &&
+ check_true(input.data instanceof Uint8ClampedArray, 'input.data instanceof Uint8ClampedArray') &&
+ check_true(input.data.length === expected.data.length, 'input.data.length === '+expected.data.length) &&
+ check_true(!('CanvasPixelArray' in self), "!('CanvasPixelArray' in self)")) {
+ for (var i = 0; i < input.length; ++i) {
+ if (!(check_true(input.data[i] === expected.data[i], 'input.data['+i+'] === '+expected.data[i]))) {
+ return false;
+ }
+ }
+ return true;
+ }
+ return false;
+}
+
+function check_ImageBitmap(input, expected) {
+ return check_true(input instanceof ImageBitmap, 'input instanceof ImageBitmap');
+ // XXX paint it on a proxy canvas and check the data
+}
+
+function check_RegExp(msg, input) {
+ // XXX ES6 spec doesn't define exact serialization for `source` (it allows several ways to escape)
+ switch (msg) {
+ case 'RegExp flags and lastIndex':
+ return check_true(input instanceof RegExp, "input instanceof RegExp") &&
+ check_true(input.source === 'foo', "input.source === 'foo'") &&
+ check_true(input.global === true, "input.global === true") &&
+ check_true(input.ignoreCase === true, "input.ignoreCase === true") &&
+ check_true(input.multiline === true, "input.multiline === true") &&
+ check_true(input.lastIndex === 0, "input.lastIndex === 0");
+ break;
+ case 'RegExp sticky flag':
+ return check_true(input instanceof RegExp, "input instanceof RegExp") &&
+ check_true(input.source === 'foo', "input.source === 'foo'") &&
+ check_true(input.global === false, "input.global === false") &&
+ check_true(input.ignoreCase === false, "input.ignoreCase === false") &&
+ check_true(input.multiline === false, "input.multiline === false") &&
+ check_true(input.sticky === true, "input.sticky === true") &&
+ check_true(input.unicode === false, "input.unicode === false") &&
+ check_true(input.lastIndex === 0, "input.lastIndex === 0");
+ break;
+ case 'RegExp unicode flag':
+ return check_true(input instanceof RegExp, "input instanceof RegExp") &&
+ check_true(input.source === 'foo', "input.source === 'foo'") &&
+ check_true(input.global === false, "input.global === false") &&
+ check_true(input.ignoreCase === false, "input.ignoreCase === false") &&
+ check_true(input.multiline === false, "input.multiline === false") &&
+ check_true(input.sticky === false, "input.sticky === false") &&
+ check_true(input.unicode === true, "input.unicode === true") &&
+ check_true(input.lastIndex === 0, "input.lastIndex === 0");
+ break;
+ case 'RegExp empty':
+ return check_true(input instanceof RegExp, "input instanceof RegExp") &&
+ check_true(input.source === '(?:)', "input.source === '(?:)'") &&
+ check_true(input.global === false, "input.global === false") &&
+ check_true(input.ignoreCase === false, "input.ignoreCase === false") &&
+ check_true(input.multiline === false, "input.multiline === false") &&
+ check_true(input.lastIndex === 0, "input.lastIndex === 0");
+ break;
+ case 'RegExp slash':
+ return check_true(input instanceof RegExp, "input instanceof RegExp") &&
+ check_true(input.source === '\\/', "input.source === '\\\\/'") &&
+ check_true(input.global === false, "input.global === false") &&
+ check_true(input.ignoreCase === false, "input.ignoreCase === false") &&
+ check_true(input.multiline === false, "input.multiline === false") &&
+ check_true(input.lastIndex === 0, "input.lastIndex === 0");
+ break;
+ case 'RegExp new line':
+ return check_true(input instanceof RegExp, "input instanceof RegExp") &&
+ check_true(input.source === '\\n', "input.source === '\\\\n'") &&
+ check_true(input.global === false, "input.global === false") &&
+ check_true(input.ignoreCase === false, "input.ignoreCase === false") &&
+ check_true(input.multiline === false, "input.multiline === false") &&
+ check_true(input.lastIndex === 0, "input.lastIndex === 0");
+ break;
+ default:
+ check_true(false, 'check_RegExp: unknown test');
+ return false;
+ break;
+ }
+}
+
+function check_FileList(msg, input) {
+ try {
+ return check_true(input instanceof FileList, 'input instanceof FileList') &&
+ check_true(input.length === 0, 'input.length === 0');
+ } catch(ex) {
+ return check_true(false, ex);
+ }
+}
+
+function check(input, port) {
+ try {
+ switch (msg) {
+ case 'primitive undefined':
+ if (check_true(input === undefined, 'input === undefined')) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'primitive null':
+ if (check_true(input === null, 'input === null')) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'primitive true':
+ if (check_true(input === true, 'input === true')) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'primitive false':
+ if (check_true(input === false, 'input === false')) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'primitive string, empty string':
+ if (check_true(input === '', "input === ''")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'primitive string, lone high surrogate':
+ if (check_true(input === '\uD800', "input === '\uD800'")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'primitive string, lone low surrogate':
+ if (check_true(input === '\uDC00', "input === '\uDC00'")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'primitive string, NUL':
+ if (check_true(input === '\u0000', "input === '\u0000'")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'primitive string, astral character':
+ if (check_true(input === '\uDBFF\uDFFD', "input === '\uDBFF\uDFFD'")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'primitive number, 0.2':
+ if (check_true(input === 0.2, "input === 0.2")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'primitive number, 0':
+ if (check_true(input === 0, "input === 0") &&
+ check_true(1/input === Infinity, "1/input === Infinity")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'primitive number, -0':
+ if (check_true(input === 0, "input === 0") &&
+ check_true(1/input === -Infinity, "1/input === -Infinity")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'primitive number, NaN':
+ if (check_true(input !== input, "input !== input")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'primitive number, Infinity':
+ if (check_true(input === Infinity, "input === Infinity")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'primitive number, -Infinity':
+ if (check_true(input === -Infinity, "input === -Infinity")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'primitive number, 9007199254740992':
+ if (check_true(input === 9007199254740992, "input === 9007199254740992")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'primitive number, -9007199254740992':
+ if (check_true(input === -9007199254740992, "input === -9007199254740992")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'primitive number, 9007199254740994':
+ if (check_true(input === 9007199254740994, "input === 9007199254740994")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'primitive number, -9007199254740994':
+ if (check_true(input === -9007199254740994, "input === -9007199254740994")) {
+ port.postMessage(input);
+ close();
+ break;
+ }
+ case 'Array primitives':
+ if (check_true(input instanceof Array, 'input instanceof Array') &&
+ check_true(input.length === 19, 'input.length === 19') &&
+ check_true(input[0] === undefined, 'input[0] === undefined') &&
+ check_true(input[1] === null, 'input[1] === null') &&
+ check_true(input[2] === true, 'input[2] === true') &&
+ check_true(input[3] === false, 'input[3] === false') &&
+ check_true(input[4] === '', "input[4] === ''") &&
+ check_true(input[5] === '\uD800', "input[5] === '\\uD800'") &&
+ check_true(input[6] === '\uDC00', "input[6] === '\\uDC00'") &&
+ check_true(input[7] === '\u0000', "input[7] === '\\u0000'") &&
+ check_true(input[8] === '\uDBFF\uDFFD', "input[8] === '\\uDBFF\\uDFFD'") &&
+ check_true(input[9] === 0.2, "input[9] === 0.2") &&
+ check_true(1/input[10] === Infinity, "1/input[10] === Infinity") &&
+ check_true(1/input[11] === -Infinity, "1/input[11] === -Infinity") &&
+ check_true(input[12] !== input[11], "input[12] !== input[11]") &&
+ check_true(input[13] === Infinity, "input[13] === Infinity") &&
+ check_true(input[14] === -Infinity, "input[14] === -Infinity") &&
+ check_true(input[15] === 9007199254740992, "input[15] === 9007199254740992") &&
+ check_true(input[16] === -9007199254740992, "input[16] === -9007199254740992") &&
+ check_true(input[17] === 9007199254740994, "input[17] === 9007199254740994") &&
+ check_true(input[18] === -9007199254740994, "input[18] === -9007199254740994")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'Object primitives':
+ (function() {
+ if (check_true(input instanceof Object, 'input instanceof Object') &&
+ check_true(!(input instanceof Array), '!(input instanceof Array)') &&
+ check_true(input['undefined'] === undefined, "input['undefined'] === undefined") &&
+ check_true(input['null'] === null, "input['null'] === null") &&
+ check_true(input['true'] === true, "input['true'] === true") &&
+ check_true(input['false'] === false, "input['false'] === false") &&
+ check_true(input['empty'] === '', "input['empty'] === ''") &&
+ check_true(input['high surrogate'] === '\uD800', "input['high surrogate'] === '\uD800'") &&
+ check_true(input['low surrogate'] === '\uDC00', "input['low surrogate'] === '\uDC00'") &&
+ check_true(input['nul'] === '\u0000', "input['nul'] === '\u0000'") &&
+ check_true(input['astral'] === '\uDBFF\uDFFD', "input['astral'] === '\uDBFF\uDFFD'") &&
+ check_true(input['0.2'] === 0.2, "input['0.2'] === 0.2") &&
+ check_true(1/input['0'] === Infinity, "1/input['0'] === Infinity") &&
+ check_true(1/input['-0'] === -Infinity, "1/input['-0'] === -Infinity") &&
+ check_true(input['NaN'] !== input['NaN'], "input['NaN'] !== input['NaN']") &&
+ check_true(input['Infinity'] === Infinity, "input['Infinity'] === Infinity") &&
+ check_true(input['-Infinity'] === -Infinity, "input['-Infinity'] === -Infinity") &&
+ check_true(input['9007199254740992'] === 9007199254740992, "input['9007199254740992'] === 9007199254740992") &&
+ check_true(input['-9007199254740992'] === -9007199254740992, "input['-9007199254740992'] === -9007199254740992") &&
+ check_true(input['9007199254740994'] === 9007199254740994, "input['9007199254740994'] === 9007199254740994") &&
+ check_true(input['-9007199254740994'] === -9007199254740994, "input['9007199254740994'] === -9007199254740994")) {
+ var i = 0;
+ for (var x in input) {
+ i++;
+ }
+ if (check_true(i === 19, 'i === 19')) {
+ port.postMessage(input);
+ close();
+ }
+ }
+ })();
+ break;
+ case 'Boolean true':
+ if (check_true(input instanceof Boolean, "input instanceof Boolean") &&
+ check_true(String(input) === 'true', "String(input) === 'true'")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'Boolean false':
+ if (check_true(input instanceof Boolean, "input instanceof Boolean") &&
+ check_true(String(input) === 'false', "String(input) === 'false'")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'Array Boolean objects':
+ (function() {
+ if (check_true(input instanceof Array, 'input instanceof Array') &&
+ check_true(input.length === 2, 'input.length === 2') &&
+ check_true(String(input[0]) === 'true', "String(input[0]) === 'true'") &&
+ check_true(String(input[1]) === 'false', "String(input[1]) === 'false'")) {
+ for (var i = 0; i < input.length; ++i) {
+ if (!check_true(input[i] instanceof Boolean, 'input['+i+'] instanceof Boolean'))
+ return;
+ }
+ port.postMessage(input);
+ close();
+ }
+ })();
+ break;
+ case 'Object Boolean objects':
+ (function() {
+ if (check_true(input instanceof Object, 'input instanceof Object') &&
+ check_true(!(input instanceof Array), '!(input instanceof Array)') &&
+ check_true(String(input['true']) === 'true', "String(input['true']) === 'true'") &&
+ check_true(String(input['false']) === 'false', "String(input['false']) === 'false'")) {
+ var i = 0;
+ for (var x in input) {
+ i++;
+ if (!check_true(input[x] instanceof Boolean, 'input['+x+'] instanceof Boolean'))
+ return;
+ }
+ if (check_true(i === 2, 'i === 2')) {
+ port.postMessage(input);
+ close();
+ }
+ }
+ })();
+ break;
+ case 'String empty string':
+ if (check_true(input instanceof String, "input instanceof String") &&
+ check_true(String(input) === '', "String(input) === ''")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'String lone high surrogate':
+ if (check_true(input instanceof String, "input instanceof String") &&
+ check_true(String(input) === '\uD800', "String(input) === '\\uD800'")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'String lone low surrogate':
+ if (check_true(input instanceof String, "input instanceof String") &&
+ check_true(String(input) === '\uDC00', "String(input) === '\\uDC00'")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'String NUL':
+ if (check_true(input instanceof String, "input instanceof String") &&
+ check_true(String(input) === '\u0000', "String(input) === '\\u0000'")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'String astral character':
+ if (check_true(input instanceof String, "input instanceof String") &&
+ check_true(String(input) === '\uDBFF\uDFFD', "String(input) === '\\uDBFF\\uDFFD'")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'Array String objects':
+ (function() {
+ if (check_true(input instanceof Array, 'input instanceof Array') &&
+ check_true(input.length === 5, 'input.length === 5') &&
+ check_true(String(input[0]) === '', "String(input[0]) === ''") &&
+ check_true(String(input[1]) === '\uD800', "String(input[1]) === '\\uD800'") &&
+ check_true(String(input[2]) === '\uDC00', "String(input[1]) === '\\uDC00'") &&
+ check_true(String(input[3]) === '\u0000', "String(input[2]) === '\\u0000'") &&
+ check_true(String(input[4]) === '\uDBFF\uDFFD', "String(input[3]) === '\\uDBFF\\uDFFD'")) {
+ for (var i = 0; i < input.length; ++i) {
+ if (!check_true(input[i] instanceof String, 'input['+i+'] instanceof String'))
+ return;
+ }
+ port.postMessage(input);
+ close();
+ }
+ })();
+ break;
+ case 'Object String objects':
+ (function() {
+ if (check_true(input instanceof Object, 'input instanceof Object') &&
+ check_true(!(input instanceof Array), '!(input instanceof Array)') &&
+ check_true(String(input['empty']) === '', "String(input['empty']) === ''") &&
+ check_true(String(input['high surrogate']) === '\uD800', "String(input['high surrogate']) === '\\uD800'") &&
+ check_true(String(input['low surrogate']) === '\uDC00', "String(input['low surrogate']) === '\\uDC00'") &&
+ check_true(String(input['nul']) === '\u0000', "String(input['nul']) === '\\u0000'") &&
+ check_true(String(input['astral']) === '\uDBFF\uDFFD', "String(input['astral']) === '\\uDBFF\\uDFFD'")) {
+ var i = 0;
+ for (var x in input) {
+ i++;
+ if (!check_true(input[x] instanceof String, 'input['+x+'] instanceof Boolean'))
+ return;
+ }
+ if (check_true(i === 5, 'i === 5')) {
+ port.postMessage(input);
+ close();
+ }
+ }
+ })();
+ break;
+ case 'Number 0.2':
+ if (check_true(input instanceof Number, "input instanceof Number") &&
+ check_true(Number(input) === 0.2, "Number(input) === 0.2")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'Number 0':
+ if (check_true(input instanceof Number, "input instanceof Number") &&
+ check_true(1/Number(input) === Infinity, "1/Number(input) === Infinity")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'Number -0':
+ if (check_true(input instanceof Number, "input instanceof Number") &&
+ check_true(1/Number(input) === -Infinity, "1/Number(input) === -Infinity")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'Number NaN':
+ if (check_true(input instanceof Number, "input instanceof Number") &&
+ check_true(Number(input) !== Number(input), "Number(input) !== Number(input)")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'Number Infinity':
+ if (check_true(input instanceof Number, "input instanceof Number") &&
+ check_true(Number(input) === Infinity, "Number(input) === Infinity")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'Number -Infinity':
+ if (check_true(input instanceof Number, "input instanceof Number") &&
+ check_true(Number(input) === -Infinity, "Number(input) === -Infinity")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'Number 9007199254740992':
+ if (check_true(input instanceof Number) &&
+ check_true(Number(input) === 9007199254740992, "Number(input) === 9007199254740992")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'Number -9007199254740992':
+ if (check_true(input instanceof Number, "input instanceof Number") &&
+ check_true(Number(input) === -9007199254740992, "Number(input) === -9007199254740992")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'Number 9007199254740994':
+ if (check_true(input instanceof Number, "input instanceof Number") &&
+ check_true(Number(input) === 9007199254740994, "Number(input) === 9007199254740994")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'Number -9007199254740994':
+ if (check_true(input instanceof Number, "input instanceof Number") &&
+ check_true(Number(input) === -9007199254740994, "Number(input) === -9007199254740994")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'Array Number objects':
+ (function() {
+ if (check_true(input instanceof Array, 'input instanceof Array') &&
+ check_true(input.length === 10, 'input.length === 10') &&
+ check_true(Number(input[0]) === 0.2, "Number(input[0]) === 0.2") &&
+ check_true(1/Number(input[1]) === Infinity, "1/Number(input[1]) === Infinity") &&
+ check_true(1/Number(input[2]) === -Infinity, "1/Number(input[2]) === -Infinity") &&
+ check_true(Number(input[3]) !== Number(input[3]), "Number(input[3]) !== Number(input[3])") &&
+ check_true(Number(input[4]) === Infinity, "Number(input[4]) === Infinity") &&
+ check_true(Number(input[5]) === -Infinity, "Number(input[5]) === -Infinity") &&
+ check_true(Number(input[6]) === 9007199254740992, "Number(input[6]) === 9007199254740992") &&
+ check_true(Number(input[7]) === -9007199254740992, "Number(input[7]) === -9007199254740992") &&
+ check_true(Number(input[8]) === 9007199254740994, "Number(input[8]) === 9007199254740994") &&
+ check_true(Number(input[9]) === -9007199254740994, "Number(input[9]) === -9007199254740994")) {
+ for (var i = 0; i < input.length; ++i) {
+ if (!check_true(input[i] instanceof Number, 'input['+i+'] instanceof Number'))
+ return;
+ }
+ port.postMessage(input);
+ close();
+ }
+ })();
+ break;
+ case 'Object Number objects':
+ (function() {
+ if (check_true(input instanceof Object, 'input instanceof Object') &&
+ check_true(!(input instanceof Array), '!(input instanceof Array)') &&
+ check_true(Number(input['0.2']) === 0.2, "Number(input['0.2']) === 0.2") &&
+ check_true(1/Number(input['0']) === Infinity, "1/Number(input['0']) === Infinity") &&
+ check_true(1/Number(input['-0']) === -Infinity, "1/Number(input['-0']) === -Infinity") &&
+ check_true(Number(input['NaN']) !== Number(input['NaN']), "Number(input['NaN']) !== Number(input['NaN'])") &&
+ check_true(Number(input['Infinity']) === Infinity, "Number(input['Infinity']) === Infinity") &&
+ check_true(Number(input['-Infinity']) === -Infinity, "Number(input['-Infinity']) === -Infinity") &&
+ check_true(Number(input['9007199254740992']) === 9007199254740992, "Number(input['9007199254740992']) === 9007199254740992") &&
+ check_true(Number(input['-9007199254740992']) === -9007199254740992, "Number(input['-9007199254740992']) === -9007199254740992") &&
+ check_true(Number(input['9007199254740994']) === 9007199254740994, "Number(input['9007199254740994']) === 9007199254740994") &&
+ check_true(Number(input['-9007199254740994']) === -9007199254740994, "Number(input['-9007199254740994']) === -9007199254740994")) {
+ var i = 0;
+ for (var x in input) {
+ i++;
+ if (!check_true(input[x] instanceof Number, 'input['+x+'] instanceof Number'))
+ return;
+ }
+ if (check_true(i === 10, 'i === 10')) {
+ port.postMessage(input);
+ close();
+ }
+ }
+ })();
+ break;
+ case 'Date 0':
+ if (check_true(input instanceof Date, "input instanceof Date") &&
+ check_true(1/Number(input) === 1/Number(new Date(0)), "1/Number(input) === 1/Number(new Date(0))")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'Date -0':
+ if (check_true(input instanceof Date, "input instanceof Date") &&
+ check_true(1/Number(input) === 1/Number(new Date(-0)), "1/Number(input) === 1/Number(new Date(-0))")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'Date -8.64e15':
+ if (check_true(input instanceof Date, "input instanceof Date") &&
+ check_true(Number(input) === -8.64e15, "Number(input) === -8.64e15")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'Date 8.64e15':
+ if (check_true(input instanceof Date, "input instanceof Date") &&
+ check_true(Number(input) === 8.64e15, "Number(input) === 8.64e15")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'Array Date objects':
+ (function() {
+ if (check_true(input instanceof Array, 'input instanceof Array') &&
+ check_true(input.length === 4, 'input.length === 4') &&
+ check_true(1/Number(input[0]) === 1/new Date(0), '1/Number(input[0]) === 1/new Date(0)') &&
+ check_true(1/Number(input[1]) === 1/new Date(-0), '1/Number(input[1]) === 1/new Date(-0)') &&
+ check_true(Number(input[2]) === -8.64e15, 'Number(input[2]) === -8.64e15') &&
+ check_true(Number(input[3]) === 8.64e15, 'Number(input[3]) === 8.64e15')) {
+ for (var i = 0; i < input.length; ++i) {
+ if (!check_true(input[i] instanceof Date, 'input['+i+'] instanceof Date'))
+ return;
+ }
+ port.postMessage(input);
+ close();
+ }
+ })();
+ break;
+ case 'Object Date objects':
+ (function() {
+ if (check_true(input instanceof Object, 'input instanceof Object') &&
+ check_true(!(input instanceof Array), '!(input instanceof Array)') &&
+ check_true(1/Number(input['0']) === 1/new Date(0), "1/Number(input['0']) === 1/new Date(0)") &&
+ check_true(1/Number(input['-0']) === 1/new Date(-0), "1/Number(input[1]) === 1/new Date(-0)") &&
+ check_true(Number(input['-8.64e15']) === -8.64e15, "Number(input['-8.64e15']) === -8.64e15") &&
+ check_true(Number(input['8.64e15']) === 8.64e15, "Number(input['8.64e15']) === 8.64e15")) {
+ var i = 0;
+ for (var x in input) {
+ i++;
+ if (!check_true(input[x] instanceof Date, 'input['+x+'] instanceof Date'))
+ return;
+ }
+ port.postMessage(input);
+ close();
+ }
+ })();
+ break;
+ case 'RegExp flags and lastIndex':
+ case 'RegExp empty':
+ case 'RegExp slash':
+ case 'RegExp new line':
+ if (check_RegExp(msg, input)) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'Array RegExp object, RegExp flags and lastIndex':
+ case 'Array RegExp object, RegExp empty':
+ case 'Array RegExp object, RegExp slash':
+ case 'Array RegExp object, RegExp new line':
+ if (check_true(input instanceof Array, 'input instanceof Array') &&
+ check_true(input.length === 1, 'input.length === 1') &&
+ check_RegExp(msg.substr('Array RegExp object, '.length), input[0])) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'Object RegExp object, RegExp flags and lastIndex':
+ case 'Object RegExp object, RegExp empty':
+ case 'Object RegExp object, RegExp slash':
+ case 'Object RegExp object, RegExp new line':
+ (function() {
+ if (check_true(input instanceof Object, 'input instanceof Object') &&
+ check_true(!(input instanceof Array), '!(input instanceof Array)') &&
+ check_RegExp(msg.substr('Object RegExp object, '.length), input['x'])) {
+ var i = 0;
+ for (var x in input) {
+ i++;
+ }
+ if (check_true(i === 1, 'i === 1')) {
+ port.postMessage(input);
+ close();
+ }
+ }
+ })();
+ break;
+ case 'Blob basic':
+ case 'Blob unpaired high surrogate (invalid utf-8)':
+ case 'Blob unpaired low surrogate (invalid utf-8)':
+ case 'Blob paired surrogates (invalid utf-8)':
+ case 'Blob empty':
+ case 'Blob NUL':
+ check_Blob(msg, input, port);
+ // no postMessage or close here, check_Blob takes care of that
+ break;
+ case 'Array Blob object, Blob basic':
+ case 'Array Blob object, Blob unpaired high surrogate (invalid utf-8)':
+ case 'Array Blob object, Blob unpaired low surrogate (invalid utf-8)':
+ case 'Array Blob object, Blob paired surrogates (invalid utf-8)':
+ case 'Array Blob object, Blob empty':
+ case 'Array Blob object, Blob NUL':
+ if (check_true(input instanceof Array, 'input instanceof Array') &&
+ check_true(input.length === 1, 'input.length === 1')) {
+ check_Blob(msg.substr('Array Blob object, '.length), input[0], port, false, input);
+ // no postMessage or close here, check_Blob takes care of that
+ }
+ break;
+ case 'Object Blob object, Blob basic':
+ case 'Object Blob object, Blob unpaired high surrogate (invalid utf-8)':
+ case 'Object Blob object, Blob unpaired low surrogate (invalid utf-8)':
+ case 'Object Blob object, Blob paired surrogates (invalid utf-8)':
+ case 'Object Blob object, Blob empty':
+ case 'Object Blob object, Blob NUL':
+ (function() {
+ if (check_true(input instanceof Object, 'input instanceof Object') &&
+ check_true(!(input instanceof Array), '!(input instanceof Array)')) {
+ var i = 0;
+ for (var x in input) {
+ i++;
+ }
+ if (check_true(i === 1, 'i === 1')) {
+ check_Blob(msg.substr('Object Blob object, '.length), input['x'], port, false, input);
+ // no postMessage or close here, check_Blob takes care of that
+ }
+ }
+ })();
+ break;
+ case 'File basic':
+ check_Blob(msg, input, port, true);
+ // no postMessage or close here, check_Blob takes care of that
+ break;
+ case 'FileList empty':
+ if (check_FileList(msg, input)) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'Array FileList object, FileList empty':
+ if (check_true(input instanceof Array, 'input instanceof Array') &&
+ check_true(input.length === 1, 'input.length === 1') &&
+ check_FileList(msg.substr('Array FileList object, '.length), input[0])) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'Object FileList object, FileList empty':
+ (function() {
+ if (check_true(input instanceof Object, 'input instanceof Object') &&
+ check_true(!(input instanceof Array), '!(input instanceof Array)') &&
+ check_FileList(msg.substr('Array FileList object, '.length), input['x'])) {
+ var i = 0;
+ for (var x in input) {
+ i++;
+ }
+ if (check_true(i === 1, 'i === 1')) {
+ port.postMessage(input);
+ close();
+ }
+ }
+ })();
+ break;
+ case 'ImageData 1x1 transparent black':
+ if (check_ImageData(input, {width:1, height:1, data:[0,0,0,0]})) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'ImageData 1x1 non-transparent non-black':
+ if (check_ImageData(input, {width:1, height:1, data:[100, 101, 102, 103]})) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'Array ImageData object, ImageData 1x1 transparent black':
+ if (check_true(input instanceof Array, 'input instanceof Array') &&
+ check_true(input.length === 1, 'input.length === 1') &&
+ check_ImageData(input[0], {width:1, height:1, data:[0,0,0,0]})) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'Array ImageData object, ImageData 1x1 non-transparent non-black':
+ if (check_true(input instanceof Array, 'input instanceof Array') &&
+ check_true(input.length === 1, 'input.length === 1') &&
+ check_ImageData(input[0], {width:1, height:1, data:[100, 101, 102, 103]})) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'Object ImageData object, ImageData 1x1 transparent black':
+ (function(){
+ if (check_true(input instanceof Object, 'input instanceof Object') &&
+ check_true(!(input instanceof Array), '!(input instanceof Array)') &&
+ check_ImageData(input['x'], {width:1, height:1, data:[0,0,0,0]})) {
+ var i = 0;
+ for (var x in input) {
+ i++;
+ }
+ if (check_true(i === 1, 'i === 1')) {
+ port.postMessage(input);
+ close();
+ }
+ }
+ })();
+ break;
+ case 'Object ImageData object, ImageData 1x1 non-transparent non-black':
+ (function() {
+ if (check_true(input instanceof Object, 'input instanceof Object') &&
+ check_true(!(input instanceof Array), '!(input instanceof Array)') &&
+ check_ImageData(input['x'], {width:1, height:1, data:[100, 101, 102, 103]})) {
+ var i = 0;
+ for (var x in input) {
+ i++;
+ }
+ if (check_true(i === 1, 'i === 1')) {
+ port.postMessage(input);
+ close();
+ }
+ }
+ })();
+ break;
+ case 'ImageBitmap 1x1 transparent black':
+ if (check_ImageBitmap(input, {width:1, height:1, data:[0, 0, 0, 0]})) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'ImageBitmap 1x1 non-transparent non-black':
+ if (check_ImageBitmap(input, {width:1, height:1, data:[100, 101, 102, 103]})) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'Array ImageBitmap object, ImageBitmap 1x1 transparent black':
+ if (check_true(input instanceof Array, 'input instanceof Array') &&
+ check_true(input.length === 1, 'input.length === 1') &&
+ check_ImageBitmap(input[0], {width:1, height:1, data:[0, 0, 0, 0]})) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'Array ImageBitmap object, ImageBitmap 1x1 non-transparent non-black':
+ if (check_true(input instanceof Array, 'input instanceof Array') &&
+ check_true(input.length === 1, 'input.length === 1') &&
+ check_ImageBitmap(input[0], {width:1, height:1, data:[100, 101, 102, 103]})) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'Object ImageBitmap object, ImageBitmap 1x1 transparent black':
+ (function() {
+ if (check_true(input instanceof Object, 'input instanceof Object') &&
+ check_true(!(input instanceof Array), '!(input instanceof Array)') &&
+ check_ImageBitmap(input['x'], {width:1, height:1, data:[0, 0, 0, 0]})) {
+ var i = 0;
+ for (var x in input) {
+ i++;
+ }
+ if (check_true(i === 1, 'i === 1')) {
+ port.postMessage(input);
+ close();
+ }
+ }
+ })();
+ break;
+ case 'Object ImageBitmap object, ImageBitmap 1x1 non-transparent non-black':
+ (function() {
+ if (check_true(input instanceof Object, 'input instanceof Object') &&
+ check_true(!(input instanceof Array), '!(input instanceof Array)') &&
+ check_ImageBitmap(input['x'], {width:1, height:1, data:[100, 101, 102, 103]})) {
+ var i = 0;
+ for (var x in input) {
+ i++;
+ }
+ if (check_true(i === 1, 'i === 1')) {
+ port.postMessage(input);
+ close();
+ }
+ }
+ })();
+ break;
+ case 'Array sparse':
+ (function() {
+ if (check_true(input instanceof Array, 'input instanceof Array') &&
+ check_true(input.length === 10, 'input.length === 10')) {
+ for (var x in input) {
+ check_true(false, 'unexpected enumerable property '+x);
+ return;
+ }
+ port.postMessage(input);
+ close();
+ }
+ })();
+ break;
+ case 'Array with non-index property':
+ if (check_true(input instanceof Array, 'input instanceof Array') &&
+ check_true(input.length === 0, 'input.length === 0') &&
+ check_true(input.foo === 'bar', "input.foo === 'bar'")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'Object with index property and length':
+ if (check_true(input instanceof Object, 'input instanceof Object') &&
+ check_true(!(input instanceof Array), '!(input instanceof Array)') &&
+ check_true(input[0] === 'foo', "input[0] === 'foo'") &&
+ check_true(input.length === 1, 'input.length === 1')) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'Array with circular reference':
+ if (check_true(input instanceof Array, 'input instanceof Array') &&
+ check_true(input.length === 1, 'input.length === 1') &&
+ check_true(input[0] === input, "input[0] === input")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'Object with circular reference':
+ if (check_true(input instanceof Object, 'input instanceof Object') &&
+ check_true(!(input instanceof Array), '!(input instanceof Array)') &&
+ check_true(input['x'] === input, "input['x'] === input")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'Array with identical property values':
+ if (check_true(input instanceof Array, 'input instanceof Array') &&
+ check_true(input.length === 2, 'input.length === 2') &&
+ check_true(input[0] === input[1], "input[0] === input[1]")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'Object with identical property values':
+ if (check_true(input instanceof Object, 'input instanceof Object') &&
+ check_true(!(input instanceof Array), '!(input instanceof Array)') &&
+ check_true(input['x'] === input['y'], "input['x'] === input['y']")) {
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'Object with property on prototype':
+ case 'Object with non-enumerable property':
+ if (check_true(input instanceof Object, 'input instanceof Object') &&
+ check_true(!(input instanceof Array), '!(input instanceof Array)') &&
+ check_true(!('foo' in input), "!('foo' in input)")) {
+ input = {};
+ Object.defineProperty(input, 'foo', {value:'bar', enumerable:false, writable:true, configurable:true});
+ port.postMessage(input);
+ close();
+ }
+ break;
+ case 'Object with non-writable property':
+ if (check_true(input instanceof Object, 'input instanceof Object') &&
+ check_true(!(input instanceof Array), '!(input instanceof Array)') &&
+ check_true(input.foo === 'bar', "input.foo === bar")) {
+ input.foo += ' baz';
+ if (check_true(input.foo === 'bar baz', "input.foo === 'bar baz'")) {
+ input = {};
+ Object.defineProperty(input, 'foo', {value:'bar', enumerable:true, writable:false, configurable:true});
+ port.postMessage(input);
+ close();
+ }
+ }
+ break;
+ case 'Object with non-configurable property':
+ if (check_true(input instanceof Object, 'input instanceof Object') &&
+ check_true(!(input instanceof Array), '!(input instanceof Array)') &&
+ check_true(input.foo === 'bar', "input.foo === bar")) {
+ delete input.foo;
+ if (check_true(!('foo' in input), "!('foo' in input)")) {
+ input = {};
+ Object.defineProperty(input, 'foo', {value:'bar', enumerable:true, writable:true, configurable:false});
+ port.postMessage(input);
+ close();
+ }
+ }
+ break;
+
+ default:
+ port.postMessage('FAIL: unknown test');
+ close();
+ }
+ if (log.length > 0) {
+ port.postMessage('FAIL '+log);
+ close();
+ }
+ } catch (ex) {
+ port.postMessage('FAIL '+ex);
+ close();
+ }
+}
diff --git a/testing/web-platform/tests/workers/semantics/xhr/001-1.xml b/testing/web-platform/tests/workers/semantics/xhr/001-1.xml
new file mode 100644
index 000000000..5d735bdf6
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/xhr/001-1.xml
@@ -0,0 +1 @@
+<x>foo</x> \ No newline at end of file
diff --git a/testing/web-platform/tests/workers/semantics/xhr/001.html b/testing/web-platform/tests/workers/semantics/xhr/001.html
new file mode 100644
index 000000000..e26e21c62
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/xhr/001.html
@@ -0,0 +1,35 @@
+<!--
+var xhr = new XMLHttpRequest();
+var log = '';
+xhr.onreadystatechange = function(e) {
+ if (this.readyState == 4) {
+ if (this.responseXML != null)
+ log += 'responseXML was not null. ';
+ if (this.responseText != '<x>foo</x>')
+ log += 'responseText was ' + this.responseText + ', expected <x>foo</x>. ';
+ postMessage(log);
+ }
+}
+xhr.open('GET', '001-1.xml', true);
+xhr.send();
+/*
+-->
+<!doctype html>
+<title>async XMLHttpRequest in dedicated worker</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+var t = async_test();
+function runtest() {
+ var worker = new Worker('#');
+ worker.onmessage = this.step_func(function(e) {
+ assert_equals(e.data, '');
+ this.done();
+ });
+}
+</script>
+<iframe src=001-1.xml onload="t.step(runtest);"></iframe>
+<!--
+*/
+//--> \ No newline at end of file
diff --git a/testing/web-platform/tests/workers/semantics/xhr/002.html b/testing/web-platform/tests/workers/semantics/xhr/002.html
new file mode 100644
index 000000000..0d3386e98
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/xhr/002.html
@@ -0,0 +1,32 @@
+<!--
+var xhr = new XMLHttpRequest();
+var log = '';
+xhr.open('GET', '001-1.xml', false);
+xhr.send();
+if (xhr.responseXML != null)
+ log += 'responseXML was not null. ';
+if (xhr.responseText != '<x>foo</x>')
+ log += 'responseText was ' + this.responseText + ', expected <x>foo</x>. ';
+postMessage(log);
+
+/*
+-->
+<!doctype html>
+<title>sync XMLHttpRequest in dedicated worker</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+var t = async_test();
+function runtest() {
+ var worker = new Worker('#');
+ worker.onmessage = this.step_func(function(e) {
+ assert_equals(e.data, '');
+ this.done();
+ });
+}
+</script>
+<iframe src=001-1.xml onload="t.step(runtest);"></iframe>
+<!--
+*/
+//--> \ No newline at end of file
diff --git a/testing/web-platform/tests/workers/semantics/xhr/003.html b/testing/web-platform/tests/workers/semantics/xhr/003.html
new file mode 100644
index 000000000..70edaf417
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/xhr/003.html
@@ -0,0 +1,41 @@
+<!--
+onconnect = function(e) {
+ var xhr = new XMLHttpRequest();
+ var log = '';
+ var port = e.ports[0];
+ var postMessage = port.postMessage;
+ xhr.onreadystatechange = function(e) {
+ if (this.readyState == 4) {
+ if (this.responseXML != null)
+ log += 'responseXML was not null. ';
+ if (this.responseText && this.responseText != '<x>foo</x>')
+ log += 'responseText was ' + this.responseText + ', expected <x>foo</x>. ';
+ postMessage.call(port, log);
+ }
+ }
+ xhr.open('GET', '001-1.xml', true);
+ xhr.send();
+}
+
+/*
+-->
+<!doctype html>
+<title>async XMLHttpRequest in shared worker</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+var t = async_test();
+function runtest() {
+ var worker = new SharedWorker('#', '');
+ worker.port.onmessage = this.step_func(function(e) {
+ assert_equals(e.data, '');
+ this.done();
+ });
+}
+</script>
+<iframe src=001-1.xml onload="t.step(runtest);"></iframe>
+<!--
+*/
+//-->
+
diff --git a/testing/web-platform/tests/workers/semantics/xhr/004.html b/testing/web-platform/tests/workers/semantics/xhr/004.html
new file mode 100644
index 000000000..ec5893a4b
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/xhr/004.html
@@ -0,0 +1,36 @@
+<!--
+onconnect = function(e) {
+ var xhr = new XMLHttpRequest();
+ var log = '';
+ xhr.open('GET', '001-1.xml', false);
+ xhr.send();
+ if (xhr.responseXML != null)
+ log += 'responseXML was not null. ';
+ if (xhr.responseText != '<x>foo</x>')
+ log += 'responseText was ' + xhr.responseText + ', expected <x>foo</x>. ';
+ e.ports[0].postMessage(log);
+}
+
+/*
+-->
+<!doctype html>
+<title>sync XMLHttpRequest in shared worker</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+var t = async_test();
+function runtest() {
+ var worker = new SharedWorker('#', '');
+ worker.port.onmessage = this.step_func(function(e) {
+ assert_equals(e.data, '');
+ this.done();
+ });
+}
+</script>
+<iframe src=001-1.xml onload="t.step(runtest);"></iframe>
+<!--
+*/
+//-->
+
+
diff --git a/testing/web-platform/tests/workers/semantics/xhr/005.html b/testing/web-platform/tests/workers/semantics/xhr/005.html
new file mode 100644
index 000000000..84abdb0c4
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/xhr/005.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<title>base url, dedicated worker</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+var t = async_test();
+var i = 0;
+function runtest() {
+ i++;
+ if (i != 2)
+ return;
+ var worker = new Worker('support/005-1.js');
+ worker.onmessage = this.step_func(function(e) {
+ assert_true(e.data);
+ this.done();
+ });
+}
+</script>
+<iframe src=001-1.xml onload="t.step(runtest);"></iframe>
+<iframe src=support/001-1.xml onload="t.step(runtest);"></iframe>
diff --git a/testing/web-platform/tests/workers/semantics/xhr/006.html b/testing/web-platform/tests/workers/semantics/xhr/006.html
new file mode 100644
index 000000000..7411b4bae
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/xhr/006.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<title>base url, shared worker</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+var t = async_test();
+var i = 0;
+function runtest() {
+ i++;
+ if (i != 2)
+ return;
+ var worker = new SharedWorker('support/006-1.js','');
+ worker.port.onmessage = this.step_func(function(e) {
+ assert_true(e.data);
+ this.done();
+ });
+}
+</script>
+<iframe src=001-1.xml onload="t.step(runtest);"></iframe>
+<iframe src=support/001-1.xml onload="t.step(runtest);"></iframe>
diff --git a/testing/web-platform/tests/workers/semantics/xhr/support/001-1.xml b/testing/web-platform/tests/workers/semantics/xhr/support/001-1.xml
new file mode 100644
index 000000000..ecea58a93
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/xhr/support/001-1.xml
@@ -0,0 +1 @@
+<x>bar</x> \ No newline at end of file
diff --git a/testing/web-platform/tests/workers/semantics/xhr/support/005-1.js b/testing/web-platform/tests/workers/semantics/xhr/support/005-1.js
new file mode 100644
index 000000000..45f6519a2
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/xhr/support/005-1.js
@@ -0,0 +1,5 @@
+var xhr = new XMLHttpRequest();
+xhr.open('GET', '001-1.xml', false);
+xhr.send();
+var passed = xhr.responseText == '<x>bar</x>';
+postMessage(passed); \ No newline at end of file
diff --git a/testing/web-platform/tests/workers/semantics/xhr/support/006-1.js b/testing/web-platform/tests/workers/semantics/xhr/support/006-1.js
new file mode 100644
index 000000000..d446781eb
--- /dev/null
+++ b/testing/web-platform/tests/workers/semantics/xhr/support/006-1.js
@@ -0,0 +1,7 @@
+onconnect = function(e) {
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', '001-1.xml', false);
+ xhr.send();
+ var passed = xhr.responseText == '<x>bar</x>';
+ e.ports[0].postMessage(passed);
+} \ No newline at end of file
diff --git a/testing/web-platform/tests/workers/support/ErrorEvent-error.js b/testing/web-platform/tests/workers/support/ErrorEvent-error.js
new file mode 100644
index 000000000..930b54c0d
--- /dev/null
+++ b/testing/web-platform/tests/workers/support/ErrorEvent-error.js
@@ -0,0 +1,9 @@
+onerror = function(message, location, line, col, error) {
+ postMessage({ source: "onerror", value: error });
+}
+
+addEventListener("error", function(e) {
+ postMessage({ source: "event listener", value: e.error });
+});
+
+throw "hello";
diff --git a/testing/web-platform/tests/workers/support/ErrorEvent.js b/testing/web-platform/tests/workers/support/ErrorEvent.js
new file mode 100644
index 000000000..22ea6d4fb
--- /dev/null
+++ b/testing/web-platform/tests/workers/support/ErrorEvent.js
@@ -0,0 +1,10 @@
+onmessage = function(evt)
+{
+ throw(new Error(evt.data));
+}
+
+onerror = function(message, location, line, col)
+{
+ postMessage( {"message": message, "filename": location, "lineno": line, "colno": col} );
+ return false; // "not handled" so the error propagates up to the Worker object
+}
diff --git a/testing/web-platform/tests/workers/support/ImportScripts.js b/testing/web-platform/tests/workers/support/ImportScripts.js
new file mode 100644
index 000000000..7f2a2bcb5
--- /dev/null
+++ b/testing/web-platform/tests/workers/support/ImportScripts.js
@@ -0,0 +1,9 @@
+try
+{
+ importScripts("WorkerBasic.js");
+}
+catch(ex)
+{
+ result = "Fail";
+ postMessage(result);
+}
diff --git a/testing/web-platform/tests/workers/support/ImportScriptsNetworkErr.js b/testing/web-platform/tests/workers/support/ImportScriptsNetworkErr.js
new file mode 100644
index 000000000..8179c8b10
--- /dev/null
+++ b/testing/web-platform/tests/workers/support/ImportScriptsNetworkErr.js
@@ -0,0 +1,15 @@
+var result = "Fail";
+
+try
+{
+ importScripts("NonExistentFile.js");
+}
+catch(ex)
+{
+ if (ex.code != null && ex.code == ex.NETWORK_ERR)
+ {
+ result = "Pass";
+ }
+}
+
+postMessage(result); \ No newline at end of file
diff --git a/testing/web-platform/tests/workers/support/Timer.js b/testing/web-platform/tests/workers/support/Timer.js
new file mode 100644
index 000000000..a86a224db
--- /dev/null
+++ b/testing/web-platform/tests/workers/support/Timer.js
@@ -0,0 +1,50 @@
+var count = 0;
+var id;
+
+onmessage = function(evt)
+{
+ try
+ {
+ switch(evt.data)
+ {
+ case "TimeoutHandler":
+ count = 0;
+ id = setTimeout("TimeoutHandler()", 10);
+ postMessage('hello');
+ break;
+ case "IntervalHandler":
+ count = 0;
+ id = setInterval("IntervalHandler()", 10);
+ postMessage('hello');
+ break;
+ }
+ }
+ catch(ex)
+ {
+ postMessage("Fail");
+ }
+}
+
+function TimeoutHandler()
+{
+ count++;
+ postMessage("worker");
+
+ id = setTimeout("TimeoutHandler()", 10);
+
+ if (count >= 2)
+ {
+ clearTimeout(id);
+ }
+}
+
+function IntervalHandler()
+{
+ count++;
+ postMessage("worker");
+
+ if (count >= 2)
+ {
+ clearInterval(id);
+ }
+}
diff --git a/testing/web-platform/tests/workers/support/WorkerBasic.js b/testing/web-platform/tests/workers/support/WorkerBasic.js
new file mode 100644
index 000000000..6bb6d32b1
--- /dev/null
+++ b/testing/web-platform/tests/workers/support/WorkerBasic.js
@@ -0,0 +1,7 @@
+var result = "Fail";
+
+onmessage = function(evt)
+{
+ result = "Pass";
+ postMessage(result);
+} \ No newline at end of file
diff --git a/testing/web-platform/tests/workers/support/WorkerClose.js b/testing/web-platform/tests/workers/support/WorkerClose.js
new file mode 100644
index 000000000..81f99993d
--- /dev/null
+++ b/testing/web-platform/tests/workers/support/WorkerClose.js
@@ -0,0 +1,5 @@
+onmessage = function(evt)
+{
+ postMessage(evt.data);
+ self.close();
+} \ No newline at end of file
diff --git a/testing/web-platform/tests/workers/support/WorkerDataCloneErr.js b/testing/web-platform/tests/workers/support/WorkerDataCloneErr.js
new file mode 100644
index 000000000..b7e8b0ae1
--- /dev/null
+++ b/testing/web-platform/tests/workers/support/WorkerDataCloneErr.js
@@ -0,0 +1,15 @@
+var result = "Fail";
+
+try
+{
+ postMessage(navigator);
+}
+catch(ex)
+{
+ if(ex.code != null && ex.code == ex.DATA_CLONE_ERR)
+ {
+ result = "Pass";
+ }
+}
+
+postMessage(result); \ No newline at end of file
diff --git a/testing/web-platform/tests/workers/support/WorkerLocation.js b/testing/web-platform/tests/workers/support/WorkerLocation.js
new file mode 100644
index 000000000..a57e2fc66
--- /dev/null
+++ b/testing/web-platform/tests/workers/support/WorkerLocation.js
@@ -0,0 +1,12 @@
+var obj = new Object();
+obj.location = location.toString();
+obj.href = location.href;
+obj.protocol = location.protocol;
+obj.host = location.host;
+obj.hostname = location.hostname;
+obj.port = location.port;
+obj.pathname = location.pathname;
+obj.search = location.search;
+obj.hash = location.hash;
+
+postMessage(obj);
diff --git a/testing/web-platform/tests/workers/support/WorkerNavigator.js b/testing/web-platform/tests/workers/support/WorkerNavigator.js
new file mode 100644
index 000000000..084e45b24
--- /dev/null
+++ b/testing/web-platform/tests/workers/support/WorkerNavigator.js
@@ -0,0 +1,8 @@
+var obj = new Object();
+obj.appName = navigator.appName;
+obj.appVersion = navigator.appVersion;
+obj.platform = navigator.platform;
+obj.userAgent = navigator.userAgent;
+obj.onLine = navigator.onLine;
+
+postMessage(obj);
diff --git a/testing/web-platform/tests/workers/support/WorkerTerminate.js b/testing/web-platform/tests/workers/support/WorkerTerminate.js
new file mode 100644
index 000000000..7c99e7ec5
--- /dev/null
+++ b/testing/web-platform/tests/workers/support/WorkerTerminate.js
@@ -0,0 +1,10 @@
+onmessage = function(evt)
+{
+ for (var i=0; true; i++)
+ {
+ if (i%1000 == 0)
+ {
+ postMessage(i);
+ }
+ }
+}
diff --git a/testing/web-platform/tests/workers/support/WorkerText.txt b/testing/web-platform/tests/workers/support/WorkerText.txt
new file mode 100644
index 000000000..e4eeb5391
--- /dev/null
+++ b/testing/web-platform/tests/workers/support/WorkerText.txt
@@ -0,0 +1,2 @@
+var result = "Pass";
+postMessage(result);