Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(587)

Issue 1561903002: Fix double resource request for script resources with integrity attr. (Closed)

Created:
4 years, 11 months ago by jww
Modified:
4 years, 11 months ago
Reviewers:
Yoav Weiss, sof
CC:
chromium-reviews, caseq+blink_chromium.org, Nate Chapin, kinuko+watch, blink-reviews-dom_chromium.org, sof, eae+blinkwatch, tyoshino+watch_chromium.org, lushnikov+blink_chromium.org, pfeldman+blink_chromium.org, dglazkov+blink, apavlov+blink_chromium.org, gavinp+loader_chromium.org, devtools-reviews_chromium.org, blink-reviews, loading-reviews+fetch_chromium.org, sergeyv+blink_chromium.org, rwlbuis, blink-reviews-html_chromium.org, kozyatinskiy+blink_chromium.org, Mike West
Base URL:
https://chromium.googlesource.com/chromium/src@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Fix double resource request for script resources with integrity attr. Script tags with an integrity attribute were making two network requests for the same resource for each tag. This would only happen if the script tag appeared in the HTML of the page, but not if it was added programmatically. This was because the preloader was requesting the resource, but not checking the integrity attribute, and when the actual request came around, it had to re-request the resource because of the integrity metadata (see https://chromium.googlesource.com/chromium/src/+/175dcb80d2d369bd7ce55b46d72971395c21a932 for a description of why this re-request for scripts is needed if there is no integrity metadata on the first request). Thus the solution to this is to check the integrity metadata in the preloader. This adds a check in the preloader where, if the resource is a script, it checks the integrity attribute and adds the appropriate integrity metadata. When the script is requested for real later, the returned resource now has the integrity metadata and no re-request is needed. BUG=573269 Committed: https://crrev.com/271be402092404bd04b2881ec7301a8fe0c58964 Cr-Commit-Position: refs/heads/master@{#367888}

Patch Set 1 #

Total comments: 10

Messages

