adachan@apple.com | 88b0ce7 | 2009-08-24 20:16:00 +0000 | [diff] [blame] | 1 | <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 |
| 9 | function verifyWindowSizeAfterNavigateBackToCachedPage() { |
| 10 | document.body.innerHTML = (window.innerWidth > 300) ? 'PASS' : 'FAIL'; |
rniwa@webkit.org | 0837233 | 2012-06-15 07:33:22 +0000 | [diff] [blame] | 11 | if (window.testRunner) |
| 12 | testRunner.notifyDone(); |
adachan@apple.com | 88b0ce7 | 2009-08-24 20:16:00 +0000 | [diff] [blame] | 13 | } |
| 14 | |
| 15 | function 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 | |
| 28 | function runTestStep() { |
rniwa@webkit.org | 0837233 | 2012-06-15 07:33:22 +0000 | [diff] [blame] | 29 | if (window.testRunner) { |
| 30 | testRunner.dumpAsText(); |
| 31 | testRunner.waitUntilDone(); |
| 32 | testRunner.overridePreference("WebKitUsesPageCachePreferenceKey", 1); |
adachan@apple.com | 88b0ce7 | 2009-08-24 20:16:00 +0000 | [diff] [blame] | 33 | } |
| 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> |