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