blob: 4d10c5a965f5fc54f6d4ebb02106bb110adf450d [file] [log] [blame]
<!DOCTYPE html>
<html>
<body>
<script src="../../resources/js-test-pre.js"></script>
<script>
description("Tests that clearing the page cache doesn't leave pages in the cache.");
window.jsTestIsAsync = true;
// Enable page cache.
if (window.testRunner)
window.testRunner.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
if (!window.internals)
debug("This test requires window.internals");
window.addEventListener("pageshow", function(event) {
debug("pageshow - " + (event.persisted ? "" : "not ") + "from cache");
if (event.persisted) {
shouldBe("window.internals.pageCacheSize()", "1");
evalAndLog("window.internals.clearPageCache()");
shouldBe("window.internals.pageCacheSize()", "0");
finishJSTest();
}
}, false);
window.addEventListener("pagehide", function(event) {
debug("pagehide - " + (event.persisted ? "" : "not ") + "entering cache");
if (!event.persisted) {
testFailed("Page did not enter the page cache.");
finishJSTest();
}
}, false);
window.addEventListener('load', function() {
// Force a back navigation back to this page.
setTimeout(function() {
window.location.href = "resources/page-cache-helper.html";
}, 0);
}, false);
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>