Supports all ':has' relative argument cases

Currently the relative selector is not supported yet, so this CL
provides the relative argument cases as follows.
 - :has(:scope > <complex-selector>)
 - :has(:scope ~ <complex-selector>)
 - :has(:scope + <complex-selector>)

This CL provides a wpt test for the above usage.
 - has-relative-argument.html

While matching those argument selectors on the :has argument subtree
of an element, we can get the candidate scope elements. By marking
those elements as matched, we can reduce the duplicated ':has'
argument matching operation.

HasArgumentSubtreeIterator provides the way to traverse the ':has'
argument subtree (downward subtree of the :has scope element). The
iterator provides right-to-left post-order traversal to prevent
incorrect 'NotMatched' status. And it also provides a way to limit
traversal depth or adjacent distance to prevent unnecessary tree
traversal for direct relations (child/direct sibling).

About the issue of incorrect 'NotMatched' status, the previous caching
logic has a bug of incorrectly using the cached status to skip one
argument selector matching operation for one descendant of an element.
The cached status should be used to skip the argument matching
operations for all the descendants of an element because it is the
status of :has scope element.

To store the 'NotMatched' status correctly during the ':has' subtree
traversal for argument selector matching , the traversal order should
be right-to-left reversed post-order to guarantee that, the downward
subtree(descendants/next siblings/descendants of next siblings) of
an element was checked with the argument selector before checking the
element and the previous check didn't mark the element as 'Matched'.

The ':has(.descendant)' test case in the 'has-basic.html' missed to
have an expected return value related with this bug, so the test
result is fixed with this CL.

And to check the added/fixed logic, following test are added.
 - has-relative-argument.html

