Image Loading: Remove `last_base_element_url_`

`blink::ImageLoader::last_base_element_url_` stores a snapshot of the
Document's base URL during UpdateFromElement() [1]. However, this
snapshot is not actually used to resolve the URL of the image request after the microtask checkpoint in DoUpdateFromElement(); rather,
relative URL resolution always happens with the Document's live base URL
mechanism [2] (more on this later).

Instead, the member exists solely to detect, at image insertion time
[3], if the Document's base URL has changed since the last time
UpdateFromElement() was called. The rationale for this used to be to
detect if a document's base URL changed before the image loading
microtask (DoUpdateFromElement()) was run, so that we could protect
against fetching the wrong image with a stale URL; see [4].

This was important because at the time, (before crrev.com/c/2103987)
ImageLoader used to store a snapshot of the resolved image URL in the
microtask state computed in UpdateFromElement(), so it was possible to
wind up in DoUpdateFromElement() with an image request URL that is stale
compared to the live Document's base URL (this was intentional, see
crbug.com/569760 & https://codereview.chromium.org/2105283002). The
solution [5] at the time was to detect, only during insertion, if the
ImageLoader's last known snapshot of the Document base URL is stale, so
that the image processing model can be re-entered, and the final DoUpdateFromElement() call is made with an up-to-date URL. This protects
against the very specific issue of:
  1. Creating an image (thus scheduling the microtask)
  2. Changing the Document's base URL
  3. The microtask that finally runs fetches an image with a stale URL

However, I have no idea how this could protect against the original bug
filed [4]; see
https://chromium-review.googlesource.com/c/chromium/src/+/3311225/comments/5ab9c13f_9c553169
where there is some discussion about how the original bug could have
behaved.

In any case, since then, crrev.com/c/2103987 has landed which ensures
that DoUpdateElement() always resolves relative URLs with the live
Document's base URL, so it is impossible for DoUpdateElement() to fetch
an outdated URL. This leaves us with the `last_base_element_url_` member
that is used as a discriminator to re-invoke the image processing model
upon insertion due to this member being stale compared to the Document's
base URL. This results in Chromium sometimes fetching the same exact
image twice (3-step scenario listed above), which makes this member
entirely obsolete dead weight.

Furthermore, the HTML Standard does not define general image insertion
as a "relevant mutation" [6] that would invoke #update-the-image-data,
and it certainly does not capture any base-URL-specific state in the
microtask machinery. After some discussion on
https://github.com/whatwg/html/issues/7383, we've decided to align
Chromium with the specification, which prompts this CL.

Testing-wise, this CL is covered by:
 - image-load-reset-on-new-base.html
    - Created in response to [4]
 - svg-image-load-reset-on-new-base.html
    - Same as above, but the SVG variant
 - image-base-url.html
    - Added/moved in crrev.com/c/2103987
 - TODO: Add a test that ensures only one request is made
    - This test is important because while the others ensure that the
      final image is correct, we've discovered that some browsers are
      re-fetching the image due to base URLs changing before the image
      microtask is run, and sometimes that second fetch is using the
      correct URL, and sometimes it's wrong: https://github.com/whatwg/html/issues/7383#issuecomment-1408234538

[1]:
https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/loader/image_loader.cc;l=646-647;drc=3297fb6d70a02d8c4af8db2bc9e315053744442b
[2]:
https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/loader/image_loader.cc;l=724;drc=3297fb6d70a02d8c4af8db2bc9e315053744442b
[3]:
https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/loader/image_loader.cc;l=297-302;drc=3297fb6d70a02d8c4af8db2bc9e315053744442b
[4]: https://crbug.com/897545
[5]: https://crrev.com/c/1296506
[6]: https://html.spec.whatwg.org/multipage/images.html#relevant-mutations

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