fune/testing/web-platform/tests/workers
Jon Coppeard 7f7fbc2229 Bug 1580536 - Make dynamic import a runtime error in contexts where we don't support it r=jorendorff
This removes the parse-time check for whether dynamic import hook has been set.  There's already a runtime check for this too, previously just to support enabling/disabling dynamic import via a pref.  I updated web platform tests and expectations so that use of dynamic imports in wokers is now an expected failure (previously we would time out).

Differential Revision: https://phabricator.services.mozilla.com/D45698

--HG--
extra : moz-landing-system : lando
2019-10-14 16:33:29 +00:00
..
baseurl
constructors Bug 1557736 - Fix more WPT tests for Workers with a non-JS mime. r=jgraham 2019-07-09 09:38:27 +00:00
examples Bug 1523562 [wpt PR 14829] - Add worker WPT test writing guide and examples, a=testonly 2019-02-07 21:50:37 +00:00
interfaces Bug 1557736 - Fix more WPT tests for Workers with a non-JS mime. r=jgraham 2019-07-09 09:38:27 +00:00
modules Bug 1580536 - Make dynamic import a runtime error in contexts where we don't support it r=jorendorff 2019-10-14 16:33:29 +00:00
non-automated Bug 1557736 - Mechanical fix for polyglot HTML/JS tests. r=jgraham 2019-06-13 17:14:56 +00:00
semantics Bug 1583443 [wpt PR 19242] - Use any.js for SharedWorker interface object tests., a=testonly 2019-09-26 20:26:15 +00:00
support Bug 1533592 [wpt PR 15663] - Upstream tests from fast/workers to external/wpt/workers., a=testonly 2019-04-01 14:42:48 +01:00
data-url-shared-window.html
data-url-shared.html
data-url.html
dedicated-worker-from-blob-url.window.js Bug 1581408 [wpt PR 19067] - Make some worker tests fail faster, a=testonly 2019-09-30 14:02:08 +00:00
importscripts_mime.any.js Bug 1514685 [wpt PR 14557] - Ship strict MIME checks for 'importScripts()', a=testonly 2019-01-23 10:56:47 +00:00
META.yml
name-property.html
nested_worker.worker.js
nested_worker_close_from_parent_worker.html
nested_worker_close_self.worker.js
nested_worker_importScripts.worker.js
nested_worker_sync_xhr.worker.js
nested_worker_terminate_from_document.html
opaque-origin.html
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 Bug 1576842 [wpt PR 18690] - Remove stale dedicated-workers.idl in favor of dom.idl + html.idl, a=testonly 2019-09-03 14:23:08 +00:00
shared-worker-from-blob-url.window.js Bug 1507412 [wpt PR 14066] - Worker: Separate worker-from-blob-url.window.html to filter out failing tests in a more fine-grained way, a=testonly 2018-11-23 18:36:50 +00:00
shared-worker-name-via-options.html
SharedWorker-constructor.html Bug 1526319 [wpt PR 14877] - Upstream fast/workers to external/wpt/workers: first batch., a=testonly 2019-02-14 11:38:21 +00:00
SharedWorker-detach-frame-in-error-event.html Bug 1557385 [wpt PR 16841] - Worker: Don't touch SharedWorkerClient when a connecting document may get destroyed, a=testonly 2019-06-19 11:05:31 -07:00
SharedWorker-exception-propagation.html Bug 1526319 [wpt PR 14877] - Upstream fast/workers to external/wpt/workers: first batch., a=testonly 2019-02-14 11:38:21 +00:00
SharedWorker-exception.html Bug 1526319 [wpt PR 14877] - Upstream fast/workers to external/wpt/workers: first batch., a=testonly 2019-02-14 11:38:21 +00:00
SharedWorker-MessageEvent-source.any.js Bug 1526319 [wpt PR 14877] - Upstream fast/workers to external/wpt/workers: first batch., a=testonly 2019-02-14 11:38:21 +00:00
SharedWorker-replace-EventHandler.any.js Bug 1526319 [wpt PR 14877] - Upstream fast/workers to external/wpt/workers: first batch., a=testonly 2019-02-14 11:38:21 +00:00
SharedWorker-script-error.html Bug 1526319 [wpt PR 14877] - Upstream fast/workers to external/wpt/workers: first batch., a=testonly 2019-02-14 11:38:21 +00:00
SharedWorker-simple.html Bug 1526319 [wpt PR 14877] - Upstream fast/workers to external/wpt/workers: first batch., a=testonly 2019-02-14 11:38:21 +00:00
SharedWorker_blobUrl.html
SharedWorker_dataUrl.html
SharedWorkerPerformanceNow.html
Worker-base64.any.js Bug 1526319 [wpt PR 14877] - Upstream fast/workers to external/wpt/workers: first batch., a=testonly 2019-02-14 11:38:21 +00:00
Worker-call.worker.js Bug 1526319 [wpt PR 14877] - Upstream fast/workers to external/wpt/workers: first batch., a=testonly 2019-02-14 11:38:21 +00:00
Worker-constructor-proto.any.js Bug 1526319 [wpt PR 14877] - Upstream fast/workers to external/wpt/workers: first batch., a=testonly 2019-02-14 11:38:21 +00:00
Worker-custom-event.any.js Bug 1537562 [wpt PR 15921] - Updating tests from legacy harness and upstreaming to external/wpt/workers., a=testonly 2019-04-24 11:18:30 +01:00
Worker-formdata.any.js Bug 1537562 [wpt PR 15921] - Updating tests from legacy harness and upstreaming to external/wpt/workers., a=testonly 2019-04-24 11:18:30 +01:00
Worker-location.sub.any.js Bug 1526377 [wpt PR 15164] - Fixing test to use wpt server features., a=testonly 2019-02-14 11:38:28 +00:00
Worker-messageport.html Bug 1533592 [wpt PR 15663] - Upstream tests from fast/workers to external/wpt/workers., a=testonly 2019-04-01 14:42:48 +01:00
Worker-multi-port.html Bug 1533592 [wpt PR 15663] - Upstream tests from fast/workers to external/wpt/workers., a=testonly 2019-04-01 14:42:48 +01:00
Worker-nested-importScripts-error.html Bug 1558591 [wpt PR 17272] - Prevent the error from triggering a page error in Worker-nested-importScripts-error, a=testonly 2019-07-24 13:29:27 +01:00
worker-performance.worker.js
Worker-replace-event-handler.any.js Bug 1537562 [wpt PR 15921] - Updating tests from legacy harness and upstreaming to external/wpt/workers., a=testonly 2019-04-24 11:18:30 +01:00
Worker-replace-global-constructor.any.js Bug 1526319 [wpt PR 14877] - Upstream fast/workers to external/wpt/workers: first batch., a=testonly 2019-02-14 11:38:21 +00:00
Worker-replace-self.any.js Bug 1526319 [wpt PR 14877] - Upstream fast/workers to external/wpt/workers: first batch., a=testonly 2019-02-14 11:38:21 +00:00
Worker-simultaneous-errors.html Bug 1526319 [wpt PR 14877] - Upstream fast/workers to external/wpt/workers: first batch., a=testonly 2019-02-14 11:38:21 +00:00
Worker-structure-message.html Bug 1533592 [wpt PR 15663] - Upstream tests from fast/workers to external/wpt/workers., a=testonly 2019-04-01 14:42:48 +01:00
Worker-terminate-forever.html Bug 1533592 [wpt PR 15663] - Upstream tests from fast/workers to external/wpt/workers., a=testonly 2019-04-01 14:42:48 +01:00
Worker-termination-with-port-messages.html Bug 1526319 [wpt PR 14877] - Upstream fast/workers to external/wpt/workers: first batch., a=testonly 2019-02-14 11:38:21 +00:00
Worker-timeout-cancel-order.html Bug 1533592 [wpt PR 15663] - Upstream tests from fast/workers to external/wpt/workers., a=testonly 2019-04-01 14:42:48 +01:00
Worker-timeout-decreasing-order.html Bug 1533592 [wpt PR 15663] - Upstream tests from fast/workers to external/wpt/workers., a=testonly 2019-04-01 14:42:48 +01:00
Worker-timeout-increasing-order.html Bug 1533592 [wpt PR 15663] - Upstream tests from fast/workers to external/wpt/workers., a=testonly 2019-04-01 14:42:48 +01:00
Worker_basic.htm
Worker_cross_origin_security_err.htm Bug 1532639 [wpt PR 15630] - Add <meta name=timeout content=long> to WPT in SlowTests, a=testonly 2019-04-24 11:19:30 +01: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
Worker_terminate_event_queue.htm
WorkerGlobalScope-close.html Bug 1533592 [wpt PR 15663] - Upstream tests from fast/workers to external/wpt/workers., a=testonly 2019-04-01 14:42:48 +01: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
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 Bug 1537562 [wpt PR 15921] - Updating tests from legacy harness and upstreaming to external/wpt/workers., a=testonly 2019-04-24 11:18:30 +01:00
WorkerNavigator.any.js Bug 1526319 [wpt PR 14877] - Upstream fast/workers to external/wpt/workers: first batch., a=testonly 2019-02-14 11:38:21 +00:00
WorkerNavigator_appName.htm
WorkerNavigator_appVersion.htm
WorkerNavigator_onLine.htm
WorkerNavigator_platform.htm
WorkerNavigator_userAgent.htm
WorkerPerformanceNow.html

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.