Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: timelapse
Fetching contributors…

Cannot retrieve contributors at this time

41 lines (36 sloc) 1.718 kb
<meta name="viewport" content="width=700">
var originalViewportWidth;
function checkViewportWidthAfterHistoryNavigation() {
if (originalViewportWidth == window.innerWidth)
document.body.innerHTML = "<div style='color:green'>PASS, viewport width is OK after history navigation.</div>";
document.body.innerHTML = "<div style='color:red'>FAIL, viewport width is different after history navigation.</div>";
function navigateAwayAndBack() {
// Force layout before getting viewport width.
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);
// 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);
<body onload='setTimeout("navigateAwayAndBack()", 0 );'>
<a id='anchor' href='data:text/html,
<meta name="viewport" content="width=600">
<body onload="document.body.offsetTop; history.back();"></body>
Jump to Line
Something went wrong with that request. Please try again.