[@container] Make UpdateStyleAndLayoutTreeForNode understand CQ

We currently have pretty serious bugs in getComputedStyle (and similar
APIs that force style), since NeedsLayoutTreeUpdateForNodeIncluding-
DisplayLocked is completely unaware of container queries: if nothing
is *style dirty* in the ancestor chain, we will early-out from
UpdateStyleAndLayoutTreeForNode, and never actually update anything.
However, for container queries, we have to also check for layout-
dirtiness, since doing that layout can affect container-query-
dependent elements.

This CL tries to formalize the concept of a "layout upgrade", which
is a name for when UpdateStyleAndLayoutTree needs to also call
UpdateStyleAndLayout due layout dependencies.

 - NeedsLayoutTreeUpdateForNodeIncludingDisplayLocked needs to return
   true whenever we *may* need to upgrade. Otherwise we'll early-out,
   and never even get the chance to upgrade. Hence, we look at the
   target node and the ancestor chain, and try to figure out if a
   layout upgrade *will* be needed. We can not know this for sure
   at this time, because the subsequent call to update style may
   (for example) remove all container-query containers, i.e.
   remove layout dependencies.
 - UpdateStyleAndLayoutTree now accepts a LayoutUpgrade object, which
   decides how or if an upgrade should take place. NodeLayoutUpgrade
   being the most interesting of these objects.
 - NodeLayoutUpgrade::ShouldUpgrade does a second traversal of the
   ancestor chain to understand if an upgrade is needed. It is not
   possible to answer this question in the first traversal
   definitively, since style (first pass) has not been updated yet
   at that time.

For forced updates which target nodes in display:none (or elements
without ComputedStyle in general), we can not tell ahead-of-time
whether or not something may require an upgrade, since the
DependsOnContainerQueries exists on ComputedStyle. Hence, for those
situations we defensively assume that we require an upgrade if we're
inside an interleaving root [1].

Pseudo-elements also needed adjustment in this CL (the change in
ElementRuleCollector). getComputedStyle will call NeedsLayoutTree-
UpdateForNodeIncludingDisplayLocked with the originating element,
so it is not enough to mark the pseudo-style with as
DependsOnContainerQueries, since we never actually observe that style
in NeedsLayoutTreeUpdateForNode(etc). Hence we mark the originating
element as well, although this will cause some over-invalidation in
some cases. (It's possible to iterate on this if needed).

[1] Interleaving root = basically a container-for-container-queries
that is not display:none.

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

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!