- Revision
- 89982
- Author
- [email protected]
- Date
- 2011-06-28 18:03:18 -0700 (Tue, 28 Jun 2011)
Log Message
2011-06-28 Adam Langley <[email protected]>
Reviewed by Adam Barth.
Skip cache validation on back with HTTPS.
https://bugs.webkit.org/show_bug.cgi?id=63537
* http/tests/cache/history-only-cached-subresource-loads-max-age-https-expected.txt: Added.
* http/tests/cache/history-only-cached-subresource-loads-max-age-https.html: Added.
* http/tests/cache/resources/max-age-resource-forward.html: Added.
* http/tests/cache/resources/max-age-resource-next.html: Added.
* http/tests/cache/resources/max-age-resource.html: Added.
* http/tests/cache/resources/random-max-age.cgi: Added.
2011-06-28 Adam Langley <[email protected]>
Reviewed by Adam Barth.
Skip cache validation on back with HTTPS.
https://bugs.webkit.org/show_bug.cgi?id=63537
For back navigations over HTTP, WebKit sets a flag to use cached data
irrespective of whether it has expired. However, this isn't currently
done for HTTPS.
The logic in question was added in
https://bugs.webkit.org/show_bug.cgi?id=33993 and appears to have been
precautionary. However, both Firefox and IE will use this back
navigation trick for HTTPS as well and so we should probably behave
likewise.
Test: http/tests/cache/history-only-cached-subresource-loads-max-age-https.html
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::addExtraFieldsToRequest):
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (89981 => 89982)
--- trunk/LayoutTests/ChangeLog 2011-06-29 00:58:45 UTC (rev 89981)
+++ trunk/LayoutTests/ChangeLog 2011-06-29 01:03:18 UTC (rev 89982)
@@ -1,3 +1,17 @@
+2011-06-28 Adam Langley <[email protected]>
+
+ Reviewed by Adam Barth.
+
+ Skip cache validation on back with HTTPS.
+ https://bugs.webkit.org/show_bug.cgi?id=63537
+
+ * http/tests/cache/history-only-cached-subresource-loads-max-age-https-expected.txt: Added.
+ * http/tests/cache/history-only-cached-subresource-loads-max-age-https.html: Added.
+ * http/tests/cache/resources/max-age-resource-forward.html: Added.
+ * http/tests/cache/resources/max-age-resource-next.html: Added.
+ * http/tests/cache/resources/max-age-resource.html: Added.
+ * http/tests/cache/resources/random-max-age.cgi: Added.
+
2011-06-27 Diego Gonzalez <[email protected]>
Reviewed by Kenneth Rohde Christiansen.
Added: trunk/LayoutTests/http/tests/cache/history-only-cached-subresource-loads-max-age-https-expected.txt (0 => 89982)
--- trunk/LayoutTests/http/tests/cache/history-only-cached-subresource-loads-max-age-https-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/cache/history-only-cached-subresource-loads-max-age-https-expected.txt 2011-06-29 01:03:18 UTC (rev 89982)
@@ -0,0 +1,8 @@
+This test checks that loading a subresource with "Cache-Control: max-age=0" is cached and reused in back navigation when the page is not in the page cache.
+
+We then test that loading the same subresource is refetched when used in non-stale loads such as refreshes or normal navigation.
+
+PASS - max-age subresource was cached and used for a back navigation
+PASS - max-age subresource was refetched with a reload
+PASS - max-age subresource was refetched with a normal navigation
+
Added: trunk/LayoutTests/http/tests/cache/history-only-cached-subresource-loads-max-age-https.html (0 => 89982)
--- trunk/LayoutTests/http/tests/cache/history-only-cached-subresource-loads-max-age-https.html (rev 0)
+++ trunk/LayoutTests/http/tests/cache/history-only-cached-subresource-loads-max-age-https.html 2011-06-29 01:03:18 UTC (rev 89982)
@@ -0,0 +1,89 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Test Caching "max-age" For History Only</title>
+</head>
+<body>
+ <p>
+ This test checks that loading a subresource with "Cache-Control: max-age=0" is
+ cached and reused in back navigation when the page is not in the page cache.
+ </p>
+ <p>
+ We then test that loading the same subresource is refetched when used in
+ non-stale loads such as refreshes or normal navigation.
+ </p>
+ <pre id="console"></pre>
+ <script>
+ // Asynchronous test because this requires a new window to perform multiple navigations.
+ if (window.layoutTestController) {
+ window.layoutTestController.dumpAsText();
+ window.layoutTestController.waitUntilDone();
+ window.layoutTestController.setCanOpenWindows();
+ }
+
+ // Values to check.
+ var originalRandomNumber = 0;
+ var backLoadRandomNumber = 0;
+ var refreshRandomNumber = 0;
+ var nextLoadRandomNumber = 0;
+
+ // Window we will be controlling.
+ var target;
+
+ // Pass messages between windows to control the navigation types.
+ var pre = document.getElementById('console');
+ window.addEventListener('message', function(event) {
+
+ // First time, record the first number, and tell the target window to trigger a back navigation.
+ if (!originalRandomNumber) {
+ originalRandomNumber = event.data;
+ target.postMessage('go-forward-and-back', '*');
+ return;
+ }
+
+ // Second time, record the second number. It should be identical. Also tell the target window to reload.
+ if (!backLoadRandomNumber) {
+ backLoadRandomNumber = event.data;
+ var wasCached = (backLoadRandomNumber === originalRandomNumber);
+ if (wasCached)
+ pre.appendChild(document.createTextNode('PASS - max-age subresource was cached and used for a back navigation\n'));
+ else
+ pre.appendChild(document.createTextNode('FAIL - max-age subresource should have been cached and used in a back navigation\n'));
+ target.postMessage('reload', '*');
+ return;
+ }
+
+ // Third time, record the third number. It should not match. Also tell the target window to navigate forward.
+ if (!refreshRandomNumber) {
+ refreshRandomNumber = event.data;
+ var wasCached = (refreshRandomNumber === originalRandomNumber);
+ if (wasCached)
+ pre.appendChild(document.createTextNode('FAIL - max-age subresource should have been refetched with a reload\n'));
+ else
+ pre.appendChild(document.createTextNode('PASS - max-age subresource was refetched with a reload\n'));
+ target.postMessage('next', '*');
+ return;
+ }
+
+ // Fourth time, record the fourth number. It should not match any numbers so far.
+ if (!nextLoadRandomNumber) {
+ nextLoadRandomNumber = event.data;
+ var wasCached = (nextLoadRandomNumber === originalRandomNumber || nextLoadRandomNumber === refreshRandomNumber);
+ if (wasCached)
+ pre.appendChild(document.createTextNode('FAIL - max-age subresource should have been refetched with a normal navigation\n'));
+ else
+ pre.appendChild(document.createTextNode('PASS - max-age subresource was refetched with a normal navigation\n'));
+ }
+
+ // Test completed.
+ target.close();
+ if (window.layoutTestController)
+ window.layoutTestController.notifyDone();
+
+ }, false);
+
+ // Open the target window and it will begin to send us messages.
+ target = window.open('https://127.0.0.1:8443/cache/resources/max-age-resource.html');
+ </script>
+</body>
+</html>
Added: trunk/LayoutTests/http/tests/cache/resources/max-age-resource-forward.html (0 => 89982)
--- trunk/LayoutTests/http/tests/cache/resources/max-age-resource-forward.html (rev 0)
+++ trunk/LayoutTests/http/tests/cache/resources/max-age-resource-forward.html 2011-06-29 01:03:18 UTC (rev 89982)
@@ -0,0 +1,4 @@
+<p>Now go back</p>
+<script>
+window.history.back();
+</script>
Added: trunk/LayoutTests/http/tests/cache/resources/max-age-resource-next.html (0 => 89982)
--- trunk/LayoutTests/http/tests/cache/resources/max-age-resource-next.html (rev 0)
+++ trunk/LayoutTests/http/tests/cache/resources/max-age-resource-next.html 2011-06-29 01:03:18 UTC (rev 89982)
@@ -0,0 +1,7 @@
+<h1></h1>
+<script src=""
+<script>
+// Random.cgi will include a global "randomNumber".
+// Send this back to our opener.
+opener.postMessage(randomNumber, '*');
+</script>
Added: trunk/LayoutTests/http/tests/cache/resources/max-age-resource.html (0 => 89982)
--- trunk/LayoutTests/http/tests/cache/resources/max-age-resource.html (rev 0)
+++ trunk/LayoutTests/http/tests/cache/resources/max-age-resource.html 2011-06-29 01:03:18 UTC (rev 89982)
@@ -0,0 +1,30 @@
+<h1></h1>
+<script src=""
+<script>
+// Random.cgi will include a global "randomNumber".
+// Always send this back to our opener.
+opener.postMessage(randomNumber, '*');
+
+// Our opener will tell us to perform various loads.
+window.addEventListener('message', function(event) {
+
+ // Go forward and back.
+ if (event.data ="" 'go-forward-and-back') {
+ window.location = 'max-age-resource-forward.html';
+ return;
+ }
+
+ // Reload.
+ if (event.data ="" 'reload') {
+ window.location.reload();
+ return;
+ }
+
+ // Normal navigation, next.
+ if (event.data ="" 'next') {
+ window.location = 'max-age-resource-next.html';
+ return;
+ }
+
+}, false);
+</script>
Added: trunk/LayoutTests/http/tests/cache/resources/random-max-age.cgi (0 => 89982)
--- trunk/LayoutTests/http/tests/cache/resources/random-max-age.cgi (rev 0)
+++ trunk/LayoutTests/http/tests/cache/resources/random-max-age.cgi 2011-06-29 01:03:18 UTC (rev 89982)
@@ -0,0 +1,9 @@
+#!/usr/bin/perl -w
+
+print "Content-type: text/_javascript_\n";
+print "Cache-control: max-age=0\n";
+print "\n";
+
+my $random_number = int(rand(1000000000000));
+print "randomNumber = " . $random_number . ";\n";
+print "document.querySelector('h1').textContent = randomNumber;";
Property changes on: trunk/LayoutTests/http/tests/cache/resources/random-max-age.cgi
___________________________________________________________________
Added: svn:executable
Modified: trunk/Source/WebCore/ChangeLog (89981 => 89982)
--- trunk/Source/WebCore/ChangeLog 2011-06-29 00:58:45 UTC (rev 89981)
+++ trunk/Source/WebCore/ChangeLog 2011-06-29 01:03:18 UTC (rev 89982)
@@ -1,3 +1,25 @@
+2011-06-28 Adam Langley <[email protected]>
+
+ Reviewed by Adam Barth.
+
+ Skip cache validation on back with HTTPS.
+ https://bugs.webkit.org/show_bug.cgi?id=63537
+
+ For back navigations over HTTP, WebKit sets a flag to use cached data
+ irrespective of whether it has expired. However, this isn't currently
+ done for HTTPS.
+
+ The logic in question was added in
+ https://bugs.webkit.org/show_bug.cgi?id=33993 and appears to have been
+ precautionary. However, both Firefox and IE will use this back
+ navigation trick for HTTPS as well and so we should probably behave
+ likewise.
+
+ Test: http/tests/cache/history-only-cached-subresource-loads-max-age-https.html
+
+ * loader/FrameLoader.cpp:
+ (WebCore::FrameLoader::addExtraFieldsToRequest):
+
2011-06-28 Dimitri Glazkov <[email protected]>
Reviewed by Adam Barth.
Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (89981 => 89982)
--- trunk/Source/WebCore/loader/FrameLoader.cpp 2011-06-29 00:58:45 UTC (rev 89981)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp 2011-06-29 01:03:18 UTC (rev 89982)
@@ -2467,7 +2467,7 @@
request.setCachePolicy(UseProtocolCachePolicy);
} else if (loadType == FrameLoadTypeReload || loadType == FrameLoadTypeReloadFromOrigin || request.isConditional())
request.setCachePolicy(ReloadIgnoringCacheData);
- else if (isBackForwardLoadType(loadType) && m_stateMachine.committedFirstRealDocumentLoad() && !request.url().protocolIs("https"))
+ else if (isBackForwardLoadType(loadType) && m_stateMachine.committedFirstRealDocumentLoad())
request.setCachePolicy(ReturnCacheDataElseLoad);
if (request.cachePolicy() == ReloadIgnoringCacheData) {