Title: [93326] trunk
Revision
93326
Author
[email protected]
Date
2011-08-18 11:41:28 -0700 (Thu, 18 Aug 2011)

Log Message

Revalidate expired resources if they're requested after the initial document load
https://bugs.webkit.org/show_bug.cgi?id=52153

Reviewed by Antti Koivisto.

Source/WebCore:

Test: http/tests/cache/subresource-multiple-instances.html

* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::determineRevalidationPolicy):

LayoutTests:

* http/tests/cache/subresource-multiple-instances-expected.txt: Added.
* http/tests/cache/subresource-multiple-instances.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (93325 => 93326)


--- trunk/LayoutTests/ChangeLog	2011-08-18 18:29:25 UTC (rev 93325)
+++ trunk/LayoutTests/ChangeLog	2011-08-18 18:41:28 UTC (rev 93326)
@@ -1,3 +1,13 @@
+2011-08-18  James Simonsen  <[email protected]>
+
+        Revalidate expired resources if they're requested after the initial document load
+        https://bugs.webkit.org/show_bug.cgi?id=52153
+
+        Reviewed by Antti Koivisto.
+
+        * http/tests/cache/subresource-multiple-instances-expected.txt: Added.
+        * http/tests/cache/subresource-multiple-instances.html: Added.
+
 2011-08-18  Tony Chang  <[email protected]>
 
         [chromium] Marking tests needing win/linux baselines as such in

Added: trunk/LayoutTests/http/tests/cache/subresource-multiple-instances-expected.txt (0 => 93326)


--- trunk/LayoutTests/http/tests/cache/subresource-multiple-instances-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/cache/subresource-multiple-instances-expected.txt	2011-08-18 18:41:28 UTC (rev 93326)
@@ -0,0 +1,11 @@
+Verifies that resources are loaded only once during the initial document load, but are reloaded if they are requested again later and can not be cached.
+
+PASS firstRandomNumber is non-zero.
+PASS secondRandomNumber is non-zero.
+PASS thirdRandomNumber is non-zero.
+PASS firstRandomNumber == secondRandomNumber is true
+PASS firstRandomNumber != thirdRandomNumber is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/cache/subresource-multiple-instances.html (0 => 93326)


--- trunk/LayoutTests/http/tests/cache/subresource-multiple-instances.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/cache/subresource-multiple-instances.html	2011-08-18 18:41:28 UTC (rev 93326)
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>Test Caching "no-store" For History Only</title>
+<script src=""
+</head>
+<body>
+<p>Verifies that resources are loaded only once during the initial document
+load, but are reloaded if they are requested again later and can not be cached.
+</p>
+<pre id="console"></pre>
+<script>
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+}
+var randomNumber = 0;
+var firstRandomNumber = 0;
+var secondRandomNumber = 0;
+var thirdRandomNumber = 0;
+function firstLoaded() {
+    firstRandomNumber = randomNumber;
+    var newScript = document.createElement("script");
+    newScript.src = ""
+    newScript._onload_ = secondLoaded;
+    document.getElementsByTagName("head")[0].appendChild(newScript);
+}
+function secondLoaded() {
+    secondRandomNumber = randomNumber;
+}
+function loadNextScript() {
+    var newScript = document.createElement("script");
+    newScript.src = ""
+    newScript._onload_ = thirdLoaded;
+    document.getElementsByTagName("head")[0].appendChild(newScript);
+}
+function thirdLoaded() {
+    thirdRandomNumber = randomNumber;
+    shouldBeNonZero("firstRandomNumber");
+    shouldBeNonZero("secondRandomNumber");
+    shouldBeNonZero("thirdRandomNumber");
+    shouldBeTrue("firstRandomNumber == secondRandomNumber");
+    shouldBeTrue("firstRandomNumber != thirdRandomNumber");
+    finishJSTest();
+}
+window.addEventListener("load", function() { setTimeout(loadNextScript, 0); }, false);
+var jsTestIsAsync = true;
+var successfullyParsed = true;
+</script>
+<script src="" _onload_="firstLoaded()" async></script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (93325 => 93326)


--- trunk/Source/WebCore/ChangeLog	2011-08-18 18:29:25 UTC (rev 93325)
+++ trunk/Source/WebCore/ChangeLog	2011-08-18 18:41:28 UTC (rev 93326)
@@ -1,3 +1,15 @@
+2011-08-18  James Simonsen  <[email protected]>
+
+        Revalidate expired resources if they're requested after the initial document load
+        https://bugs.webkit.org/show_bug.cgi?id=52153
+
+        Reviewed by Antti Koivisto.
+
+        Test: http/tests/cache/subresource-multiple-instances.html
+
+        * loader/cache/CachedResourceLoader.cpp:
+        (WebCore::CachedResourceLoader::determineRevalidationPolicy):
+
 2011-08-18  Anders Carlsson  <[email protected]>
 
         Fix clang libc++ C++0x build

Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp (93325 => 93326)


--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp	2011-08-18 18:29:25 UTC (rev 93325)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp	2011-08-18 18:41:28 UTC (rev 93326)
@@ -474,10 +474,10 @@
         return Reload;
     }
 
-    // Avoid loading the same resource multiple times for a single document, even if the cache policies would tell us to.
-    if (m_validatedURLs.contains(existingResource->url()))
+    // During the initial load, avoid loading the same resource multiple times for a single document, even if the cache policies would tell us to.
+    if (!document()->loadEventFinished() && m_validatedURLs.contains(existingResource->url()))
         return Use;
-    
+
     // CachePolicyReload always reloads
     if (cachePolicy() == CachePolicyReload) {
         LOG(ResourceLoading, "CachedResourceLoader::determineRevalidationPolicy reloading due to CachePolicyReload.");
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to