Diff
Modified: trunk/LayoutTests/ChangeLog (229195 => 229196)
--- trunk/LayoutTests/ChangeLog 2018-03-03 07:58:55 UTC (rev 229195)
+++ trunk/LayoutTests/ChangeLog 2018-03-03 08:57:34 UTC (rev 229196)
@@ -1,3 +1,16 @@
+2018-03-03 Yoav Weiss <y...@yoav.ws>
+
+ Link headers for subresources are not being processed
+ https://bugs.webkit.org/show_bug.cgi?id=181789
+
+ Reviewed by Youenn Fablet.
+
+ Adds tests to make sure Link headers on subresources are being processed.
+
+ * http/tests/preload/link-header-on-subresource-expected.txt: Added.
+ * http/tests/preload/link-header-on-subresource.html: Added.
+ * http/tests/preload/resources/dummy-preloads-subresource.css.php: Added.
+
2018-03-02 Youenn Fablet <you...@apple.com>
Service worker test gardening
Added: trunk/LayoutTests/http/tests/preload/link-header-on-subresource-expected.txt (0 => 229196)
--- trunk/LayoutTests/http/tests/preload/link-header-on-subresource-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/preload/link-header-on-subresource-expected.txt 2018-03-03 08:57:34 UTC (rev 229196)
@@ -0,0 +1,5 @@
+CONSOLE MESSAGE: Did not parse stylesheet at 'http://127.0.0.1:8000/preload/resources/dummy-preloads-subresource.css.php' because non CSS MIME types are not allowed in strict mode.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/http/tests/preload/link-header-on-subresource.html (0 => 229196)
--- trunk/LayoutTests/http/tests/preload/link-header-on-subresource.html (rev 0)
+++ trunk/LayoutTests/http/tests/preload/link-header-on-subresource.html 2018-03-03 08:57:34 UTC (rev 229196)
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<script>
+ if (window.testRunner) {
+ testRunner.dumpAsText()
+ testRunner.waitUntilDone();
+ }
+</script>
+<script src=""
+<link rel=stylesheet href=""
+<script>
+ setInterval(function() {
+ if (internals.isPreloaded("../resources/dummy.js") && internals.isPreloaded("../resources/dummy.js?media"))
+ testRunner.notifyDone();
+ }, 100);
+</script>
+
Added: trunk/LayoutTests/http/tests/preload/resources/dummy-preloads-subresource.css.php (0 => 229196)
--- trunk/LayoutTests/http/tests/preload/resources/dummy-preloads-subresource.css.php (rev 0)
+++ trunk/LayoutTests/http/tests/preload/resources/dummy-preloads-subresource.css.php 2018-03-03 08:57:34 UTC (rev 229196)
@@ -0,0 +1,6 @@
+<?php
+header("Link: <../resources/dummy.js>; rel=preload; as=script", false);
+header("Link: <../resources/dummy.js?media>; rel=preload; as=script; media=all", false);
+?>
+/* This is just a dummy, empty CSS file */
+
Modified: trunk/Source/WebCore/ChangeLog (229195 => 229196)
--- trunk/Source/WebCore/ChangeLog 2018-03-03 07:58:55 UTC (rev 229195)
+++ trunk/Source/WebCore/ChangeLog 2018-03-03 08:57:34 UTC (rev 229196)
@@ -1,3 +1,20 @@
+2018-03-03 Yoav Weiss <y...@yoav.ws>
+
+ Link headers for subresources are not being processes
+ https://bugs.webkit.org/show_bug.cgi?id=181789
+
+ Reviewed by Youenn Fablet.
+
+ Triggers Link header processing when the Link headers arrive on a subresource.
+
+ Test: http/tests/preload/link-header-on-subresource.html
+
+ * loader/LinkLoader.cpp:
+ (WebCore::LinkLoader::loadLinksFromHeader): Change the media check conditions.
+ * loader/LinkLoader.h: Add a third state for media checks.
+ * loader/SubresourceLoader.cpp:
+ (WebCore::SubresourceLoader::didReceiveResponse): Preload links from headers for subresources.
+
2018-03-02 Yusuke Suzuki <utatane....@gmail.com>
[WTF] Remove RunLoop and RunLoop::Timer's interface using double as seconds
Modified: trunk/Source/WebCore/loader/LinkLoader.cpp (229195 => 229196)
--- trunk/Source/WebCore/loader/LinkLoader.cpp 2018-03-03 07:58:55 UTC (rev 229195)
+++ trunk/Source/WebCore/loader/LinkLoader.cpp 2018-03-03 08:57:34 UTC (rev 229196)
@@ -97,12 +97,9 @@
for (auto& header : headerSet) {
if (!header.valid() || header.url().isEmpty() || header.rel().isEmpty())
continue;
- if (mediaAttributeCheck == MediaAttributeCheck::MediaAttributeNotEmpty) {
- if (header.media().isEmpty())
+ if ((mediaAttributeCheck == MediaAttributeCheck::MediaAttributeNotEmpty && header.media().isEmpty())
+ || (mediaAttributeCheck == MediaAttributeCheck::MediaAttributeEmpty && !header.media().isEmpty())) {
continue;
- } else {
- if (!header.media().isEmpty())
- continue;
}
LinkRelAttribute relAttribute(document, header.rel());
Modified: trunk/Source/WebCore/loader/LinkLoader.h (229195 => 229196)
--- trunk/Source/WebCore/loader/LinkLoader.h 2018-03-03 07:58:55 UTC (rev 229195)
+++ trunk/Source/WebCore/loader/LinkLoader.h 2018-03-03 08:57:34 UTC (rev 229196)
@@ -54,7 +54,7 @@
bool loadLink(const LinkRelAttribute&, const URL&, const String& as, const String& media, const String& type, const String& crossOrigin, Document&);
static std::optional<CachedResource::Type> resourceTypeFromAsAttribute(const String& as);
- enum class MediaAttributeCheck { MediaAttributeEmpty, MediaAttributeNotEmpty };
+ enum class MediaAttributeCheck { MediaAttributeEmpty, MediaAttributeNotEmpty, SkipMediaAttributeCheck };
static void loadLinksFromHeader(const String& headerValue, const URL& baseURL, Document&, MediaAttributeCheck);
static bool isSupportedType(CachedResource::Type, const String& mimeType);
Modified: trunk/Source/WebCore/loader/SubresourceLoader.cpp (229195 => 229196)
--- trunk/Source/WebCore/loader/SubresourceLoader.cpp 2018-03-03 07:58:55 UTC (rev 229195)
+++ trunk/Source/WebCore/loader/SubresourceLoader.cpp 2018-03-03 08:57:34 UTC (rev 229196)
@@ -38,6 +38,7 @@
#include "DocumentLoader.h"
#include "Frame.h"
#include "FrameLoader.h"
+#include "LinkLoader.h"
#include "Logging.h"
#include "MainFrame.h"
#include "MemoryCache.h"
@@ -359,6 +360,8 @@
return;
bool isResponseMultipart = response.isMultipart();
+ if (options().mode != FetchOptions::Mode::Navigate)
+ LinkLoader::loadLinksFromHeader(response.httpHeaderField(HTTPHeaderName::Link), m_documentLoader->url(), *m_frame->document(), LinkLoader::MediaAttributeCheck::SkipMediaAttributeCheck);
ResourceLoader::didReceiveResponse(response, [this, protectedThis = WTFMove(protectedThis), isResponseMultipart, completionHandlerCaller = WTFMove(completionHandlerCaller)]() mutable {
if (reachedTerminalState())
return;