blob: 04b7bd6cf28b730a47faa16dfbaa61dc75fb27ac [file] [log] [blame]
<!-- webkit-test-runner [ enableBackForwardCache=true ] -->
<!DOCTYPE html>
<html>
<body>
<script src="../../resources/js-test-pre.js"></script>
<script>
description('Tests that notifications do not prevent the Page from entering page cache if they are idle or closed.');
window.jsTestIsAsync = true;
if (window.testRunner)
testRunner.grantWebNotificationPermission("file://");
window.addEventListener("pageshow", function(event) {
debug("pageshow - " + (event.persisted ? "" : "not ") + "from cache");
if (event.persisted) {
testPassed("Page did enter and was restored from the page cache");
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() {
// This notification is shown and should be suspendable once it is closed.
notification = new Notification('title', { body: 'body' });
notification.ondisplay = function() {
// Close the notification.
setTimeout(function() {
notification.close();
}, 0);
};
notification.onerror = function() {
testFailed("Could not display the notification");
finishJSTest();
};
notification.onclose = function() {
setTimeout(function() {
// Force a back navigation back to this page.
window.location.href = "resources/page-cache-helper.html";
}, 0);
};
}, false);
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>