Title: [181188] branches/safari-600.1.4.15-branch

Diff

Modified: branches/safari-600.1.4.15-branch/LayoutTests/ChangeLog (181187 => 181188)


--- branches/safari-600.1.4.15-branch/LayoutTests/ChangeLog	2015-03-06 23:08:10 UTC (rev 181187)
+++ branches/safari-600.1.4.15-branch/LayoutTests/ChangeLog	2015-03-06 23:13:53 UTC (rev 181188)
@@ -1,3 +1,21 @@
+2015-03-06  Lucas Forschler  <lforsch...@apple.com>
+
+        Merge r180337
+
+    2015-02-18  Andreas Kling  <akl...@apple.com>
+
+            REGRESSION(r179347): Clearing the PageCache no longer clears the PageCache.
+            <https://webkit.org/b/141788>
+
+            Reviewed by Anders Carlsson.
+
+            Add a simple test that navigates to a temporary page which immediately does a history.back
+            navigation. Upon returning to the first page, check that the page cache now has 1 entry,
+            and that clearing the page cache makes that entry go away.
+
+            * fast/history/page-cache-clearing-expected.txt: Added.
+            * fast/history/page-cache-clearing.html: Added.
+
 2015-02-26  Babak Shafiei  <bshaf...@apple.com>
 
        Merge r173806.

Copied: branches/safari-600.1.4.15-branch/LayoutTests/fast/history/page-cache-clearing-expected.txt (from rev 180337, trunk/LayoutTests/fast/history/page-cache-clearing-expected.txt) (0 => 181188)


--- branches/safari-600.1.4.15-branch/LayoutTests/fast/history/page-cache-clearing-expected.txt	                        (rev 0)
+++ branches/safari-600.1.4.15-branch/LayoutTests/fast/history/page-cache-clearing-expected.txt	2015-03-06 23:13:53 UTC (rev 181188)
@@ -0,0 +1,13 @@
+Tests that clearing the page cache doesn't leave pages in the cache.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+pageshow - not from cache
+pagehide - entering cache
+pageshow - from cache
+Cached page count before clearing: 1
+Clearing the page cache
+Cached page count after clearing: 0
+PASS
+

Copied: branches/safari-600.1.4.15-branch/LayoutTests/fast/history/page-cache-clearing.html (from rev 180337, trunk/LayoutTests/fast/history/page-cache-clearing.html) (0 => 181188)


--- branches/safari-600.1.4.15-branch/LayoutTests/fast/history/page-cache-clearing.html	                        (rev 0)
+++ branches/safari-600.1.4.15-branch/LayoutTests/fast/history/page-cache-clearing.html	2015-03-06 23:13:53 UTC (rev 181188)
@@ -0,0 +1,61 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+description("Tests that clearing the page cache doesn't leave pages in the cache.");
+
+if (!window.internals)
+    debug("This test requires window.internals");
+
+window.addEventListener("pageshow", function(event) {
+    debug("pageshow - " + (event.persisted ? "" : "not ") + "from cache");
+    if (event.persisted) {
+        var cachedPageCountBefore = window.internals.pageCacheSize();
+        debug("Cached page count before clearing: " + cachedPageCountBefore);
+        debug("Clearing the page cache");
+        window.internals.clearPageCache();
+        var cachedPageCountAfter = window.internals.pageCacheSize();
+        debug("Cached page count after clearing: " + cachedPageCountAfter);
+        if (cachedPageCountBefore != 0 && cachedPageCountAfter == 0)
+            debug("PASS");
+        else
+            debug("FAIL");
+        finishJSTest();
+        window.testRunner.notifyDone();
+    }
+}, false);
+
+window.addEventListener("pagehide", function(event) {
+    debug("pagehide - " + (event.persisted ? "" : "not ") + "entering cache");
+    if (!event.persisted) {
+        debug("FAIL - Page did not enter the page cache.");
+        finishJSTest();
+        window.testRunner.notifyDone();
+    }
+}, false);
+
+window.addEventListener('load', function() {
+
+    // Enable the PageCache and make this an async test.
+    if (window.testRunner) {
+        window.testRunner.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
+        window.testRunner.waitUntilDone();
+    }
+
+    // Force a back navigation back to this page.
+    setTimeout(function() {
+        window.location.href = ""
+    }, 0);
+
+}, false);
+
+var successfullyParsed = true;
+var jsTestIsAsync = true;
+</script>
+</body>
+</html>

Modified: branches/safari-600.1.4.15-branch/Source/WebCore/ChangeLog (181187 => 181188)


