Title: [228141] branches/safari-605-branch

Diff

Modified: branches/safari-605-branch/LayoutTests/ChangeLog (228140 => 228141)


--- branches/safari-605-branch/LayoutTests/ChangeLog	2018-02-06 00:16:02 UTC (rev 228140)
+++ branches/safari-605-branch/LayoutTests/ChangeLog	2018-02-06 00:16:05 UTC (rev 228141)
@@ -1,3 +1,18 @@
+2018-02-05  Jason Marcell  <jmarc...@apple.com>
+
+        Cherry-pick r228096. rdar://problem/37240973
+
+    2018-02-05  Antti Koivisto  <an...@apple.com>
+
+            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-04  Jason Marcell  <jmarc...@apple.com>
 
         Cherry-pick r227935. rdar://problem/37145460

Added: branches/safari-605-branch/LayoutTests/http/tests/preload/link-preload-type-mismatch-expected.txt (0 => 228141)


--- branches/safari-605-branch/LayoutTests/http/tests/preload/link-preload-type-mismatch-expected.txt	                        (rev 0)
+++ branches/safari-605-branch/LayoutTests/http/tests/preload/link-preload-type-mismatch-expected.txt	2018-02-06 00:16:05 UTC (rev 228141)
@@ -0,0 +1 @@
+Test mismatching preload types. The test passes if it doesn't crash or assert.

Added: branches/safari-605-branch/LayoutTests/http/tests/preload/link-preload-type-mismatch.html (0 => 228141)


--- branches/safari-605-branch/LayoutTests/http/tests/preload/link-preload-type-mismatch.html	                        (rev 0)
+++ branches/safari-605-branch/LayoutTests/http/tests/preload/link-preload-type-mismatch.html	2018-02-06 00:16:05 UTC (rev 228141)
@@ -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: branches/safari-605-branch/Source/WebCore/ChangeLog (228140 => 228141)


--- branches/safari-605-branch/Source/WebCore/ChangeLog	2018-02-06 00:16:02 UTC (rev 228140)
+++ branches/safari-605-branch/Source/WebCore/ChangeLog	2018-02-06 00:16:05 UTC (rev 228141)
@@ -1,5 +1,31 @@
 2018-02-05  Jason Marcell  <jmarc...@apple.com>
 
+        Cherry-pick r228096. rdar://problem/37240973
+
+    2018-02-05  Antti Koivisto  <an...@apple.com>
+
+            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  Jason Marcell  <jmarc...@apple.com>
+
         Cherry-pick r227989. rdar://problem/37145565
 
     2018-02-01  Youenn Fablet  <you...@apple.com>

Modified: branches/safari-605-branch/Source/WebCore/loader/LinkLoader.cpp (228140 => 228141)


--- branches/safari-605-branch/Source/WebCore/loader/LinkLoader.cpp	2018-02-06 00:16:02 UTC (rev 228140)
+++ branches/safari-605-branch/Source/WebCore/loader/LinkLoader.cpp	2018-02-06 00:16:05 UTC (rev 228141)
@@ -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
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to