servo/tests/wpt/web-platform-tests/workers
2019-12-10 11:06:32 +00:00
..
baseurl Update web-platform-tests to revision 60220357131c65146444da1f54624d5b54d0975d 2018-07-18 22:07:44 +00:00
constructors Update web-platform-tests to revision 89aa3f42131cce5a77268ddaeb2fab8a2e29c2a6 2019-11-17 14:10:26 +00:00
examples Update web-platform-tests to revision a589fd30bc64bb4d40e1d6854e07accca69b8472 2019-01-18 22:11:13 -05:00
interfaces Update web-platform-tests to revision cbd8c8ca929bc1aea71087be3b826cf1ee189a52 2019-10-28 14:07:02 +00:00
modules Update web-platform-tests to revision 9f31d497bf87bdf5ebc3ba70b5cb9f87786f4071 2019-10-15 13:26:56 +00:00
non-automated Update web-platform-tests to revision 097043b336e46876e281ddec3bb014fe9c480128 2019-08-03 15:03:51 +00:00
semantics Update web-platform-tests to revision cbd8c8ca929bc1aea71087be3b826cf1ee189a52 2019-10-28 14:07:02 +00:00
support Update web-platform-tests to revision 78f764c05c229883e87ad135c7153051a66e2851 2019-03-06 22:39:43 -05:00
data-url-shared-window.html Update web-platform-tests to revision be5419e845d39089ba6dc338c1bd0fa279108317 2018-01-09 12:52:27 -05:00
data-url-shared.html Update web-platform-tests to revision 3678c44dfe811f93a796285e9531ee34d7d15682 2018-02-27 22:03:50 -05:00
data-url.html Update web-platform-tests to revision 0fe9f012a8ee5503b728a379705a6c5286ba1e96 2018-02-23 21:56:20 -05:00
dedicated-worker-from-blob-url.window.js Update web-platform-tests to revision 90e1ee27eede63cf117f19c1e55553cc1881aef0 2019-09-27 13:51:36 +00:00
importscripts_mime.any.js Update web-platform-tests to revision 4984b190341b535c645729b8f99247aace0022fe 2018-12-17 22:27:33 -05:00
META.yml Update web-platform-tests to revision 60220357131c65146444da1f54624d5b54d0975d 2018-07-18 22:07:44 +00:00
name-property.html Update web-platform-tests to revision cf261625e2d230ab219eec966f4abe26e3401b64 2018-05-29 23:08:06 -04:00
nested_worker.worker.js Update web-platform-tests to revision cf261625e2d230ab219eec966f4abe26e3401b64 2018-05-29 23:08:06 -04:00
nested_worker_close_from_parent_worker.html Update web-platform-tests to revision 4333a1d2f109795547fc5e22ebfc8481fa649de7 2018-06-22 22:44:39 -04:00
nested_worker_close_self.worker.js Update web-platform-tests to revision 4333a1d2f109795547fc5e22ebfc8481fa649de7 2018-06-22 22:44:39 -04:00
nested_worker_importScripts.worker.js Update web-platform-tests to revision 4333a1d2f109795547fc5e22ebfc8481fa649de7 2018-06-22 22:44:39 -04:00
nested_worker_sync_xhr.worker.js Update web-platform-tests to revision 4333a1d2f109795547fc5e22ebfc8481fa649de7 2018-06-22 22:44:39 -04:00
nested_worker_terminate_from_document.html Update web-platform-tests to revision 4333a1d2f109795547fc5e22ebfc8481fa649de7 2018-06-22 22:44:39 -04:00
opaque-origin.html Update web-platform-tests to revision 1829a42c93e435937db68c8a842fa9b56dd39dc2 2018-05-30 22:50:35 -04:00
postMessage_clone_port.htm
postMessage_clone_port_error.htm
postMessage_DataCloneErr.htm
postMessage_event_properties.htm
postMessage_ports_readonly_array.htm
postMessage_target_source.htm
README.md Update web-platform-tests to revision d75cd4df6722acef7224eb6edcdc52b125680dad 2019-08-28 15:09:15 +00:00
shared-worker-from-blob-url.window.js Update web-platform-tests to revision a8fb1792cbfab3ed59401775da76fb6c15d9f2e2 2018-11-23 15:48:00 -05:00
shared-worker-name-via-options.html Update web-platform-tests to revision cbd8c8ca929bc1aea71087be3b826cf1ee189a52 2019-10-28 14:07:02 +00:00
SharedWorker-constructor.html Update web-platform-tests to revision ac12b3e9488edb436f063b11213e954ae62d5a5e 2019-01-30 22:39:55 -05:00
SharedWorker-detach-frame-in-error-event.html Update web-platform-tests to revision e426a6933a05bf144eba06a1d4c47ba876a4e2d1 2019-05-22 14:00:10 +00:00
SharedWorker-exception-propagation.html Update web-platform-tests to revision ac12b3e9488edb436f063b11213e954ae62d5a5e 2019-01-30 22:39:55 -05:00
SharedWorker-exception.html Update web-platform-tests to revision ac12b3e9488edb436f063b11213e954ae62d5a5e 2019-01-30 22:39:55 -05:00
SharedWorker-MessageEvent-source.any.js Update web-platform-tests to revision ac12b3e9488edb436f063b11213e954ae62d5a5e 2019-01-30 22:39:55 -05:00
SharedWorker-replace-EventHandler.any.js Update web-platform-tests to revision ac12b3e9488edb436f063b11213e954ae62d5a5e 2019-01-30 22:39:55 -05:00
SharedWorker-script-error.html Update web-platform-tests to revision ac12b3e9488edb436f063b11213e954ae62d5a5e 2019-01-30 22:39:55 -05:00
SharedWorker-simple.html Update web-platform-tests to revision ac12b3e9488edb436f063b11213e954ae62d5a5e 2019-01-30 22:39:55 -05:00
SharedWorker_blobUrl.html
SharedWorker_dataUrl.html Update web-platform-tests to revision be5419e845d39089ba6dc338c1bd0fa279108317 2018-01-09 12:52:27 -05:00
SharedWorkerPerformanceNow.html Update web-platform-tests to revision c26470dac73f2df9d4822a0d3482f7eb1ebf57d9 2018-01-16 17:18:09 +01:00
Worker-base64.any.js Update web-platform-tests to revision ac12b3e9488edb436f063b11213e954ae62d5a5e 2019-01-30 22:39:55 -05:00
Worker-call.worker.js Update web-platform-tests to revision ac12b3e9488edb436f063b11213e954ae62d5a5e 2019-01-30 22:39:55 -05:00
Worker-constructor-proto.any.js Update web-platform-tests to revision fa41b43ac93bc2fdc2427a4378dc3754d483cdda 2019-12-10 11:06:32 +00:00
Worker-custom-event.any.js Update web-platform-tests to revision b7a8b84debb42268ea95a45bdad8f727d1facdf7 2019-03-21 23:44:37 -04:00
Worker-formdata.any.js Update web-platform-tests to revision b7a8b84debb42268ea95a45bdad8f727d1facdf7 2019-03-21 23:44:37 -04:00
Worker-location.sub.any.js Update web-platform-tests to revision fa41b43ac93bc2fdc2427a4378dc3754d483cdda 2019-12-10 11:06:32 +00:00
Worker-messageport.html Update web-platform-tests to revision 78f764c05c229883e87ad135c7153051a66e2851 2019-03-06 22:39:43 -05:00
Worker-multi-port.html Update web-platform-tests to revision fa41b43ac93bc2fdc2427a4378dc3754d483cdda 2019-12-10 11:06:32 +00:00
Worker-nested-importScripts-error.html Prevent the error from triggering a page error in Worker-nested-importScripts-error 2019-06-12 10:15:52 +02:00
worker-performance.worker.js Update web-platform-tests to revision c26470dac73f2df9d4822a0d3482f7eb1ebf57d9 2018-01-16 17:18:09 +01:00
Worker-replace-event-handler.any.js Update web-platform-tests to revision b7a8b84debb42268ea95a45bdad8f727d1facdf7 2019-03-21 23:44:37 -04:00
Worker-replace-global-constructor.any.js Update web-platform-tests to revision ac12b3e9488edb436f063b11213e954ae62d5a5e 2019-01-30 22:39:55 -05:00
Worker-replace-self.any.js Update web-platform-tests to revision ac12b3e9488edb436f063b11213e954ae62d5a5e 2019-01-30 22:39:55 -05:00
Worker-simultaneous-errors.html Update web-platform-tests to revision ac12b3e9488edb436f063b11213e954ae62d5a5e 2019-01-30 22:39:55 -05:00
Worker-structure-message.html Update web-platform-tests to revision 78f764c05c229883e87ad135c7153051a66e2851 2019-03-06 22:39:43 -05:00
Worker-terminate-forever.html Update web-platform-tests to revision 78f764c05c229883e87ad135c7153051a66e2851 2019-03-06 22:39:43 -05:00
Worker-termination-with-port-messages.html Update web-platform-tests to revision ac12b3e9488edb436f063b11213e954ae62d5a5e 2019-01-30 22:39:55 -05:00
Worker-timeout-cancel-order.html Update web-platform-tests to revision 78f764c05c229883e87ad135c7153051a66e2851 2019-03-06 22:39:43 -05:00
Worker-timeout-decreasing-order.html Update web-platform-tests to revision 78f764c05c229883e87ad135c7153051a66e2851 2019-03-06 22:39:43 -05:00
Worker-timeout-increasing-order.html Update web-platform-tests to revision 78f764c05c229883e87ad135c7153051a66e2851 2019-03-06 22:39:43 -05:00
Worker_basic.htm
Worker_cross_origin_security_err.htm Update web-platform-tests to revision 122a4672fa0dc554a6e7528fa3487fd907c792ee 2019-03-23 23:57:08 -04:00
Worker_dispatchEvent_ErrorEvent.htm
Worker_ErrorEvent_bubbles_cancelable.htm
Worker_ErrorEvent_error.htm
Worker_ErrorEvent_filename.htm
Worker_ErrorEvent_lineno.htm
Worker_ErrorEvent_message.htm
Worker_ErrorEvent_type.htm
Worker_NosniffErr.htm
Worker_script_mimetype.htm Update web-platform-tests to revision fa41b43ac93bc2fdc2427a4378dc3754d483cdda 2019-12-10 11:06:32 +00:00
Worker_terminate_event_queue.htm
WorkerGlobalScope-close.html Update web-platform-tests to revision fa41b43ac93bc2fdc2427a4378dc3754d483cdda 2019-12-10 11:06:32 +00:00
WorkerGlobalScope_ErrorEvent_colno.htm
WorkerGlobalScope_ErrorEvent_filename.htm
WorkerGlobalScope_ErrorEvent_lineno.htm
WorkerGlobalScope_ErrorEvent_message.htm
WorkerGlobalScope_importScripts.htm
WorkerGlobalScope_importScripts_NetworkErr.htm
WorkerGlobalScope_importScripts_NosniffErr.htm
WorkerGlobalScope_requestAnimationFrame.tentative.worker.js Update web-platform-tests to revision 848ceffad26e92d47ffe790ed8b650906b2c2343 2018-08-10 14:45:43 -04:00
WorkerGlobalScope_setInterval.htm
WorkerGlobalScope_setTimeout.htm
WorkerLocation-origin.sub.window.js
WorkerLocation.htm
WorkerLocation_hash.htm
WorkerLocation_hash_encoding.htm
WorkerLocation_hash_nonexist.htm
WorkerLocation_host.htm
WorkerLocation_hostname.htm
WorkerLocation_href.htm
WorkerLocation_pathname.htm
WorkerLocation_port.htm
WorkerLocation_protocol.htm
WorkerLocation_search.htm
WorkerLocation_search_empty.htm
WorkerLocation_search_fragment.htm
WorkerLocation_search_nonexist.htm
WorkerNavigator-hardware-concurrency.any.js Update web-platform-tests to revision b7a8b84debb42268ea95a45bdad8f727d1facdf7 2019-03-21 23:44:37 -04:00
WorkerNavigator.any.js Update web-platform-tests to revision ac12b3e9488edb436f063b11213e954ae62d5a5e 2019-01-30 22:39:55 -05:00
WorkerNavigator_appName.htm
WorkerNavigator_appVersion.htm
WorkerNavigator_onLine.htm
WorkerNavigator_platform.htm
WorkerNavigator_userAgent.htm
WorkerPerformanceNow.html Update web-platform-tests to revision c26470dac73f2df9d4822a0d3482f7eb1ebf57d9 2018-01-16 17:18:09 +01:00

