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';
11 if (window.layoutTestController)
12 layoutTestController.notifyDone();
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);
28 function runTestStep() {
29 if (window.layoutTestController) {
30 layoutTestController.dumpAsText();
31 layoutTestController.waitUntilDone();
32 layoutTestController.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
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);
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>