Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (255692 => 255693)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2020-02-04 21:39:46 UTC (rev 255692)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2020-02-04 21:42:07 UTC (rev 255693)
@@ -1,3 +1,18 @@
+2020-02-04 Rob Buis <[email protected]>
+
+ Tighten up stylesheet loading
+ https://bugs.webkit.org/show_bug.cgi?id=189913
+
+ Reviewed by Antti Koivisto.
+
+ Update improved test results.
+
+ * web-platform-tests/html/semantics/document-metadata/the-link-element/link-load-error-events-expected.txt:
+ * web-platform-tests/html/semantics/document-metadata/the-link-element/link-load-error-events.https-expected.txt:
+ * web-platform-tests/html/semantics/document-metadata/the-link-element/link-style-error-01-expected.txt:
+ * web-platform-tests/html/semantics/document-metadata/the-link-element/link-style-error-limited-quirks-expected.txt:
+ * web-platform-tests/html/semantics/document-metadata/the-link-element/link-style-error-quirks-expected.txt:
+
2020-02-04 youenn fablet <[email protected]>
MediaDevices should handle changes of iframe allow attribute value
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-link-element/link-load-error-events-expected.txt (255692 => 255693)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-link-element/link-load-error-events-expected.txt 2020-02-04 21:39:46 UTC (rev 255692)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-link-element/link-load-error-events-expected.txt 2020-02-04 21:42:07 UTC (rev 255693)
@@ -5,7 +5,7 @@
PASS Import of nonexistent stylesheet
PASS Import of import of stylesheet
FAIL Import of import of nonexistent stylesheet assert_unreached: load fired when error expected Reached unreachable code
-FAIL Load of non-CSS stylesheet assert_unreached: load fired when error expected Reached unreachable code
+PASS Load of non-CSS stylesheet
FAIL Import of non-CSS stylesheet assert_unreached: load fired when error expected Reached unreachable code
FAIL Import of import of non-CSS stylesheet assert_unreached: load fired when error expected Reached unreachable code
PASS Load of http:// stylesheet
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-link-element/link-load-error-events.https-expected.txt (255692 => 255693)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-link-element/link-load-error-events.https-expected.txt 2020-02-04 21:39:46 UTC (rev 255692)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-link-element/link-load-error-events.https-expected.txt 2020-02-04 21:42:07 UTC (rev 255693)
@@ -5,7 +5,7 @@
PASS Import of nonexistent stylesheet
PASS Import of import of stylesheet
FAIL Import of import of nonexistent stylesheet assert_unreached: load fired when error expected Reached unreachable code
-FAIL Load of non-CSS stylesheet assert_unreached: load fired when error expected Reached unreachable code
+PASS Load of non-CSS stylesheet
FAIL Import of non-CSS stylesheet assert_unreached: load fired when error expected Reached unreachable code
FAIL Import of import of non-CSS stylesheet assert_unreached: load fired when error expected Reached unreachable code
PASS Load of http:// stylesheet
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-link-element/link-style-error-01-expected.txt (255692 => 255693)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-link-element/link-style-error-01-expected.txt 2020-02-04 21:39:46 UTC (rev 255692)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-link-element/link-style-error-01-expected.txt 2020-02-04 21:42:07 UTC (rev 255693)
@@ -3,13 +3,13 @@
PASS Should get an error event for an unsupported URL.
PASS Stylesheet loading using <link> with no Content-Type, same-origin, and no nosniff
PASS Stylesheet loading using <link> with no Content-Type, same-origin, and nosniff
-FAIL Stylesheet loading using <link> with wrong Content-Type, same-origin, and no nosniff assert_unreached: error event should have fired Reached unreachable code
+PASS Stylesheet loading using <link> with wrong Content-Type, same-origin, and no nosniff
PASS Stylesheet loading using <link> with wrong Content-Type, same-origin, and nosniff
PASS Stylesheet loading using <link> with broken Content-Type, same-origin, and no nosniff
PASS Stylesheet loading using <link> with broken Content-Type, same-origin, and nosniff
PASS Stylesheet loading using <link> with no Content-Type, cross-origin, and no nosniff
PASS Stylesheet loading using <link> with no Content-Type, cross-origin, and nosniff
-FAIL Stylesheet loading using <link> with wrong Content-Type, cross-origin, and no nosniff assert_unreached: error event should have fired Reached unreachable code
+PASS Stylesheet loading using <link> with wrong Content-Type, cross-origin, and no nosniff
PASS Stylesheet loading using <link> with wrong Content-Type, cross-origin, and nosniff
PASS Stylesheet loading using <link> with broken Content-Type, cross-origin, and no nosniff
PASS Stylesheet loading using <link> with broken Content-Type, cross-origin, and nosniff
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-link-element/link-style-error-limited-quirks-expected.txt (255692 => 255693)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-link-element/link-style-error-limited-quirks-expected.txt 2020-02-04 21:39:46 UTC (rev 255692)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-link-element/link-style-error-limited-quirks-expected.txt 2020-02-04 21:42:07 UTC (rev 255693)
@@ -7,7 +7,7 @@
PASS Stylesheet loading using <link> with broken Content-Type, same-origin, and nosniff
PASS Stylesheet loading using <link> with no Content-Type, cross-origin, and no nosniff
PASS Stylesheet loading using <link> with no Content-Type, cross-origin, and nosniff
-FAIL Stylesheet loading using <link> with wrong Content-Type, cross-origin, and no nosniff assert_unreached: error event should have fired Reached unreachable code
+PASS Stylesheet loading using <link> with wrong Content-Type, cross-origin, and no nosniff
PASS Stylesheet loading using <link> with wrong Content-Type, cross-origin, and nosniff
PASS Stylesheet loading using <link> with broken Content-Type, cross-origin, and no nosniff
PASS Stylesheet loading using <link> with broken Content-Type, cross-origin, and nosniff
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-link-element/link-style-error-quirks-expected.txt (255692 => 255693)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-link-element/link-style-error-quirks-expected.txt 2020-02-04 21:39:46 UTC (rev 255692)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-link-element/link-style-error-quirks-expected.txt 2020-02-04 21:42:07 UTC (rev 255693)
@@ -7,7 +7,7 @@
PASS Stylesheet loading using <link> with broken Content-Type, same-origin, and nosniff
PASS Stylesheet loading using <link> with no Content-Type, cross-origin, and no nosniff
PASS Stylesheet loading using <link> with no Content-Type, cross-origin, and nosniff
-FAIL Stylesheet loading using <link> with wrong Content-Type, cross-origin, and no nosniff assert_unreached: error event should have fired Reached unreachable code
+PASS Stylesheet loading using <link> with wrong Content-Type, cross-origin, and no nosniff
PASS Stylesheet loading using <link> with wrong Content-Type, cross-origin, and nosniff
PASS Stylesheet loading using <link> with broken Content-Type, cross-origin, and no nosniff
PASS Stylesheet loading using <link> with broken Content-Type, cross-origin, and nosniff
Modified: trunk/Source/WebCore/ChangeLog (255692 => 255693)
--- trunk/Source/WebCore/ChangeLog 2020-02-04 21:39:46 UTC (rev 255692)
+++ trunk/Source/WebCore/ChangeLog 2020-02-04 21:42:07 UTC (rev 255693)
@@ -1,3 +1,35 @@
+2020-02-04 Rob Buis <[email protected]>
+
+ Tighten up stylesheet loading
+ https://bugs.webkit.org/show_bug.cgi?id=189913
+
+ Reviewed by Antti Koivisto.
+
+ Content-Type metadata for link stylesheet is determined using MIME
+ sniffing[1]. This can result in no Content-Type metadata.
+ If there is no Content-Type metadata, but the external resource link
+ type has a default type defined, then the user agent must assume that
+ the resource is of that type [2]. For link stylesheet the default is
+ text/css. This means invalid MIME type will default to text/css and
+ load and valid MIME types other than text/css will result in load error.
+
+ [1] https://mimesniff.spec.whatwg.org/
+ [2] https://html.spec.whatwg.org/multipage/semantics.html#fetch-and-process-the-linked-resource
+
+ Tests: imported/w3c/web-platform-tests/html/semantics/document-metadata/the-link-element/link-load-error-events.html
+ imported/w3c/web-platform-tests/html/semantics/document-metadata/the-link-element/link-load-error-events.https.html
+ imported/w3c/web-platform-tests/html/semantics/document-metadata/the-link-element/link-style-error-01.html
+ imported/w3c/web-platform-tests/html/semantics/document-metadata/the-link-element/link-style-error-limited-quirks.html
+ imported/w3c/web-platform-tests/html/semantics/document-metadata/the-link-element/link-style-error-quirks.html
+
+ * css/StyleSheetContents.cpp:
+ (WebCore::StyleSheetContents::parseAuthorStyleSheet):
+ * css/StyleSheetContents.h:
+ * html/HTMLLinkElement.cpp:
+ (WebCore::HTMLLinkElement::setCSSStyleSheet):
+ * loader/cache/CachedCSSStyleSheet.cpp:
+ (WebCore::CachedCSSStyleSheet::canUseSheet const):
+
2020-02-04 youenn fablet <[email protected]>
NetworkProcess should be notified by UIProcess when its service worker process connection should be on
Modified: trunk/Source/WebCore/css/StyleSheetContents.cpp (255692 => 255693)
--- trunk/Source/WebCore/css/StyleSheetContents.cpp 2020-02-04 21:39:46 UTC (rev 255692)
+++ trunk/Source/WebCore/css/StyleSheetContents.cpp 2020-02-04 21:42:07 UTC (rev 255693)
@@ -316,7 +316,7 @@
return it->value;
}
-void StyleSheetContents::parseAuthorStyleSheet(const CachedCSSStyleSheet* cachedStyleSheet, const SecurityOrigin* securityOrigin)
+bool StyleSheetContents::parseAuthorStyleSheet(const CachedCSSStyleSheet* cachedStyleSheet, const SecurityOrigin* securityOrigin)
{
bool isSameOriginRequest = securityOrigin && securityOrigin->canRequest(baseURL());
CachedCSSStyleSheet::MIMETypeCheckHint mimeTypeCheckHint = isStrictParserMode(m_parserContext.mode) || !isSameOriginRequest ? CachedCSSStyleSheet::MIMETypeCheckHint::Strict : CachedCSSStyleSheet::MIMETypeCheckHint::Lax;
@@ -335,10 +335,11 @@
page->console().addMessage(MessageSource::Security, MessageLevel::Error, makeString("Did not parse stylesheet at '", cachedStyleSheet->url().stringCenterEllipsizedToLength(), "' because non CSS MIME types are not allowed for cross-origin stylesheets."));
}
}
- return;
+ return false;
}
CSSParser(parserContext()).parseSheet(this, sheetText, CSSParser::RuleParsing::Deferred);
+ return true;
}
bool StyleSheetContents::parseString(const String& sheetText)
Modified: trunk/Source/WebCore/css/StyleSheetContents.h (255692 => 255693)
--- trunk/Source/WebCore/css/StyleSheetContents.h 2020-02-04 21:39:46 UTC (rev 255692)
+++ trunk/Source/WebCore/css/StyleSheetContents.h 2020-02-04 21:42:07 UTC (rev 255693)
@@ -65,7 +65,7 @@
const AtomString& defaultNamespace() { return m_defaultNamespace; }
const AtomString& namespaceURIFromPrefix(const AtomString& prefix);
- void parseAuthorStyleSheet(const CachedCSSStyleSheet*, const SecurityOrigin*);
+ bool parseAuthorStyleSheet(const CachedCSSStyleSheet*, const SecurityOrigin*);
WEBCORE_EXPORT bool parseString(const String&);
bool isCacheable() const;
Modified: trunk/Source/WebCore/html/HTMLLinkElement.cpp (255692 => 255693)
--- trunk/Source/WebCore/html/HTMLLinkElement.cpp 2020-02-04 21:39:46 UTC (rev 255692)
+++ trunk/Source/WebCore/html/HTMLLinkElement.cpp 2020-02-04 21:42:07 UTC (rev 255693)
@@ -471,7 +471,12 @@
// FIXME: Set the visibility option based on m_sheet being clean or not.
// Best approach might be to set it on the style sheet content itself or its context parser otherwise.
- styleSheet.get().parseAuthorStyleSheet(cachedStyleSheet, &document().securityOrigin());
+ if (!styleSheet.get().parseAuthorStyleSheet(cachedStyleSheet, &document().securityOrigin())) {
+ m_loading = false;
+ sheetLoaded();
+ notifyLoadedSheetAndAllCriticalSubresources(true);
+ return;
+ }
m_loading = false;
styleSheet.get().notifyLoadedSheet(cachedStyleSheet);
Modified: trunk/Source/WebCore/loader/cache/CachedCSSStyleSheet.cpp (255692 => 255693)
--- trunk/Source/WebCore/loader/cache/CachedCSSStyleSheet.cpp 2020-02-04 21:39:46 UTC (rev 255692)
+++ trunk/Source/WebCore/loader/cache/CachedCSSStyleSheet.cpp 2020-02-04 21:42:07 UTC (rev 255693)
@@ -31,6 +31,7 @@
#include "HTTPHeaderNames.h"
#include "HTTPParsers.h"
#include "MemoryCache.h"
+#include "ParsedContentType.h"
#include "SharedBuffer.h"
#include "StyleSheetContents.h"
#include "TextResourceDecoder.h"
@@ -151,7 +152,7 @@
// This code defaults to allowing the stylesheet for non-HTTP protocols so
// folks can use standards mode for local HTML documents.
String mimeType = responseMIMEType();
- bool typeOK = mimeType.isEmpty() || equalLettersIgnoringASCIICase(mimeType, "text/css") || equalLettersIgnoringASCIICase(mimeType, "application/x-unknown-content-type");
+ bool typeOK = mimeType.isEmpty() || equalLettersIgnoringASCIICase(mimeType, "text/css") || equalLettersIgnoringASCIICase(mimeType, "application/x-unknown-content-type") || !isValidContentType(mimeType);
if (hasValidMIMEType)
*hasValidMIMEType = typeOK;
return typeOK;