Change-Id: I71f8752ad90d32c6f9ee6bf87949b838e3843eba
Bug: 669058
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2914967
Commit-Queue: Byungwoo Lee <blee@igalia.com>
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#894067}
3 files changed
tree: 51de7220db8ec53509e0219b9014a53662b6e45f
  1. .github/
  2. .well-known/
  3. accelerometer/
  4. accessibility/
  5. accname/
  6. acid/
  7. ambient-light/
  8. animation-worklet/
  9. annotation-model/
  10. annotation-protocol/
  11. annotation-vocab/
  12. apng/
  13. appmanifest/
  14. audio-output/
  15. background-fetch/
  16. BackgroundSync/
  17. badging/
  18. battery-status/
  19. beacon/
  20. bluetooth/
  21. clear-site-data/
  22. client-hints/
  23. clipboard-apis/
  24. common/
  25. compat/
  26. compression/
  27. compute-pressure/
  28. conformance-checkers/
  29. console/
  30. contacts/
  31. content-dpr/
  32. content-index/
  33. content-security-policy/
  34. contenteditable/
  35. cookie-store/
  36. cookies/
  37. core-aam/
  38. cors/
  39. credential-management/
  40. css/
  41. custom-elements/
  42. custom-state-pseudo-class/
  43. delegated-ink/
  44. density-size-correction/
  45. deprecation-reporting/
  46. device-memory/
  47. docs/
  48. document-policy/
  49. dom/
  50. domparsing/
  51. domxpath/
  52. dpub-aam/
  53. dpub-aria/
  54. editing/
  55. element-timing/
  56. encoding/
  57. encoding-detection/
  58. encrypted-media/
  59. entries-api/
  60. event-timing/
  61. eventsource/
  62. feature-policy/
  63. fetch/
  64. file-system-access/
  65. FileAPI/
  66. focus/
  67. font-access/
  68. fonts/
  69. forced-colors-mode/
  70. fullscreen/
  71. gamepad/
  72. generic-sensor/
  73. geolocation-API/
  74. geolocation-sensor/
  75. graphics-aam/
  76. gyroscope/
  77. hr-time/
  78. html/
  79. html-longdesc/
  80. html-media-capture/
  81. idle-detection/
  82. imagebitmap-renderingcontext/
  83. images/
  84. import-maps/
  85. IndexedDB/
  86. inert/
  87. infrastructure/
  88. input-device-capabilities/
  89. input-events/
  90. installedapp/
  91. interfaces/
  92. intersection-observer/
  93. intervention-reporting/
  94. is-input-pending/
  95. js/
  96. js-self-profiling/
  97. keyboard-lock/
  98. keyboard-map/
  99. largest-contentful-paint/
  100. layout-instability/
  101. lifecycle/
  102. loading/
  103. longtask-timing/
  104. magnetometer/
  105. managed/
  106. mathml/
  107. measure-memory/
  108. media/
  109. media-capabilities/
  110. media-playback-quality/
  111. media-source/
  112. mediacapture-depth/
  113. mediacapture-fromelement/
  114. mediacapture-image/
  115. mediacapture-insertable-streams/
  116. mediacapture-record/
  117. mediacapture-streams/
  118. mediasession/
  119. merchant-validation/
  120. mimesniff/
  121. mixed-content/
  122. mst-content-hint/
  123. native-io/
  124. navigation-timing/
  125. netinfo/
  126. network-error-logging/
  127. notifications/
  128. old-tests/
  129. orientation-event/
  130. orientation-sensor/
  131. origin-policy/
  132. page-lifecycle/
  133. page-visibility/
  134. paint-timing/
  135. payment-handler/
  136. payment-method-basic-card/
  137. payment-method-id/
  138. payment-request/
  139. performance-timeline/
  140. periodic-background-sync/
  141. permissions/
  142. permissions-policy/
  143. permissions-request/
  144. permissions-revoke/
  145. picture-in-picture/
  146. pointerevents/
  147. pointerlock/
  148. portals/
  149. preload/
  150. presentation-api/
  151. priority-hints/
  152. private-click-measurement/
  153. proximity/
  154. push-api/
  155. quirks/
  156. raw-sockets/
  157. referrer-policy/
  158. remote-playback/
  159. reporting/
  160. requestidlecallback/
  161. resize-observer/
  162. resource-timing/
  163. resources/
  164. sanitizer-api/
  165. savedata/
  166. screen-capture/
  167. screen-orientation/
  168. screen-wake-lock/
  169. screen_enumeration/
  170. scroll-animations/
  171. scroll-to-text-fragment/
  172. secure-contexts/
  173. secure-payment-confirmation/
  174. selection/
  175. serial/
  176. server-timing/
  177. service-workers/
  178. shadow-dom/
  179. shape-detection/
  180. signed-exchange/
  181. speech-api/
  182. storage/
  183. storage-access-api/
  184. streams/
  185. subresource-integrity/
  186. svg/
  187. svg-aam/
  188. timing-entrytypes-registry/
  189. tools/
  190. touch-events/
  191. trust-tokens/
  192. trusted-types/
  193. ua-client-hints/
  194. uievents/
  195. upgrade-insecure-requests/
  196. url/
  197. urlpattern/
  198. user-timing/
  199. vibration/
  200. video-rvfc/
  201. visual-viewport/
  202. wai-aria/
  203. wasm/
  204. web-animations/
  205. web-bundle/
  206. web-locks/
  207. web-nfc/
  208. web-otp/
  209. web-share/
  210. webaudio/
  211. webauthn/
  212. webcodecs/
  213. WebCryptoAPI/
  214. webdriver/
  215. webgl/
  216. webgpu/
  217. webhid/
  218. WebIDL/
  219. webmessaging/
  220. webmidi/
  221. webrtc/
  222. webrtc-encoded-transform/
  223. webrtc-extensions/
  224. webrtc-ice/
  225. webrtc-identity/
  226. webrtc-priority/
  227. webrtc-stats/
  228. webrtc-svc/
  229. websockets/
  230. webstorage/
  231. webtransport/
  232. webusb/
  233. webvr/
  234. webvtt/
  235. webxr/
  236. window-segments/
  237. workers/
  238. worklets/
  239. x-frame-options/
  240. xhr/
  241. xslt/
  242. .azure-pipelines.yml
  243. .gitattributes
  244. .gitignore
  245. .mailmap
  246. .taskcluster.yml
  247. CODE_OF_CONDUCT.md
  248. CODEOWNERS
  249. CONTRIBUTING.md
  250. LICENSE.md
  251. lint.ignore
  252. README.md
  253. testharness_runner.html
  254. update-built-tests.sh
  255. wpt
  256. wpt.py
