Pass the correct sourceURLs to DevTools for constructed stylesheets

A CSSStyleSheet imported as a CSS module script has the constructed
flag set
(https://wicg.github.io/construct-stylesheets/#cssstylesheet-constructed-flag).
This is because it is useful to treat imported CSSStyleSheets the same
way as stylesheets created via `new`. For example we want to be able
to add both to document.adoptedStyleSheets, and we want both to treat
@import rules the same way.

However, we want DevTools to display them differently. Sheets
created with `new` don't have a source file to show, but imported
sheets do, so we want the latter to be shown more like "normal"
stylesheets.

To enable DevTools to tell these types of constructed stylesheets apart,
start passing an empty sourceURL to DevTools for constructed stylesheets
created by `new`. The corresponding frontend change
https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2964580
will check for an empty sourceURL to determine whether to try to link
the stylesheet to a source file or not.

Additionally, a CSSStyleSheet for a module import now stores the
URL of the module request as its base URL. This is later passed to
DevTools as the source URL of the stylesheet. This works because the
base URL and source URL for a CSS module script are always the same.

This also happens to fix a bug with resolution of relative URLs in
CSS modules. The previous behavior was to resolve these using the URL
of the importing document. The new, correct, behavior is to resolve
them using the URL of the stylesheet resource.

Bug: 1219441
Change-Id: I48de349e1f7c8e10a329bff016cef68ac9901bb6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2964539
Reviewed-by: Andrey Kosyakov <caseq@chromium.org>
Reviewed-by: Kouhei Ueno <kouhei@chromium.org>
Reviewed-by: Alex Rudenko <alexrudenko@chromium.org>
Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
Commit-Queue: Dan Clark <daniec@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#894456}
2 files changed
tree: e1e8dbaa7c1c560d8113e5aa89398dd049ebddba
  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!