--- branches/safari-600.1.4.15-branch/Source/WebCore/ChangeLog	2015-03-06 23:08:10 UTC (rev 181187)
+++ branches/safari-600.1.4.15-branch/Source/WebCore/ChangeLog	2015-03-06 23:13:53 UTC (rev 181188)
@@ -1,3 +1,36 @@
+2015-03-06  Lucas Forschler  <lforsch...@apple.com>
+
+        Merge r180337
+
+    2015-02-18  Andreas Kling  <akl...@apple.com>
+
+            REGRESSION(r179347): Clearing the PageCache no longer clears the PageCache.
+            <https://webkit.org/b/141788>
+
+            Reviewed by Anders Carlsson.
+
+            Once again we've fallen into the TemporaryChange trap:
+
+                TemporaryChange<unsigned>(m_member, temporaryValue);
+
+            The code above doesn't actually do anything. Since the TemporaryChange local is not named,
+            it immediately goes out of scope and restores the original value of m_member.
+
+            Unless someone knows a C++ trick to prevent these, we'll need to add a style checker pass
+            to catch bugs like this. Whatever we do will be done separately from this bug.
+
+            Test: fast/history/page-cache-clearing.html
+
+            * history/PageCache.cpp:
+            (WebCore::PageCache::pruneToSizeNow): Name the local so it lives longer.
+
+            * testing/Internals.cpp:
+            (WebCore::Internals::clearPageCache):
+            (WebCore::Internals::pageCacheSize):
+            * testing/Internals.h:
+            * testing/Internals.idl: Add a way to clear the page cache and query its size from
+            window.internals to facilitate writing a simple test for this bug.
+
 2015-03-05  Dean Jackson  <d...@apple.com>
 
         Merge r180906. <rdar://problem/20058845>

Modified: branches/safari-600.1.4.15-branch/Source/WebCore/history/PageCache.cpp (181187 => 181188)


--- branches/safari-600.1.4.15-branch/Source/WebCore/history/PageCache.cpp	2015-03-06 23:08:10 UTC (rev 181187)
+++ branches/safari-600.1.4.15-branch/Source/WebCore/history/PageCache.cpp	2015-03-06 23:13:53 UTC (rev 181188)
@@ -386,7 +386,7 @@
 
 void PageCache::pruneToCapacityNow(int capacity, PruningReason pruningReason)
 {
-    TemporaryChange<int>(m_capacity, std::max(capacity, 0));
+    TemporaryChange<int> change(m_capacity, std::max(capacity, 0));
     prune(pruningReason);
 }
 

Modified: branches/safari-600.1.4.15-branch/Source/WebCore/testing/Internals.cpp (181187 => 181188)


--- branches/safari-600.1.4.15-branch/Source/WebCore/testing/Internals.cpp	2015-03-06 23:08:10 UTC (rev 181187)
+++ branches/safari-600.1.4.15-branch/Source/WebCore/testing/Internals.cpp	2015-03-06 23:13:53 UTC (rev 181188)
@@ -76,6 +76,7 @@
 #include "MemoryCache.h"
 #include "MemoryInfo.h"
 #include "Page.h"
+#include "PageCache.h"
 #include "PrintContext.h"
 #include "PseudoElement.h"
 #include "Range.h"
@@ -368,6 +369,16 @@
 }
 
 
+void Internals::clearPageCache()
+{
+    pageCache()->pruneToCapacityNow(0, PruningReason::None);
+}
+
+unsigned Internals::pageCacheSize() const
+{
+    return pageCache()->pageCount();
+}
+
 Node* Internals::treeScopeRootNode(Node* node, ExceptionCode& ec)
 {
     if (!node) {

Modified: branches/safari-600.1.4.15-branch/Source/WebCore/testing/Internals.h (181187 => 181188)


--- branches/safari-600.1.4.15-branch/Source/WebCore/testing/Internals.h	2015-03-06 23:08:10 UTC (rev 181187)
+++ branches/safari-600.1.4.15-branch/Source/WebCore/testing/Internals.h	2015-03-06 23:13:53 UTC (rev 181188)
@@ -80,6 +80,9 @@
     bool isPreloaded(const String& url);
     bool isLoadingFromMemoryCache(const String& url);
 
+    void clearPageCache();
+    unsigned pageCacheSize() const;
+
     PassRefPtr<CSSComputedStyleDeclaration> computedStyleIncludingVisitedInfo(Node*, ExceptionCode&) const;
 
     Node* ensureShadowRoot(Element* host, ExceptionCode&);

Modified: branches/safari-600.1.4.15-branch/Source/WebCore/testing/Internals.idl (181187 => 181188)


--- branches/safari-600.1.4.15-branch/Source/WebCore/testing/Internals.idl	2015-03-06 23:08:10 UTC (rev 181187)
+++ branches/safari-600.1.4.15-branch/Source/WebCore/testing/Internals.idl	2015-03-06 23:13:53 UTC (rev 181188)
@@ -36,6 +36,9 @@
     boolean isPreloaded(DOMString url);
     boolean isLoadingFromMemoryCache(DOMString url);
 
+    void clearPageCache();
+    unsigned int pageCacheSize();
+
     [RaisesException] CSSStyleDeclaration computedStyleIncludingVisitedInfo(Node node);
 
     [RaisesException] Node ensureShadowRoot(Element host);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to