README.md

The web-platform-tests Project

Taskcluster CI Status documentation manifest Python 3

The web-platform-tests Project is a cross-browser test suite for the Web-platform stack. Writing tests in a way that allows them to be run in all browsers gives browser projects confidence that they are shipping software that is compatible with other implementations, and that later implementations will be compatible with their implementations. This in turn gives Web authors/developers confidence that they can actually rely on the Web platform to deliver on the promise of working across browsers and devices without needing extra layers of abstraction to paper over the gaps left by specification editors and implementors.

The most important sources of information and activity are:

  • github.com/web-platform-tests/wpt: the canonical location of the project's source code revision history and the discussion forum for changes to the code
  • web-platform-tests.org: the documentation website; details how to set up the project, how to write tests, how to give and receive peer review, how to serve as an administrator, and more
  • wpt.live: a public deployment of the test suite, allowing anyone to run the tests by visiting from an Internet-enabled browser of their choice
  • wpt.fyi: an archive of test results collected from an array of web browsers on a regular basis
  • Real-time chat room: the IRC chat room named #testing on irc.w3.org; includes participants located around the world, but busiest during the European working day; all discussion is archived here
  • Mailing list: a public and low-traffic discussion list
  • RFCs: a repo for requesting comments on substantial changes that would impact other stakeholders or users; people who work on WPT infra are encouraged to watch the repo.

If you'd like clarification about anything, don't hesitate to ask in the chat room or on the mailing list.

Setting Up the Repo

Clone or otherwise get https://github.com/web-platform-tests/wpt.

Note: because of the frequent creation and deletion of branches in this repo, it is recommended to “prune” stale branches when fetching updates, i.e. use git pull --prune (or git fetch -p && git merge).

Running the Tests

See the documentation website and in particular the system setup for running tests locally.

Command Line Tools

The wpt command provides a frontend to a variety of tools for working with and running web-platform-tests. Some of the most useful commands are:

  • wpt serve - For starting the wpt http server
  • wpt run - For running tests in a browser
  • wpt lint - For running the lint against all tests
  • wpt manifest - For updating or generating a MANIFEST.json test manifest
  • wpt install - For installing the latest release of a browser or webdriver server on the local machine.
  • wpt serve-wave - For starting the wpt http server and the WAVE test runner. For more details on how to use the WAVE test runner see the documentation.

Windows Notes

On Windows wpt commands must be prefixed with python or the path to the python binary (if python is not in your %PATH%).

python wpt [command]

Alternatively, you may also use Bash on Ubuntu on Windows in the Windows 10 Anniversary Update build, then access your windows partition from there to launch wpt commands.

Please make sure git and your text editor do not automatically convert line endings, as it will cause lint errors. For git, please set git config core.autocrlf false in your working tree.

Publication

The master branch is automatically synced to wpt.live and w3c-test.org.

Pull requests are automatically mirrored except those that modify sensitive resources (such as .py). The latter require someone with merge access to comment with “LGTM” or “w3c-test:mirror” to indicate the pull request has been checked.

Contributing

Save the Web, Write Some Tests!

Absolutely everyone is welcome to contribute to test development. No test is too small or too simple, especially if it corresponds to something for which you've noted an interoperability bug in a browser.

The way to contribute is just as usual:

  • Fork this repository (and make sure you're still relatively in sync with it if you forked a while ago).
  • Create a branch for your changes: git checkout -b topic.
  • Make your changes.
  • Run ./wpt lint as described above.
  • Commit locally and push that to your repo.
  • Create a pull request based on the above.

Issues with web-platform-tests

If you spot an issue with a test and are not comfortable providing a pull request per above to fix it, please file a new issue. Thank you!