Bug
1627880 [wpt PR 22738] - Do not set integrity metadata in preload scanner for <link rel=preload as=image>, a=testonly
Automatic update from web-platform-tests
Do not set integrity metadata in preload scanner for <link rel=preload as=image>
ImageResource in Blink does not support SRI, but preload scanner
assigns integrity metadata for `<link rel="preload">` for
all `as` values, not only `stylesheet` and `script`.
This triggered a CHECK failure in a scenario like
subresource-integrity-partial-image.html WPT:
1. An image load is started, with integrity metadata is set.
2. The partial image is rendered, and decoded size is set.
3. The image is fully loaded. Resource::Finish() is called
and SRI check is executed, which triggers CHECK failure.
The root cause is that SRI code (and the CHECK condition)
doesn't support images, and thus SRI code + images will
anyway fail, not necessarily in this particular scenario/CHECK.
This is a regression since
https://chromium-review.googlesource.com/c/chromium/src/+/
1679140
removed a guard condition from
third_party/blink/renderer/core/html/parser/html_preload_scanner.cc
that prevented preload scanner from setting integrity metadata
for non-`as="stylesheet"` `<link rel="preload">`.
This CL prevents SRI in images, by resurrected the guard condition,
plus allowing `<link rel="preload" as="script">`,
and aligning with a corresponding check in
third_party/blink/renderer/core/loader/preload_helper.cc.
This CL adds a WPT test to confirm the crash no longer occurs.
Bug:
1058045
Change-Id: I73b3224c9beef28308fa4c47e8e91b09b3840688
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/
2138994
Reviewed-by: Dominic Farolino <dom@chromium.org>
Reviewed-by: Yoav Weiss <yoavweiss@chromium.org>
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758488}
--
wpt-commits:
8b5ad57ed745f17deaca83ed8c72ba109146b2a9
wpt-pr: 22738