Total messages: 24 (8 generated)
jww
sigbjorn@, would you mind taking a look at this? Thanks!
4 years, 11 months ago (2016-01-06 01:20:58 UTC) #2
tyoshino (SeeGerritForStatus)
On 2016/01/06 01:20:58, jww wrote: > sigbjorn@, would you mind taking a look at this? ...
4 years, 11 months ago (2016-01-06 04:53:14 UTC) #3
tyoshino (SeeGerritForStatus)
On 2016/01/06 04:53:14, tyoshino wrote: > On 2016/01/06 01:20:58, jww wrote: > > sigbjorn@, would ...
4 years, 11 months ago (2016-01-06 04:55:03 UTC) #6
sof
lgtm, quickly diagnosed and addressed. (It's not the first time the preloader has given us ...
4 years, 11 months ago (2016-01-06 07:38:13 UTC) #8
Yoav Weiss
LGTM as well. Is this a problem only with scripts? Is SRI enabled for other ...
4 years, 11 months ago (2016-01-06 07:48:28 UTC) #9
Yoav Weiss
https://codereview.chromium.org/1561903002/diff/1/third_party/WebKit/LayoutTests/http/tests/inspector/network/subresource-integrity-number-of-requests.html File third_party/WebKit/LayoutTests/http/tests/inspector/network/subresource-integrity-number-of-requests.html (right): https://codereview.chromium.org/1561903002/diff/1/third_party/WebKit/LayoutTests/http/tests/inspector/network/subresource-integrity-number-of-requests.html#newcode5 third_party/WebKit/LayoutTests/http/tests/inspector/network/subresource-integrity-number-of-requests.html:5: <script src="../network-test.js"></script> Interesting! Didn't know about network-test. When testing ...
4 years, 11 months ago (2016-01-06 07:48:43 UTC) #11
jww
On 2016/01/06 07:48:28, Yoav Weiss wrote: > LGTM as well. > > Is this a ...
4 years, 11 months ago (2016-01-06 18:37:41 UTC) #12
jww
https://codereview.chromium.org/1561903002/diff/1/third_party/WebKit/LayoutTests/http/tests/inspector/network/subresource-integrity-number-of-requests.html File third_party/WebKit/LayoutTests/http/tests/inspector/network/subresource-integrity-number-of-requests.html (right): https://codereview.chromium.org/1561903002/diff/1/third_party/WebKit/LayoutTests/http/tests/inspector/network/subresource-integrity-number-of-requests.html#newcode5 third_party/WebKit/LayoutTests/http/tests/inspector/network/subresource-integrity-number-of-requests.html:5: <script src="../network-test.js"></script> On 2016/01/06 07:48:43, Yoav Weiss wrote: > ...
4 years, 11 months ago (2016-01-06 18:37:53 UTC) #13
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1561903002/1 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1561903002/1
4 years, 11 months ago (2016-01-06 18:38:46 UTC) #15
commit-bot: I haz the power
Committed patchset #1 (id:1)
4 years, 11 months ago (2016-01-06 20:16:30 UTC) #17
commit-bot: I haz the power
Patchset 1 (id:??) landed as https://crrev.com/271be402092404bd04b2881ec7301a8fe0c58964 Cr-Commit-Position: refs/heads/master@{#367888}
4 years, 11 months ago (2016-01-06 20:17:44 UTC) #19
Yoav Weiss
On 2016/01/06 18:37:41, jww wrote: > On 2016/01/06 07:48:28, Yoav Weiss wrote: > > LGTM ...
4 years, 11 months ago (2016-01-06 20:22:10 UTC) #20
Yoav Weiss
On 2016/01/06 18:37:53, jww wrote: > https://codereview.chromium.org/1561903002/diff/1/third_party/WebKit/LayoutTests/http/tests/inspector/network/subresource-integrity-number-of-requests.html > File > third_party/WebKit/LayoutTests/http/tests/inspector/network/subresource-integrity-number-of-requests.html > (right): > > ...
4 years, 11 months ago (2016-01-06 20:25:23 UTC) #21
Yoav Weiss
On 2016/01/06 20:22:10, Yoav Weiss wrote: > On 2016/01/06 18:37:41, jww wrote: > > On ...
4 years, 11 months ago (2016-01-06 20:26:34 UTC) #22
jww
On 2016/01/06 20:26:34, Yoav Weiss wrote: > On 2016/01/06 20:22:10, Yoav Weiss wrote: > > ...
4 years, 11 months ago (2016-01-06 21:10:19 UTC) #23
jww
4 years, 11 months ago (2016-01-06 21:12:46 UTC) #24
Message was sent while issue was closed.
On 2016/01/06 21:10:19, jww wrote:
> On 2016/01/06 20:26:34, Yoav Weiss wrote:
> > On 2016/01/06 20:22:10, Yoav Weiss wrote:
> > > On 2016/01/06 18:37:41, jww wrote:
> > > > On 2016/01/06 07:48:28, Yoav Weiss wrote:
> > > > > LGTM as well.
> > > > > 
> > > > > Is this a problem only with scripts? Is SRI enabled for other resource
> > > types?
> > > > > (e.g. stylesheets)
> > > > 
> > > > Yes, this is only a problem for scripts. While stylesheet resources also
> > have
> > > > SRI enabled, they do not suffer from this re-request issue because they
> > store
> > > > the raw resource around always. I've added a comment in
> > HTMLPreloadScanner.cpp
> > > > to hopefully explain this.
> > > 
> > > Maybe also add a comment to the parts in stylesheet that make sure that it
> > > doesn't double download.
> > > The scenario that scares me in that respect is that someone will modify
the
> > code
> > > there and will cause double downloads, which take us time to figure out...
> > 
> > Or even better yet, maybe add a similar test for stylesheets, to make sure
> they
> > don't start double downloading in the future.
> 
> I messed up with this commit and failed to actually upload all of the changes
I
> said "done" to above :-P I'm opening a new CL () to commit those changes. To
> respond to Yoav's latest comments:
> - The default scenario is not to re-request. The only way to cause a double
> request is to override Resource::mustRefetchDueToIntegrityMismatch(), so I'll
> put a comment above that specifying that it should be left as-is for
everything
> other than scripts.
> - I don't think we should add this test to the WPT suite. This is a very
> implementation specific issue, I don't think it's something the Web platform
> should be verifying (that is, this is only a quirk because of how we implement
> Strings, and even more specifically, the fact that V8 needs us to keep the
> decoded string around, and not the raw data).
> - I'll add another test for stylesheets as well, as per your suggestion.

And here's the other CL: https://codereview.chromium.org/1569623002

Powered by Google App Engine
This is Rietveld 408576698