tree: 6ba4d99881f3ff3b4e19d3d616d1311653989892 [path history] [tgz]
  1. baseurl/
  2. constructors/
  3. examples/
  4. interfaces/
  5. modules/
  6. non-automated/
  7. semantics/
  8. support/
  9. abrupt-completion-expected.txt
  10. abrupt-completion.html
  11. data-url-expected.txt
  12. data-url-shared-expected.txt
  13. data-url-shared-window.html
  14. data-url-shared.html
  15. data-url.html
  16. dedicated-worker-from-blob-url.window-expected.txt
  17. dedicated-worker-from-blob-url.window.html
  18. dedicated-worker-from-blob-url.window.js
  19. dedicated-worker-in-data-url-context.window-expected.txt
  20. dedicated-worker-in-data-url-context.window.html
  21. dedicated-worker-in-data-url-context.window.js
  22. dedicated-worker-parse-error-failure-expected.txt
  23. dedicated-worker-parse-error-failure.html
  24. importscripts_mime.any.js
  25. importscripts_mime.any.worker-expected.txt
  26. importscripts_mime.any.worker.html
  27. META.yml
  28. name-property-expected.txt
  29. name-property.html
  30. nested_worker.worker-expected.txt
  31. nested_worker.worker.html
  32. nested_worker.worker.js
  33. nested_worker_close_from_parent_worker-expected.txt
  34. nested_worker_close_from_parent_worker.html
  35. nested_worker_close_self.worker-expected.txt
  36. nested_worker_close_self.worker.html
  37. nested_worker_close_self.worker.js
  38. nested_worker_importScripts.worker-expected.txt
  39. nested_worker_importScripts.worker.html
  40. nested_worker_importScripts.worker.js
  41. nested_worker_sync_xhr.worker-expected.txt
  42. nested_worker_sync_xhr.worker.html
  43. nested_worker_sync_xhr.worker.js
  44. nested_worker_terminate_from_document-expected.txt
  45. nested_worker_terminate_from_document.html
  46. opaque-origin-expected.txt
  47. opaque-origin.html
  48. postMessage_block.https-expected.txt
  49. postMessage_block.https.html
  50. postMessage_block.https.html.headers
  51. postMessage_clone_port-expected.txt
  52. postMessage_clone_port.htm
  53. postMessage_clone_port_error-expected.txt
  54. postMessage_clone_port_error.htm
  55. postMessage_DataCloneErr-expected.txt
  56. postMessage_DataCloneErr.htm
  57. postMessage_event_properties-expected.txt
  58. postMessage_event_properties.htm
  59. postMessage_ports_readonly_array-expected.txt
  60. postMessage_ports_readonly_array.htm
  61. postMessage_target_source-expected.txt
  62. postMessage_target_source.htm
  63. README.md
  64. shared-worker-from-blob-url.window-expected.txt
  65. shared-worker-from-blob-url.window.html
  66. shared-worker-from-blob-url.window.js
  67. shared-worker-in-data-url-context.window-expected.txt
  68. shared-worker-in-data-url-context.window.html
  69. shared-worker-in-data-url-context.window.js
  70. shared-worker-name-via-options-expected.txt
  71. shared-worker-name-via-options.html
  72. shared-worker-options-mismatch-expected.txt
  73. shared-worker-options-mismatch.html
  74. shared-worker-parse-error-failure-expected.txt
  75. shared-worker-parse-error-failure.html
  76. SharedWorker-constructor-expected.txt
  77. SharedWorker-constructor.html
  78. SharedWorker-detach-frame-in-error-event-expected.txt
  79. SharedWorker-detach-frame-in-error-event.html
  80. SharedWorker-exception-expected.txt
  81. SharedWorker-exception-propagation-expected.txt
  82. SharedWorker-exception-propagation.html
  83. SharedWorker-exception.html
  84. SharedWorker-MessageEvent-source.any-expected.txt
  85. SharedWorker-MessageEvent-source.any.html
  86. SharedWorker-MessageEvent-source.any.js
  87. SharedWorker-MessageEvent-source.any.worker-expected.txt
  88. SharedWorker-MessageEvent-source.any.worker.html
  89. SharedWorker-replace-EventHandler.any-expected.txt
  90. SharedWorker-replace-EventHandler.any.html
  91. SharedWorker-replace-EventHandler.any.js
  92. SharedWorker-replace-EventHandler.any.worker-expected.txt
  93. SharedWorker-replace-EventHandler.any.worker.html
  94. SharedWorker-script-error-expected.txt
  95. SharedWorker-script-error.html
  96. SharedWorker-simple-expected.txt
  97. SharedWorker-simple.html
  98. SharedWorker_blobUrl-expected.txt
  99. SharedWorker_blobUrl.html
  100. SharedWorker_dataUrl-expected.txt
  101. SharedWorker_dataUrl.html
  102. SharedWorkerPerformanceNow-expected.txt
  103. SharedWorkerPerformanceNow.html
  104. w3c-import.log
  105. Worker-base64.any.js
  106. Worker-base64.any.worker-expected.txt
  107. Worker-base64.any.worker.html
  108. Worker-call.worker-expected.txt
  109. Worker-call.worker.html
  110. Worker-call.worker.js
  111. Worker-constructor-proto.any.js
  112. Worker-constructor-proto.any.worker-expected.txt
  113. Worker-constructor-proto.any.worker.html
  114. Worker-custom-event.any.js
  115. Worker-custom-event.any.worker-expected.txt
  116. Worker-custom-event.any.worker.html
  117. Worker-formdata.any.js
  118. Worker-formdata.any.worker-expected.txt
  119. Worker-formdata.any.worker.html
  120. Worker-location.sub.any.js
  121. Worker-location.sub.any.worker-expected.txt
  122. Worker-location.sub.any.worker.html
  123. Worker-messageport-expected.txt
  124. Worker-messageport.html
  125. Worker-multi-port-expected.txt
  126. Worker-multi-port.html
  127. Worker-nested-importScripts-error-expected.txt
  128. Worker-nested-importScripts-error.html
  129. worker-performance.worker-expected.txt
  130. worker-performance.worker.html
  131. worker-performance.worker.js
  132. Worker-replace-event-handler.any.js
  133. Worker-replace-event-handler.any.worker-expected.txt
  134. Worker-replace-event-handler.any.worker.html
  135. Worker-replace-global-constructor.any.js
  136. Worker-replace-global-constructor.any.worker-expected.txt
  137. Worker-replace-global-constructor.any.worker.html
  138. Worker-replace-self.any.js
  139. Worker-replace-self.any.worker-expected.txt
  140. Worker-replace-self.any.worker.html
  141. Worker-simultaneous-errors-expected.txt
  142. Worker-simultaneous-errors.html
  143. Worker-structure-message-expected.txt
  144. Worker-structure-message.html
  145. Worker-terminate-forever-expected.txt
  146. Worker-terminate-forever.html
  147. Worker-termination-with-port-messages-expected.txt
  148. Worker-termination-with-port-messages.html
  149. Worker-timeout-cancel-order-expected.txt
  150. Worker-timeout-cancel-order.html
  151. Worker-timeout-decreasing-order-expected.txt
  152. Worker-timeout-decreasing-order.html
  153. Worker-timeout-increasing-order-expected.txt
  154. Worker-timeout-increasing-order.html
  155. Worker_basic-expected.txt
  156. Worker_basic.htm
  157. Worker_cross_origin_security_err-expected.txt
  158. Worker_cross_origin_security_err.htm
  159. Worker_dispatchEvent_ErrorEvent-expected.txt
  160. Worker_dispatchEvent_ErrorEvent.htm
  161. Worker_ErrorEvent_bubbles_cancelable-expected.txt
  162. Worker_ErrorEvent_bubbles_cancelable.htm
  163. Worker_ErrorEvent_error-expected.txt
  164. Worker_ErrorEvent_error.htm
  165. Worker_ErrorEvent_filename-expected.txt
  166. Worker_ErrorEvent_filename.htm
  167. Worker_ErrorEvent_lineno-expected.txt
  168. Worker_ErrorEvent_lineno.htm
  169. Worker_ErrorEvent_message-expected.txt
  170. Worker_ErrorEvent_message.htm
  171. Worker_ErrorEvent_type-expected.txt
  172. Worker_ErrorEvent_type.htm
  173. Worker_NosniffErr-expected.txt
  174. Worker_NosniffErr.htm
  175. Worker_script_mimetype-expected.txt
  176. Worker_script_mimetype.htm
  177. Worker_terminate_event_queue-expected.txt
  178. Worker_terminate_event_queue.htm
  179. WorkerGlobalScope-close-expected.txt
  180. WorkerGlobalScope-close.html
  181. WorkerGlobalScope_ErrorEvent_colno-expected.txt
  182. WorkerGlobalScope_ErrorEvent_colno.htm
  183. WorkerGlobalScope_ErrorEvent_filename-expected.txt
  184. WorkerGlobalScope_ErrorEvent_filename.htm
  185. WorkerGlobalScope_ErrorEvent_lineno-expected.txt
  186. WorkerGlobalScope_ErrorEvent_lineno.htm
  187. WorkerGlobalScope_ErrorEvent_message-expected.txt
  188. WorkerGlobalScope_ErrorEvent_message.htm
  189. WorkerGlobalScope_importScripts-expected.txt
  190. WorkerGlobalScope_importScripts.htm
  191. WorkerGlobalScope_importScripts_NetworkErr-expected.txt
  192. WorkerGlobalScope_importScripts_NetworkErr.htm
  193. WorkerGlobalScope_importScripts_NosniffErr-expected.txt
  194. WorkerGlobalScope_importScripts_NosniffErr.htm
  195. WorkerGlobalScope_requestAnimationFrame.tentative.worker-expected.txt
  196. WorkerGlobalScope_requestAnimationFrame.tentative.worker.html
  197. WorkerGlobalScope_requestAnimationFrame.tentative.worker.js
  198. WorkerGlobalScope_setInterval-expected.txt
  199. WorkerGlobalScope_setInterval.htm
  200. WorkerGlobalScope_setTimeout-expected.txt
  201. WorkerGlobalScope_setTimeout.htm
  202. WorkerLocation-expected.txt
  203. WorkerLocation-origin.sub.window-expected.txt
  204. WorkerLocation-origin.sub.window.html
  205. WorkerLocation-origin.sub.window.js
  206. WorkerLocation.htm
  207. WorkerLocation_hash-expected.txt
  208. WorkerLocation_hash.htm
  209. WorkerLocation_hash_encoding-expected.txt
  210. WorkerLocation_hash_encoding.htm
  211. WorkerLocation_hash_nonexist-expected.txt
  212. WorkerLocation_hash_nonexist.htm
  213. WorkerLocation_host-expected.txt
  214. WorkerLocation_host.htm
  215. WorkerLocation_hostname-expected.txt
  216. WorkerLocation_hostname.htm
  217. WorkerLocation_href-expected.txt
  218. WorkerLocation_href.htm
  219. WorkerLocation_pathname-expected.txt
  220. WorkerLocation_pathname.htm
  221. WorkerLocation_port-expected.txt
  222. WorkerLocation_port.htm
  223. WorkerLocation_protocol-expected.txt
  224. WorkerLocation_protocol.htm
  225. WorkerLocation_search-expected.txt
  226. WorkerLocation_search.htm
  227. WorkerLocation_search_empty-expected.txt
  228. WorkerLocation_search_empty.htm
  229. WorkerLocation_search_fragment-expected.txt
  230. WorkerLocation_search_fragment.htm
  231. WorkerLocation_search_nonexist-expected.txt
  232. WorkerLocation_search_nonexist.htm
  233. WorkerNavigator-hardware-concurrency.any.js
  234. WorkerNavigator-hardware-concurrency.any.worker-expected.txt
  235. WorkerNavigator-hardware-concurrency.any.worker.html
  236. WorkerNavigator.any.js
  237. WorkerNavigator.any.worker-expected.txt
  238. WorkerNavigator.any.worker.html
  239. WorkerNavigator_appName-expected.txt
  240. WorkerNavigator_appName.htm
  241. WorkerNavigator_appVersion-expected.txt
  242. WorkerNavigator_appVersion.htm
  243. WorkerNavigator_onLine-expected.txt
  244. WorkerNavigator_onLine.htm
  245. WorkerNavigator_platform-expected.txt
  246. WorkerNavigator_platform.htm
  247. WorkerNavigator_userAgent-expected.txt
  248. WorkerNavigator_userAgent.htm
  249. WorkerNavigator_userAgentData.http-expected.txt
  250. WorkerNavigator_userAgentData.http.html
  251. WorkerNavigator_userAgentData.https-expected.txt
  252. WorkerNavigator_userAgentData.https.html
  253. WorkerPerformanceNow-expected.txt
  254. WorkerPerformanceNow.html
LayoutTests/imported/w3c/web-platform-tests/workers/README.md

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.