Diff
Modified: branches/safari-605-branch/LayoutTests/ChangeLog (229818 => 229819)
--- branches/safari-605-branch/LayoutTests/ChangeLog 2018-03-21 19:41:26 UTC (rev 229818)
+++ branches/safari-605-branch/LayoutTests/ChangeLog 2018-03-21 20:21:45 UTC (rev 229819)
@@ -1,3 +1,20 @@
+2018-03-21 Jason Marcell <[email protected]>
+
+ Cherry-pick r229585. rdar://problem/38681880
+
+ 2018-03-13 Youenn Fablet <[email protected]>
+
+ Changing link element rel attribute from preload to stylesheet should succeed loading the stylesheet
+ https://bugs.webkit.org/show_bug.cgi?id=183601
+ <rdar://problem/38309441>
+
+ Reviewed by Antti Koivisto.
+
+ * http/wpt/preload/change-link-rel-attribute-expected.txt: Added.
+ * http/wpt/preload/change-link-rel-attribute.html: Added.
+ * http/wpt/preload/resources/style.css: Added.
+ (body):
+
2018-03-21 Ryan Haddad <[email protected]>
Work towards rdar://problem/38714892.
Added: branches/safari-605-branch/LayoutTests/http/wpt/preload/change-link-rel-attribute-expected.txt (0 => 229819)
--- branches/safari-605-branch/LayoutTests/http/wpt/preload/change-link-rel-attribute-expected.txt (rev 0)
+++ branches/safari-605-branch/LayoutTests/http/wpt/preload/change-link-rel-attribute-expected.txt 2018-03-21 20:21:45 UTC (rev 229819)
@@ -0,0 +1,3 @@
+
+PASS Check changing preload link to stylesheet link works
+
Added: branches/safari-605-branch/LayoutTests/http/wpt/preload/change-link-rel-attribute.html (0 => 229819)
--- branches/safari-605-branch/LayoutTests/http/wpt/preload/change-link-rel-attribute.html (rev 0)
+++ branches/safari-605-branch/LayoutTests/http/wpt/preload/change-link-rel-attribute.html 2018-03-21 20:21:45 UTC (rev 229819)
@@ -0,0 +1,49 @@
+<!doctype html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <script src=""
+ <script src=""
+ <style>
+ body {
+ background: red;
+ }
+ </style>
+</head>
+<body>
+ <link rel="preload" as="style" href=""
+
+ <script>
+ window.addEventListener('load', function () {
+ var css = document.querySelectorAll('link[href*=".css"]');
+ for (var i = 0; i < css.length; ++i) {
+ css[i].setAttribute('rel', 'stylesheet');
+ }
+ });
+
+ function waitFor(duration)
+ {
+ return new Promise((resolve) => setTimeout(resolve, duration));
+ }
+
+ var counter = 10;
+ async function checkBackgroundColor()
+ {
+ if (--counter < 0) {
+ assert_unreached("test timed out");
+ return;
+ }
+ if (getComputedStyle(document.body).backgroundColor === "rgb(0, 128, 0)")
+ return;
+
+ await waitFor(10);
+ return checkBackgroundColor();
+ }
+
+ promise_test(async (test) => {
+ await checkBackgroundColor();
+ document.body.style.backgroundColor = "white";
+ }, "Check changing preload link to stylesheet link works");
+ </script>
+</body>
+</html>
Added: branches/safari-605-branch/LayoutTests/http/wpt/preload/resources/style.css (0 => 229819)
--- branches/safari-605-branch/LayoutTests/http/wpt/preload/resources/style.css (rev 0)
+++ branches/safari-605-branch/LayoutTests/http/wpt/preload/resources/style.css 2018-03-21 20:21:45 UTC (rev 229819)
@@ -0,0 +1,3 @@
+body {
+ background: green;
+}
Modified: branches/safari-605-branch/Source/WebCore/ChangeLog (229818 => 229819)
--- branches/safari-605-branch/Source/WebCore/ChangeLog 2018-03-21 19:41:26 UTC (rev 229818)
+++ branches/safari-605-branch/Source/WebCore/ChangeLog 2018-03-21 20:21:45 UTC (rev 229819)
@@ -1,3 +1,25 @@
+2018-03-21 Jason Marcell <[email protected]>
+
+ Cherry-pick r229585. rdar://problem/38681880
+
+ 2018-03-13 Youenn Fablet <[email protected]>
+
+ Changing link element rel attribute from preload to stylesheet should succeed loading the stylesheet
+ https://bugs.webkit.org/show_bug.cgi?id=183601
+ <rdar://problem/38309441>
+
+ Reviewed by Antti Koivisto.
+
+ Test: http/wpt/preload/change-link-rel-attribute.html
+
+ * loader/LinkPreloadResourceClients.h:
+ (WebCore::LinkPreloadResourceClient::clearResource): Remove the call to CachedResource::cancelLoad.
+ This call is expected to be called by ResourceLoader when cancelling the load from below CachedResource.
+ * loader/cache/CachedResource.cpp:
+ (WebCore::CachedResource::allClientsRemoved): In case of preload,
+ cancel the load if not finished when there is no more client attached to it.
+ * loader/cache/CachedResource.h:
+
2018-03-20 Jason Marcell <[email protected]>
Apply patch. rdar://problem/38651613
Modified: branches/safari-605-branch/Source/WebCore/loader/LinkPreloadResourceClients.h (229818 => 229819)
--- branches/safari-605-branch/Source/WebCore/loader/LinkPreloadResourceClients.h 2018-03-21 19:41:26 UTC (rev 229818)
+++ branches/safari-605-branch/Source/WebCore/loader/LinkPreloadResourceClients.h 2018-03-21 20:21:45 UTC (rev 229819)
@@ -62,10 +62,10 @@
void clearResource(CachedResourceClient& client)
{
- if (m_resource) {
- m_resource->cancelLoad();
- m_resource->removeClient(client);
- }
+ if (!m_resource)
+ return;
+
+ m_resource->removeClient(client);
m_resource = nullptr;
}
Modified: branches/safari-605-branch/Source/WebCore/loader/cache/CachedResource.cpp (229818 => 229819)
--- branches/safari-605-branch/Source/WebCore/loader/cache/CachedResource.cpp 2018-03-21 19:41:26 UTC (rev 229818)
+++ branches/safari-605-branch/Source/WebCore/loader/cache/CachedResource.cpp 2018-03-21 20:21:45 UTC (rev 229819)
@@ -586,6 +586,12 @@
memoryCache.pruneSoon();
}
+void CachedResource::allClientsRemoved()
+{
+ if (isLinkPreload() && m_loader)
+ m_loader->cancelIfNotFinishing();
+}
+
void CachedResource::destroyDecodedDataIfNeeded()
{
if (!m_decodedSize)
Modified: branches/safari-605-branch/Source/WebCore/loader/cache/CachedResource.h (229818 => 229819)
--- branches/safari-605-branch/Source/WebCore/loader/cache/CachedResource.h 2018-03-21 19:41:26 UTC (rev 229818)
+++ branches/safari-605-branch/Source/WebCore/loader/cache/CachedResource.h 2018-03-21 20:21:45 UTC (rev 229819)
@@ -144,7 +144,7 @@
virtual void didAddClient(CachedResourceClient&);
virtual void didRemoveClient(CachedResourceClient&) { }
- virtual void allClientsRemoved() { }
+ virtual void allClientsRemoved();
void destroyDecodedDataIfNeeded();
unsigned count() const { return m_clients.size(); }