Worker WPT tests

These are the workers (Worker, SharedWorker) tests for the Web workers chapter of the HTML Standard.

See also testharness.js API > Web Workers.

Note that because workers are defined in the HTML Standard, the idlharness.js tests are in /html/dom instead of here.

Writing *.any.js

The easiest and most recommended way to write tests for workers is to create .any.js-style tests.

Official doc: WPT > File Name Flags > Test Features.

  • Standard testharness.js-style can be used (and is enforced).
  • The same test can be run on window and many types of workers.
  • All glue code are automatically generated.
  • No need to care about how to create and communicate with each type of workers, thanks to fetch_tests_from_worker in testharness.js.

Converting existing tests into .any.js-style also has benefits:

  • Multiple tests can be merged into one.
  • Tests written for window can be run on workers with a very low development cost.

How to write tests

If you write testharness.js-based tests in foo.any.js and specify types of workers to be tested, the test can run on any of dedicated, shared and service workers.

See examples/general.any.js for example.

Even for testing specific features in a specific type of workers (e.g. shared worker's onconnect), .any.js-style tests can be used.

See examples/onconnect.any.js for example.

How to debug tests

Whether each individual test passed or failed, and its assertion failures (if any) are all reported in the final results.

console.log() might not appear in the test results and thus might not be useful for printf debugging. For example, in Chromium, this message

  • Appears (in stderr) on a window or a dedicated worker, but
  • Does NOT appear on a shared worker or a service worker.

How it works

.any.js-style tests use fetch_tests_from_worker functionality of testharness.js.

The WPT test server generates necessary glue code (including generated Document HTML and worker top-level scripts). See serve.py for the actual glue code.

Note that .any.js file is not the worker top-level script, and currently we cannot set response headers to the worker top-level script, e.g. to set Referrer Policy of the workers.

Writing *.worker.js

Similar to .any.js, you can also write .worker.js for tests only for dedicated workers. Almost the same as .any.js, except for the things listed below.

Official doc: WPT > File Name Flags > Test Features.

How to write tests

You have to write two things manually (which is generated in .any.js tests):

  • importScripts("/resources/testharness.js"); at the beginning.
  • done(); at the bottom.

Note: Even if you write async_test() or promise_test(), this global done() is always needed (this is different from async_test's done()) for dedicated workers and shared workers. See official doc: testharness.js API > Determining when all tests are complete.

See examples/general.worker.js for example.

How it works

.worker.js-style tests also use fetch_tests_from_worker functionality of testharness.js.

The WPT test server generates glue code in Document HTML-side, but not for worker top-level scripts. This is why you have to manually write importScripts() etc. See serve.py for the actual glue code.

Unlike *.any.js cases, the *.worker.js is the worker top-level script.

Using fetch_tests_from_worker

If you need more flexibility, writing tests using fetch_tests_from_worker is the way to go. For example, when

  • Additional processing is needed on the parent Document.
  • Workers should be created in a specific way.
  • You are writing non-WPT tests using testharness.js.

You have to write the main HTMLs and the worker scripts, but most of the glue code needed for running tests on workers are provided by fetch_tests_from_worker.

How to write tests

See

  • examples/fetch_tests_from_worker.html and examples/fetch_tests_from_worker.js.

Writing the whole tests manually

If fetch_tests_from_worker isn't suitable for your specific case (which should be rare but might be still possible), you have to write the whole tests, including the main Document HTML, worker scripts, and message passing code between them.

TODO: Supply the templates for writing this kind of tests.