Diff
Modified: trunk/LayoutTests/ChangeLog (227234 => 227235)
--- trunk/LayoutTests/ChangeLog 2018-01-19 22:12:23 UTC (rev 227234)
+++ trunk/LayoutTests/ChangeLog 2018-01-19 22:16:21 UTC (rev 227235)
@@ -1,3 +1,18 @@
+2018-01-19 Yoav Weiss <[email protected]>
+
+ Support for preconnect Link headers
+ https://bugs.webkit.org/show_bug.cgi?id=181657
+
+ Reviewed by Darin Adler.
+
+ Add test to see Link preconnect headers trigger a connection.
+
+ * http/tests/preconnect/link-header-rel-preconnect-http-expected.txt: Added.
+ * http/tests/preconnect/link-header-rel-preconnect-http.html: Added.
+ * http/tests/preconnect/resources/header-preconnect.php: Added.
+ * platform/ios-simulator/TestExpectations: Skipped the test, as ios-simulator doesn't process Link headers for subresources.
+ * platform/win/TestExpectations: Skipped the preconnect test directory, as it doesn't work on Windows.
+
2018-01-19 Joseph Pecoraro <[email protected]>
AppCache: Log a Deprecation warning to the Console when AppCache is used
Added: trunk/LayoutTests/http/tests/preconnect/link-header-rel-preconnect-http-expected.txt (0 => 227235)
--- trunk/LayoutTests/http/tests/preconnect/link-header-rel-preconnect-http-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/preconnect/link-header-rel-preconnect-http-expected.txt 2018-01-19 22:16:21 UTC (rev 227235)
@@ -0,0 +1,10 @@
+CONSOLE MESSAGE: Successfuly preconnected to http://localhost:8000/
+Tests that Link header's rel=preconnect works as expected over HTTP.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/http/tests/preconnect/link-header-rel-preconnect-http.html (0 => 227235)
--- trunk/LayoutTests/http/tests/preconnect/link-header-rel-preconnect-http.html (rev 0)
+++ trunk/LayoutTests/http/tests/preconnect/link-header-rel-preconnect-http.html 2018-01-19 22:16:21 UTC (rev 227235)
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script>
+description("Tests that Link header's rel=preconnect works as expected over HTTP.");
+jsTestIsAsync = true;
+
+// If the feature is not supported on this platform, fail without a timeout.
+if (!document.createElement("link").relList.supports("preconnect"))
+ finishJSTest();
+
+internals.setConsoleMessageListener(function() {
+ finishJSTest();
+});
+var script = document.createElement("script");
+script.src = ""
+document.body.appendChild(script);
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/http/tests/preconnect/resources/header-preconnect.php (0 => 227235)
--- trunk/LayoutTests/http/tests/preconnect/resources/header-preconnect.php (rev 0)
+++ trunk/LayoutTests/http/tests/preconnect/resources/header-preconnect.php 2018-01-19 22:16:21 UTC (rev 227235)
@@ -0,0 +1,3 @@
+<?php
+ header('Link: <http://localhost:8000>; rel=preconnect');
+?>
Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (227234 => 227235)
--- trunk/LayoutTests/platform/ios-simulator/TestExpectations 2018-01-19 22:12:23 UTC (rev 227234)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations 2018-01-19 22:16:21 UTC (rev 227235)
@@ -59,5 +59,8 @@
# WebGL tests which need triaging https://bugs.webkit.org/b/174100
webgl/1.0.2/conformance/uniforms/uniform-default-values.html [ Failure ]
+# ios-simulator does not process link headers for subresources
+webkit.org/b/181789 http/tests/preconnect/link-header-rel-preconnect-http.html [ Skip ]
+
# This test requires Skia, which isn't available on iOS.
webkit.org/b/174079 fast/text/variations/skia-postscript-name.html [ ImageOnlyFailure ]
Modified: trunk/LayoutTests/platform/win/TestExpectations (227234 => 227235)
--- trunk/LayoutTests/platform/win/TestExpectations 2018-01-19 22:12:23 UTC (rev 227234)
+++ trunk/LayoutTests/platform/win/TestExpectations 2018-01-19 22:16:21 UTC (rev 227235)
@@ -3786,8 +3786,7 @@
# preconnect tests are failing on Windows.
webkit.org/b/177626 fast/dom/HTMLLinkElement/preconnect-support.html [ Skip ]
-webkit.org/b/177626 http/tests/preconnect/link-rel-preconnect-http.html [ Skip ]
-webkit.org/b/177626 http/tests/preconnect/link-rel-preconnect-https.html [ Skip ]
+webkit.org/b/177626 http/tests/preconnect/ [ Skip ]
webkit.org/b/177964 fast/text/font-display/block-nofinish.html [ Pass ImageOnlyFailure ]
webkit.org/b/177964 fast/text/font-display/failure-finish.html [ Pass ImageOnlyFailure ]
Modified: trunk/Source/WebCore/ChangeLog (227234 => 227235)
--- trunk/Source/WebCore/ChangeLog 2018-01-19 22:12:23 UTC (rev 227234)
+++ trunk/Source/WebCore/ChangeLog 2018-01-19 22:16:21 UTC (rev 227235)
@@ -1,3 +1,21 @@
+2018-01-19 Yoav Weiss <[email protected]>
+
+ Support for preconnect Link headers
+ https://bugs.webkit.org/show_bug.cgi?id=181657
+
+ Reviewed by Darin Adler.
+
+ Move the preconnect functionality into its own function, and
+ also call this function when Link headers are processed.
+
+ Test: http/tests/preconnect/link-header-rel-preconnect-http.php
+
+ * loader/LinkLoader.cpp:
+ (WebCore::LinkLoader::loadLinksFromHeader): Call preconnectIfNeeded.
+ (WebCore::LinkLoader::preconnectIfNeeded): Preconnect to a host functionality moved here.
+ (WebCore::LinkLoader::loadLink): Call preconnectIfNeeded.
+ * loader/LinkLoader.h:
+
2018-01-19 Joseph Pecoraro <[email protected]>
AppCache: Log a Deprecation warning to the Console when AppCache is used
Modified: trunk/Source/WebCore/loader/LinkLoader.cpp (227234 => 227235)
--- trunk/Source/WebCore/loader/LinkLoader.cpp 2018-01-19 22:12:23 UTC (rev 227234)
+++ trunk/Source/WebCore/loader/LinkLoader.cpp 2018-01-19 22:16:21 UTC (rev 227235)
@@ -110,6 +110,7 @@
// Sanity check to avoid re-entrancy here.
if (equalIgnoringFragmentIdentifier(url, baseURL))
continue;
+ preconnectIfNeeded(relAttribute, url, document, header.crossOrigin());
preloadIfNeeded(relAttribute, url, document, header.as(), header.media(), header.mimeType(), header.crossOrigin(), nullptr);
}
}
@@ -211,6 +212,26 @@
return false;
}
+void LinkLoader::preconnectIfNeeded(const LinkRelAttribute& relAttribute, const URL& href, Document& document, const String& crossOrigin)
+{
+ if (!relAttribute.isLinkPreconnect || !href.isValid() || !href.protocolIsInHTTPFamily() || !document.frame())
+ return;
+ ASSERT(document.settings().linkPreconnectEnabled());
+ StoredCredentialsPolicy storageCredentialsPolicy = StoredCredentialsPolicy::Use;
+ if (equalIgnoringASCIICase(crossOrigin, "anonymous") && document.securityOrigin().canAccess(SecurityOrigin::create(href)))
+ storageCredentialsPolicy = StoredCredentialsPolicy::DoNotUse;
+ ASSERT(document.frame()->loader().networkingContext());
+ platformStrategies()->loaderStrategy()->preconnectTo(*document.frame()->loader().networkingContext(), href, storageCredentialsPolicy, [weakDocument = document.createWeakPtr(), href](ResourceError error) {
+ if (!weakDocument)
+ return;
+
+ if (!error.isNull())
+ weakDocument->addConsoleMessage(MessageSource::Network, MessageLevel::Error, makeString(ASCIILiteral("Failed to preconnect to "), href.string(), ASCIILiteral(". Error: "), error.localizedDescription()));
+ else
+ weakDocument->addConsoleMessage(MessageSource::Network, MessageLevel::Info, makeString(ASCIILiteral("Successfuly preconnected to "), href.string()));
+ });
+}
+
std::unique_ptr<LinkPreloadResourceClient> LinkLoader::preloadIfNeeded(const LinkRelAttribute& relAttribute, const URL& href, Document& document, const String& as, const String& media, const String& mimeType, const String& crossOriginMode, LinkLoader* loader)
{
if (!document.loader() || !relAttribute.isLinkPreload)
@@ -259,23 +280,8 @@
document.frame()->loader().client().prefetchDNS(href.host());
}
- if (relAttribute.isLinkPreconnect && href.isValid() && href.protocolIsInHTTPFamily() && document.frame()) {
- ASSERT(document.settings().linkPreconnectEnabled());
- StoredCredentialsPolicy storageCredentialsPolicy = StoredCredentialsPolicy::Use;
- if (equalIgnoringASCIICase(crossOrigin, "anonymous") && document.securityOrigin().canAccess(SecurityOrigin::create(href)))
- storageCredentialsPolicy = StoredCredentialsPolicy::DoNotUse;
- ASSERT(document.frame()->loader().networkingContext());
- platformStrategies()->loaderStrategy()->preconnectTo(*document.frame()->loader().networkingContext(), href, storageCredentialsPolicy, [weakDocument = document.createWeakPtr(), href](ResourceError error) {
- if (!weakDocument)
- return;
+ preconnectIfNeeded(relAttribute, href, document, crossOrigin);
- if (!error.isNull())
- weakDocument->addConsoleMessage(MessageSource::Network, MessageLevel::Error, makeString(ASCIILiteral("Failed to preconnect to "), href.string(), ASCIILiteral(". Error: "), error.localizedDescription()));
- else
- weakDocument->addConsoleMessage(MessageSource::Network, MessageLevel::Info, makeString(ASCIILiteral("Successfuly preconnected to "), href.string()));
- });
- }
-
if (m_client.shouldLoadLink()) {
auto resourceClient = preloadIfNeeded(relAttribute, href, document, as, media, mimeType, crossOrigin, this);
if (resourceClient)
Modified: trunk/Source/WebCore/loader/LinkLoader.h (227234 => 227235)
--- trunk/Source/WebCore/loader/LinkLoader.h 2018-01-19 22:12:23 UTC (rev 227234)
+++ trunk/Source/WebCore/loader/LinkLoader.h 2018-01-19 22:16:21 UTC (rev 227235)
@@ -64,6 +64,7 @@
private:
void notifyFinished(CachedResource&) override;
+ static void preconnectIfNeeded(const LinkRelAttribute&, const URL& href, Document&, const String& crossOrigin);
static std::unique_ptr<LinkPreloadResourceClient> preloadIfNeeded(const LinkRelAttribute&, const URL& href, Document&, const String& as, const String& media, const String& type, const String& crossOriginMode, LinkLoader*);
LinkLoaderClient& m_client;