Log Message
Support for preconnect Link headers https://bugs.webkit.org/show_bug.cgi?id=181657
Reviewed by Darin Adler. Source/WebCore: 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: LayoutTests: 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/win/TestExpectations: Skipped the preconnect test directory, rather than the individual files in it.
Modified Paths
- trunk/LayoutTests/ChangeLog
- trunk/LayoutTests/platform/win/TestExpectations
- trunk/Source/WebCore/ChangeLog
- trunk/Source/WebCore/loader/LinkLoader.cpp
- trunk/Source/WebCore/loader/LinkLoader.h
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (229307 => 229308)
--- trunk/LayoutTests/ChangeLog 2018-03-06 05:59:08 UTC (rev 229307)
+++ trunk/LayoutTests/ChangeLog 2018-03-06 06:59:34 UTC (rev 229308)
@@ -1,3 +1,17 @@
+2018-03-05 Yoav Weiss <y...@yoav.ws>
+
+ 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/win/TestExpectations: Skipped the preconnect test directory, rather than the individual files in it.
+
2018-03-05 Ryan Haddad <ryanhad...@apple.com>
Mark imported/w3c/web-platform-tests/service-workers/service-worker/registration-updateviacache.https.html as slow.
Added: trunk/LayoutTests/http/tests/preconnect/link-header-rel-preconnect-http-expected.txt (0 => 229308)
--- 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-03-06 06:59:34 UTC (rev 229308)
@@ -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 => 229308)
--- 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-03-06 06:59:34 UTC (rev 229308)
@@ -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 => 229308)
--- trunk/LayoutTests/http/tests/preconnect/resources/header-preconnect.php (rev 0)
+++ trunk/LayoutTests/http/tests/preconnect/resources/header-preconnect.php 2018-03-06 06:59:34 UTC (rev 229308)
@@ -0,0 +1,3 @@
+<?php
+ header('Link: <http://localhost:8000>; rel=preconnect');
+?>
Modified: trunk/LayoutTests/platform/win/TestExpectations (229307 => 229308)
--- trunk/LayoutTests/platform/win/TestExpectations 2018-03-06 05:59:08 UTC (rev 229307)
+++ trunk/LayoutTests/platform/win/TestExpectations 2018-03-06 06:59:34 UTC (rev 229308)
@@ -3795,8 +3795,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 (229307 => 229308)
--- trunk/Source/WebCore/ChangeLog 2018-03-06 05:59:08 UTC (rev 229307)
+++ trunk/Source/WebCore/ChangeLog 2018-03-06 06:59:34 UTC (rev 229308)
@@ -1,3 +1,21 @@
+2018-03-05 Yoav Weiss <y...@yoav.ws>
+
+ 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-03-05 Antti Koivisto <an...@apple.com>
Add ChildrenAffectedByForwardPositionalRules bit for nth-child pseudo class marking
Modified: trunk/Source/WebCore/loader/LinkLoader.cpp (229307 => 229308)
--- trunk/Source/WebCore/loader/LinkLoader.cpp 2018-03-06 05:59:08 UTC (rev 229307)
+++ trunk/Source/WebCore/loader/LinkLoader.cpp 2018-03-06 06:59:34 UTC (rev 229308)
@@ -107,6 +107,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);
}
}
@@ -208,6 +209,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(), 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(), 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 (229307 => 229308)
--- trunk/Source/WebCore/loader/LinkLoader.h 2018-03-06 05:59:08 UTC (rev 229307)
+++ trunk/Source/WebCore/loader/LinkLoader.h 2018-03-06 06:59:34 UTC (rev 229308)
@@ -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;
_______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-changes