gecko-dev/testing/web-platform/tests/workers
Sergio Villar Senin 20e6065a94 Bug 1532639 [wpt PR 15630] - Add <meta name=timeout content=long> to WPT in SlowTests, a=testonly
Automatic update from web-platform-tests
Add <meta name=timeout content=long> to WPT in SlowTests

This is the 2nd step in the process of banning external/wpt from
SlowTests. After cleaning up the wtp entries we're marking them as
slow by using wpt idioms, i.e.:

1) Add <meta name="timeout" content="long"> to .html files
2) Add // META: timeout=long to .js files

Bug: 765026
Change-Id: Iaf051104f419524916e19324996cc36ee37d5426
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1497005
Commit-Queue: Sergio Villar <svillar@igalia.com>
Reviewed-by: Andy Paicu <andypaicu@chromium.org>
Reviewed-by: Robert Ma <robertma@chromium.org>
Cr-Commit-Position: refs/heads/master@{#643402}

--

wpt-commits: 7287608f90f6b9530635d10086fd2ab386faab38
wpt-pr: 15630
2019-04-24 11:19:30 +01:00
..
baseurl
constructors 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
examples
interfaces 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
modules
non-automated
semantics 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
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
importscripts_mime.any.js
interfaces.worker.js
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
shared-worker-from-blob-url.window.js
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-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 1533592 [wpt PR 15663] - Upstream tests from fast/workers to external/wpt/workers., a=testonly 2019-04-01 14:42:48 +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.

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.