blob: 8ac3ab3c8b580677fdb7d65abdddfe3717195703 [file] [log] [blame]
adachan@apple.com88b0ce72009-08-24 20:16:00 +00001<html>
2<script>
3
4// Navigation steps:
5// 1- loads this page
6// 2- resizes the window to (300, 300)
7// 3- loads a data URL that resizes the window to (1000, 1000) and navigates back
8// 4- loads this page which will restore the timer to check the window width to make sure it's > 300
9function verifyWindowSizeAfterNavigateBackToCachedPage() {
10 document.body.innerHTML = (window.innerWidth > 300) ? 'PASS' : 'FAIL';
rniwa@webkit.org08372332012-06-15 07:33:22 +000011 if (window.testRunner)
12 testRunner.notifyDone();
adachan@apple.com88b0ce72009-08-24 20:16:00 +000013}
14
15function navigateAwayAndBack() {
16 // Assigning to location does not create a history entry, so
17 // instead we simulate a link click.
18 var evt = document.createEvent("MouseEvents");
19 evt.initMouseEvent("click", true, true, window,
20 0, 0, 0, 0, 0, false, false, false, false, 0, null);
21 document.getElementById('anchor').dispatchEvent(evt);
22 // Wait a long while so the verification is done after we have navigated back to the cached version of this page.
23 // This test makes use of the behavior where timers are restored on a cached page.
24 // We don't need to depend on this long timer when pageshow event is implemented for b/f cache (<rdar://problem/6440869>).
25 window.setTimeout("verifyWindowSizeAfterNavigateBackToCachedPage()", 1000);
26}
27
28function runTestStep() {
rniwa@webkit.org08372332012-06-15 07:33:22 +000029 if (window.testRunner) {
30 testRunner.dumpAsText();
31 testRunner.waitUntilDone();
32 testRunner.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
adachan@apple.com88b0ce72009-08-24 20:16:00 +000033 }
34 window.resizeTo(300, 300);
35 // Wait a bit before navigating away to make sure we have done layout due to the resizing.
36 window.setTimeout("navigateAwayAndBack()", 200);
37}
38
39</script>
40<body onload='runTestStep()' style="background: yellow">
41 <a id='anchor' href='data:text/html,<body onload="window.resizeTo(1000, 1000); history.back()"></body>'>go away, resize window, and come back</a>
42</body>
43</html>