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