3 <meta name=
"viewport" content=
"width=700">
5 var originalViewportWidth
;
7 function checkViewportWidthAfterHistoryNavigation() {
8 if (originalViewportWidth
== window
.innerWidth
)
9 document
.body
.innerHTML
= "<div style='color:green'>PASS, viewport width is OK after history navigation.</div>";
11 document
.body
.innerHTML
= "<div style='color:red'>FAIL, viewport width is different after history navigation.</div>";
14 function navigateAwayAndBack() {
15 // Force layout before getting viewport width.
16 document
.body
.offsetTop
;
17 originalViewportWidth
= window
.innerWidth
;
19 // Assigning to window.location does not create a history entry, so instead link click is simulated.
20 var evt
= document
.createEvent("MouseEvents");
21 evt
.initMouseEvent("click", true, true, window
, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
22 document
.getElementById('anchor').dispatchEvent(evt
);
23 // Initiate timer to do final verification as we have navigated back to the cached version of this page.
24 // This test makes use of the behavior where timers are restored on a cached page.
25 setTimeout('checkViewportWidthAfterHistoryNavigation()', 1000);
30 <body onload='setTimeout(
"navigateAwayAndBack()",
0 );'
>
31 <a id='anchor' href='data:text/html,
34 <meta name=
"viewport" content=
"width=600">
36 <body onload=
"document.body.offsetTop; history.back();"></body>