css: Make fetches from inline CSS use the document's URL as referrer
Right now, fetches from inline CSS use the inline CSS's base URL instead of the URL from the context that embeds the inline CSS: for instance, loading a source-site.com page with the following code <base href="https://other-site.com"> <style type=text/css> @import('best-sheet.com') </style> should lead to the best-sheet.com sheet getting fetched with a source-site.com referrer, but it will currently provide an other-site.com referrer. However, if the imported sheet from best-sheet.com makes more nested fetches, those nested requests should use best-sheet.com as the basis for their referrers (as they do currently). This CL updates CSSParserContext's referrer setting logic to roughly do the following: - inline CSS: use the embedding document's URL as the referrer, or, for srcdoc iframes, walk up the frame tree until hitting a non-srcdoc frame - requests from fetched stylesheets: just as currently, use the fetched sheet's URL as the basis for constructing the referrer This seemed like it required refactoring CSSParserContext slightly because there are constructors that take both a Document and a base URL, and it's not obvious from the constructor signature whether the Document or the base URL should be the one that provides the referrer. To resolve this ambiguity, the refactor updates these CSSParserContext constructors to take caller-provided Referrer objects. Change-Id: If5a99d8057dff5e771e821d0e1f605566e28ff1d Fixed: 1158645, 1158010 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2592447Reviewed-by:Rune Lillesveen <futhark@chromium.org> Reviewed-by:
Matt Falkenhagen <falken@chromium.org> Commit-Queue: David Van Cleve <davidvc@chromium.org> Cr-Commit-Position: refs/heads/master@{#841509}
Showing
Please register or sign in to comment