Title: [229585] trunk
- Revision
- 229585
- Author
- you...@apple.com
- Date
- 2018-03-13 13:39:17 -0700 (Tue, 13 Mar 2018)
Log Message
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.
Source/WebCore:
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:
LayoutTests:
* 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):
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (229584 => 229585)
--- trunk/LayoutTests/ChangeLog 2018-03-13 20:14:14 UTC (rev 229584)
+++ trunk/LayoutTests/ChangeLog 2018-03-13 20:39:17 UTC (rev 229585)
@@ -1,3 +1,16 @@
+2018-03-13 Youenn Fablet <you...@apple.com>
+
+ 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-13 Frederic Wang <fw...@igalia.com>
Skip mathml-in-dashboard-expected on Windows
Added: trunk/LayoutTests/http/wpt/preload/change-link-rel-attribute-expected.txt (0 => 229585)
--- trunk/LayoutTests/http/wpt/preload/change-link-rel-attribute-expected.txt (rev 0)
+++ trunk/LayoutTests/http/wpt/preload/change-link-rel-attribute-expected.txt 2018-03-13 20:39:17 UTC (rev 229585)
@@ -0,0 +1,3 @@
+
+PASS Check changing preload link to stylesheet link works
+
Added: trunk/LayoutTests/http/wpt/preload/change-link-rel-attribute.html (0 => 229585)
--- trunk/LayoutTests/http/wpt/preload/change-link-rel-attribute.html (rev 0)
+++ trunk/LayoutTests/http/wpt/preload/change-link-rel-attribute.html 2018-03-13 20:39:17 UTC (rev 229585)
@@ -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: trunk/LayoutTests/http/wpt/preload/resources/style.css (0 => 229585)
--- trunk/LayoutTests/http/wpt/preload/resources/style.css (rev 0)
+++ trunk/LayoutTests/http/wpt/preload/resources/style.css 2018-03-13 20:39:17 UTC (rev 229585)
@@ -0,0 +1,3 @@
+body {
+ background: green;
+}
Modified: trunk/Source/WebCore/ChangeLog (229584 => 229585)
--- trunk/Source/WebCore/ChangeLog 2018-03-13 20:14:14 UTC (rev 229584)
+++ trunk/Source/WebCore/ChangeLog 2018-03-13 20:39:17 UTC (rev 229585)
@@ -1,3 +1,21 @@
+2018-03-13 Youenn Fablet <you...@apple.com>
+
+ 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-12 John Wilander <wilan...@apple.com>
Resource Load Statistics: Immediately forward cookie access at user interaction when there's an opener document
Modified: trunk/Source/WebCore/loader/LinkPreloadResourceClients.h (229584 => 229585)
--- trunk/Source/WebCore/loader/LinkPreloadResourceClients.h 2018-03-13 20:14:14 UTC (rev 229584)
+++ trunk/Source/WebCore/loader/LinkPreloadResourceClients.h 2018-03-13 20:39:17 UTC (rev 229585)
@@ -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: trunk/Source/WebCore/loader/cache/CachedResource.cpp (229584 => 229585)
--- trunk/Source/WebCore/loader/cache/CachedResource.cpp 2018-03-13 20:14:14 UTC (rev 229584)
+++ trunk/Source/WebCore/loader/cache/CachedResource.cpp 2018-03-13 20:39:17 UTC (rev 229585)
@@ -579,6 +579,12 @@
memoryCache.pruneSoon();
}
+void CachedResource::allClientsRemoved()
+{
+ if (isLinkPreload() && m_loader)
+ m_loader->cancelIfNotFinishing();
+}
+
void CachedResource::destroyDecodedDataIfNeeded()
{
if (!m_decodedSize)
Modified: trunk/Source/WebCore/loader/cache/CachedResource.h (229584 => 229585)
--- trunk/Source/WebCore/loader/cache/CachedResource.h 2018-03-13 20:14:14 UTC (rev 229584)
+++ trunk/Source/WebCore/loader/cache/CachedResource.h 2018-03-13 20:39:17 UTC (rev 229585)
@@ -141,7 +141,7 @@
virtual void didAddClient(CachedResourceClient&);
virtual void didRemoveClient(CachedResourceClient&) { }
- virtual void allClientsRemoved() { }
+ virtual void allClientsRemoved();
void destroyDecodedDataIfNeeded();
unsigned count() const { return m_clients.size(); }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes