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

Unified Diff: third_party/WebKit/Source/core/css/StyleSheetContents.cpp

Issue 1861243002: Check the mime type of cross-origin CSS fetched via the Service Worker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add files Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/css/StyleSheetContents.cpp
diff --git a/third_party/WebKit/Source/core/css/StyleSheetContents.cpp b/third_party/WebKit/Source/core/css/StyleSheetContents.cpp
index f60e92860d25c832c1680cf3baca182b6671c050..7c7dd2e8ac3d6b2bf18652df809cffed467b5be1 100644
--- a/third_party/WebKit/Source/core/css/StyleSheetContents.cpp
+++ b/third_party/WebKit/Source/core/css/StyleSheetContents.cpp
@@ -322,6 +322,16 @@ void StyleSheetContents::parseAuthorStyleSheet(const CSSStyleSheetResource* cach
TRACE_EVENT1("blink,devtools.timeline", "ParseAuthorStyleSheet", "data", InspectorParseAuthorStyleSheetEvent::data(cachedStyleSheet));
bool isSameOriginRequest = securityOrigin && securityOrigin->canRequest(baseURL());
+
+ // When the response was fetched via the Service Worker, the original URL may not be same as the base URL.
+ // TODO(horo): When we will use the original URL as the base URL, we can remove this check. crbug.com/553535
+ if (cachedStyleSheet->response().wasFetchedViaServiceWorker()) {
+ const KURL originalURL(cachedStyleSheet->response().originalURLViaServiceWorker());
+ // |originalURL| is empty when the response is created in the SW.
+ if (!originalURL.isEmpty() && !securityOrigin->canRequest(originalURL))
+ isSameOriginRequest = false;
+ }
+
CSSStyleSheetResource::MIMETypeCheck mimeTypeCheck = isQuirksModeBehavior(m_parserContext.mode()) && isSameOriginRequest ? CSSStyleSheetResource::MIMETypeCheck::Lax : CSSStyleSheetResource::MIMETypeCheck::Strict;
String sheetText = cachedStyleSheet->sheetText(mimeTypeCheck);
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/fetch-request-css-cross-origin-mime-check-worker.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698