Title: [228096] trunk
- Revision
- 228096
- Author
- [email protected]
- Date
- 2018-02-05 08:30:02 -0800 (Mon, 05 Feb 2018)
Log Message
Crash on sfgate.com because mismatching link preload types
https://bugs.webkit.org/show_bug.cgi?id=182483
<rdar://problem/37065331>
Reviewed by Daniel Bates.
Source/WebCore:
Preloading the same URL with different 'as' types causes some confusion.
Test: http/tests/preload/link-preload-type-mismatch.html
* loader/LinkLoader.cpp:
(WebCore::createLinkPreloadResourceClient):
Ensure we use the actual resource type when creating the client.
(WebCore::LinkLoader::preloadIfNeeded):
Don't construct client if the types don't match. This can happen if there is an existing
preload for the same resource with different type.
LayoutTests:
* http/tests/preload/link-preload-type-mismatch-expected.txt: Added.
* http/tests/preload/link-preload-type-mismatch.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (228095 => 228096)
--- trunk/LayoutTests/ChangeLog 2018-02-05 13:51:24 UTC (rev 228095)
+++ trunk/LayoutTests/ChangeLog 2018-02-05 16:30:02 UTC (rev 228096)
@@ -1,3 +1,14 @@
+2018-02-05 Antti Koivisto <[email protected]>
+
+ Crash on sfgate.com because mismatching link preload types
+ https://bugs.webkit.org/show_bug.cgi?id=182483
+ <rdar://problem/37065331>
+
+ Reviewed by Daniel Bates.
+
+ * http/tests/preload/link-preload-type-mismatch-expected.txt: Added.
+ * http/tests/preload/link-preload-type-mismatch.html: Added.
+
2018-02-05 Manuel Rego Casasnovas <[email protected]>
[css-grid] Rename gutter properties to remove "grid-" prefix
Added: trunk/LayoutTests/http/tests/preload/link-preload-type-mismatch-expected.txt (0 => 228096)
--- trunk/LayoutTests/http/tests/preload/link-preload-type-mismatch-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/preload/link-preload-type-mismatch-expected.txt 2018-02-05 16:30:02 UTC (rev 228096)
@@ -0,0 +1 @@
+Test mismatching preload types. The test passes if it doesn't crash or assert.
Added: trunk/LayoutTests/http/tests/preload/link-preload-type-mismatch.html (0 => 228096)
--- trunk/LayoutTests/http/tests/preload/link-preload-type-mismatch.html (rev 0)
+++ trunk/LayoutTests/http/tests/preload/link-preload-type-mismatch.html 2018-02-05 16:30:02 UTC (rev 228096)
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<script>
+if (window.testRunner) {
+ testRunner.dumpAsText()
+ testRunner.waitUntilDone();
+ window.addEventListener("load", function() {
+ testRunner.notifyDone();
+ });
+}
+</script>
+<link rel=preload href="" as=fetch>
+<link rel=preload href="" as=script>
+<body>
+Test mismatching preload types. The test passes if it doesn't crash or assert.
+<script src=""
+</body>
Modified: trunk/Source/WebCore/ChangeLog (228095 => 228096)
--- trunk/Source/WebCore/ChangeLog 2018-02-05 13:51:24 UTC (rev 228095)
+++ trunk/Source/WebCore/ChangeLog 2018-02-05 16:30:02 UTC (rev 228096)
@@ -1,3 +1,25 @@
+2018-02-05 Antti Koivisto <[email protected]>
+
+ Crash on sfgate.com because mismatching link preload types
+ https://bugs.webkit.org/show_bug.cgi?id=182483
+ <rdar://problem/37065331>
+
+ Reviewed by Daniel Bates.
+
+ Preloading the same URL with different 'as' types causes some confusion.
+
+ Test: http/tests/preload/link-preload-type-mismatch.html
+
+ * loader/LinkLoader.cpp:
+ (WebCore::createLinkPreloadResourceClient):
+
+ Ensure we use the actual resource type when creating the client.
+
+ (WebCore::LinkLoader::preloadIfNeeded):
+
+ Don't construct client if the types don't match. This can happen if there is an existing
+ preload for the same resource with different type.
+
2018-02-05 Manuel Rego Casasnovas <[email protected]>
[css-grid] Rename gutter properties to remove "grid-" prefix
Modified: trunk/Source/WebCore/loader/LinkLoader.cpp (228095 => 228096)
--- trunk/Source/WebCore/loader/LinkLoader.cpp 2018-02-05 13:51:24 UTC (rev 228095)
+++ trunk/Source/WebCore/loader/LinkLoader.cpp 2018-02-05 16:30:02 UTC (rev 228096)
@@ -135,9 +135,9 @@
return std::nullopt;
}
-static std::unique_ptr<LinkPreloadResourceClient> createLinkPreloadResourceClient(CachedResource& resource, LinkLoader& loader, CachedResource::Type type)
+static std::unique_ptr<LinkPreloadResourceClient> createLinkPreloadResourceClient(CachedResource& resource, LinkLoader& loader)
{
- switch (type) {
+ switch (resource.type()) {
case CachedResource::ImageResource:
return LinkPreloadImageResourceClient::create(loader, static_cast<CachedImage&>(resource));
case CachedResource::Script:
@@ -239,8 +239,11 @@
linkRequest.setAsPotentiallyCrossOrigin(crossOriginMode, document);
auto cachedLinkResource = document.cachedResourceLoader().preload(type.value(), WTFMove(linkRequest)).value_or(nullptr);
+ if (cachedLinkResource && cachedLinkResource->type() != *type)
+ return nullptr;
+
if (cachedLinkResource && loader)
- return createLinkPreloadResourceClient(*cachedLinkResource, *loader, type.value());
+ return createLinkPreloadResourceClient(*cachedLinkResource, *loader);
return nullptr;
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes