blob: bdbb17f94ba0337ccc133124dbd34af26acc4949 [file] [log] [blame]
<!-- webkit-test-runner [ UsesBackForwardCache=true ] -->
<!DOCTYPE html>
<html>
<body>
<script src="../../resources/js-test-pre.js"></script>
<script>
description('Tests that a page with an open IndexedDB database goes into the page cache.');
window.jsTestIsAsync = true;
window.addEventListener("pageshow", function(event) {
debug("pageshow - " + (event.persisted ? "" : "not ") + "from cache");
if (!window.sessionStorage.page_cache_open_indexeddb_test_started)
return;
delete window.sessionStorage.page_cache_open_indexeddb_test_started;
if (event.persisted)
testPassed("Page did enter and was restored from the page cache");
else
testFailed("Page was not restored from page cache");
finishJSTest();
}, false);
window.addEventListener("pagehide", function(event) {
debug("pagehide - " + (event.persisted ? "" : "not ") + "entering cache");
if (!event.persisted) {
testFailed("Page failed to enter the page cache.");
finishJSTest();
}
}, false);
window.addEventListener('load', function() {
// Open the database.
var request = indexedDB.open("Page Cache Test");
request.onerror = function(event) {
testFailed("Could not open the database");
finishJSTest();
}
request.onsuccess = function(event) {
db = event.target.result;
// Force a back navigation back to this page.
window.sessionStorage.page_cache_open_indexeddb_test_started = true;
window.location.href = "resources/page-cache-helper.html";
}
}, false);
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>