2010-10-08 Gavin Peters <gavinp@chromium.org>
Reviewed by Adam Barth.
Output X-Purpose header for prefetch requests
https://bugs.webkit.org/show_bug.cgi?id=46529
* http/tests/misc/prefetch-purpose-expected.txt: Added.
* http/tests/misc/prefetch-purpose.html: Added.
* http/tests/misc/resources/prefetch-purpose.php: Added.
* platform/gtk/Skipped:
* platform/mac/Skipped:
* platform/qt/Skipped:
* platform/win/Skipped:
2010-10-08 Gavin Peters <gavinp@chromium.org>
Reviewed by Adam Barth.
Output X-Purpose header for prefetch requests
https://bugs.webkit.org/show_bug.cgi?id=46529
Test: http/tests/misc/prefetch-purpose.html
* loader/loader.cpp:
(WebCore::Loader::Host::servePendingRequests):
git-svn-id: svn://svn.chromium.org/blink/trunk@69420 bbb929c8-8fbe-4397-9dbb-9b2b20218538
diff --git a/third_party/WebKit/LayoutTests/ChangeLog b/third_party/WebKit/LayoutTests/ChangeLog
index 71c6d43..8276b83 100644
--- a/third_party/WebKit/LayoutTests/ChangeLog
+++ b/third_party/WebKit/LayoutTests/ChangeLog
@@ -1,3 +1,18 @@
+2010-10-08 Gavin Peters <gavinp@chromium.org>
+
+ Reviewed by Adam Barth.
+
+ Output X-Purpose header for prefetch requests
+ https://bugs.webkit.org/show_bug.cgi?id=46529
+
+ * http/tests/misc/prefetch-purpose-expected.txt: Added.
+ * http/tests/misc/prefetch-purpose.html: Added.
+ * http/tests/misc/resources/prefetch-purpose.php: Added.
+ * platform/gtk/Skipped:
+ * platform/mac/Skipped:
+ * platform/qt/Skipped:
+ * platform/win/Skipped:
+
2010-10-08 Albert J. Wong <ajwong@chromium.org>
[chromium] Unreviewed. Build fix.
diff --git a/third_party/WebKit/LayoutTests/http/tests/misc/prefetch-purpose-expected.txt b/third_party/WebKit/LayoutTests/http/tests/misc/prefetch-purpose-expected.txt
new file mode 100644
index 0000000..68486eaf
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/misc/prefetch-purpose-expected.txt
@@ -0,0 +1,7 @@
+prefetch-purpose.php has MIME type text/html
+prefetch-purpose.php has MIME type text/html
+The cookie was set!
+
+X-Purpose: prefetch
+
+This test verifies that prefetches are sent with the HTTP request header X-Purpose: prefetch. To do this, the root page has a prefetch link targetting this subresource which contains a PHP script (resources/prefetch-purpose.php). That initial prefetch of this resource sets a cookie. Later, the root page sets window.location to target this script, which verifies the presence of the cookie, and generates the happy test output that you hopefully see right now.
diff --git a/third_party/WebKit/LayoutTests/http/tests/misc/prefetch-purpose.html b/third_party/WebKit/LayoutTests/http/tests/misc/prefetch-purpose.html
new file mode 100644
index 0000000..12f17e1
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/misc/prefetch-purpose.html
@@ -0,0 +1,20 @@
+<html>
+<head>
+<script>
+
+function finishUp() {
+ window.location = 'resources/prefetch-purpose.php';
+}
+
+if (window.layoutTestController) {
+ layoutTestController.waitUntilDone();
+ layoutTestController.dumpAsText();
+ layoutTestController.dumpResourceResponseMIMETypes();
+}
+</script>
+<link href="resources/prefetch-purpose.php" rel="prefetch">
+</head>
+<body onload="setTimeout('finishUp()', 50);">
+<p>Nothing to see here, this page should replace itself with resources/prefetch-purpose.php almost instantly.
+</body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/http/tests/misc/resources/prefetch-purpose.php b/third_party/WebKit/LayoutTests/http/tests/misc/resources/prefetch-purpose.php
new file mode 100644
index 0000000..9693eb9
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/misc/resources/prefetch-purpose.php
@@ -0,0 +1,24 @@
+<?php setcookie("X-Purpose", $_SERVER["HTTP_X_PURPOSE"]);
+
+if (isset($_COOKIE['X-Purpose'])) {
+ setcookie("X-Purpose", "", time() - 3600);
+ echo "<h1>The cookie was set!</h1>";
+ echo "<p>X-Purpose: ";
+ echo $_COOKIE['X-Purpose'];
+} else {
+ echo "<h1>BAD BROWSER NO COOKIE</h1>";
+}
+?>
+
+<script>
+layoutTestController.notifyDone();
+</script>
+
+<p>This test verifies that prefetches are sent with the HTTP request header
+<b>X-Purpose: prefetch</b>. To do this, the root page has a prefetch
+link targetting this subresource which contains a PHP script
+(resources/prefetch-purpose.php). That initial prefetch of this
+resource sets a cookie. Later, the root page sets window.location to
+target this script, which verifies the presence of the cookie, and
+generates the happy test output that you hopefully see right now.
+
diff --git a/third_party/WebKit/LayoutTests/platform/gtk/Skipped b/third_party/WebKit/LayoutTests/platform/gtk/Skipped
index 2a5706b5..ff881f6 100644
--- a/third_party/WebKit/LayoutTests/platform/gtk/Skipped
+++ b/third_party/WebKit/LayoutTests/platform/gtk/Skipped
@@ -3049,6 +3049,7 @@
http/tests/misc/acid3.html
http/tests/misc/isindex-formdata.html
http/tests/misc/policy-delegate-called-twice.html
+http/tests/misc/prefetch-purpose.html
http/tests/misc/redirect-to-external-url.html
http/tests/misc/slow-preload-cancel.html
http/tests/misc/window-dot-stop.html
diff --git a/third_party/WebKit/LayoutTests/platform/mac/Skipped b/third_party/WebKit/LayoutTests/platform/mac/Skipped
index ab039b8..4c3619f 100644
--- a/third_party/WebKit/LayoutTests/platform/mac/Skipped
+++ b/third_party/WebKit/LayoutTests/platform/mac/Skipped
@@ -233,6 +233,7 @@
# Link prefetch is disabled by default
fast/dom/HTMLLinkElement/prefetch.html
+http/tests/misc/prefetch-purpose.html
# https://bugs.webkit.org/show_bug.cgi?id=39908
fast/dom/Geolocation/maximum-age.html
diff --git a/third_party/WebKit/LayoutTests/platform/qt/Skipped b/third_party/WebKit/LayoutTests/platform/qt/Skipped
index 83f0f21..1442740a 100644
--- a/third_party/WebKit/LayoutTests/platform/qt/Skipped
+++ b/third_party/WebKit/LayoutTests/platform/qt/Skipped
@@ -5301,6 +5301,7 @@
# Link prefetch is disabled by default
fast/dom/HTMLLinkElement/prefetch.html
+http/tests/misc/prefetch-purpose.html
# [Qt] Regression(r61749): inspector/debugger-pause-on-debugger-statement.html fails
# https://bugs.webkit.org/show_bug.cgi?id=41147
diff --git a/third_party/WebKit/LayoutTests/platform/win/Skipped b/third_party/WebKit/LayoutTests/platform/win/Skipped
index 6da31e3..32933bf 100644
--- a/third_party/WebKit/LayoutTests/platform/win/Skipped
+++ b/third_party/WebKit/LayoutTests/platform/win/Skipped
@@ -916,6 +916,7 @@
# Link prefetch is disabled by default
fast/dom/HTMLLinkElement/prefetch.html
+http/tests/misc/prefetch-purpose.html
# LayoutTestController::pageProperty is not implemented for WIN yet.
printing/page-rule-selection.html
diff --git a/third_party/WebKit/WebCore/ChangeLog b/third_party/WebKit/WebCore/ChangeLog
index 6adae22..a9ce425 100644
--- a/third_party/WebKit/WebCore/ChangeLog
+++ b/third_party/WebKit/WebCore/ChangeLog
@@ -1,3 +1,15 @@
+2010-10-08 Gavin Peters <gavinp@chromium.org>
+
+ Reviewed by Adam Barth.
+
+ Output X-Purpose header for prefetch requests
+ https://bugs.webkit.org/show_bug.cgi?id=46529
+
+ Test: http/tests/misc/prefetch-purpose.html
+
+ * loader/loader.cpp:
+ (WebCore::Loader::Host::servePendingRequests):
+
2010-10-08 James Kozianski <koz@chromium.org>
Reviewed by Simon Fraser.
diff --git a/third_party/WebKit/WebCore/loader/loader.cpp b/third_party/WebKit/WebCore/loader/loader.cpp
index 8f262e2..2c8f3bd 100644
--- a/third_party/WebKit/WebCore/loader/loader.cpp
+++ b/third_party/WebKit/WebCore/loader/loader.cpp
@@ -358,6 +358,11 @@
}
}
+#if ENABLE(LINK_PREFETCH)
+ if (request->cachedResource()->type() == CachedResource::LinkPrefetch)
+ resourceRequest.setHTTPHeaderField("X-Purpose", "prefetch");
+#endif
+
RefPtr<SubresourceLoader> loader = SubresourceLoader::create(cachedResourceLoader->doc()->frame(),
this, resourceRequest, request->shouldDoSecurityCheck(), request->sendResourceLoadCallbacks());
if (loader) {