Bug 1627880 [wpt PR 22738] - Do not set integrity metadata in preload scanner for...
commitd4b148f39b8643f6f62863ffd1d4966b3a496bf7
authorHiroshige Hayashizaki <hiroshige@chromium.org>
Tue, 14 Apr 2020 11:20:54 +0000 (14 11:20 +0000)
committermoz-wptsync-bot <wptsync@mozilla.com>
Thu, 16 Apr 2020 09:58:37 +0000 (16 09:58 +0000)
tree03865268a1e0e69386df0b58528dc948fc1e53e4
parentf23789913d91d24ef15ad6389507d0c85261cde7
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
testing/web-platform/tests/preload/subresource-integrity-partial-image.html [new file with mode: 0644]