Home | History | Annotate | Download | only in ManualTests
      1 <html>
      2 <head>
      3     <meta name="viewport" content="width=700">
      4     <script>
      5         var originalViewportWidth;
      6 
      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>";
     10             else
     11                 document.body.innerHTML = "<div style='color:red'>FAIL, viewport width is different after history navigation.</div>";
     12         }
     13 
     14         function navigateAwayAndBack() {
     15             // Force layout before getting viewport width.
     16             document.body.offsetTop;
     17             originalViewportWidth = window.innerWidth;
     18 
     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);
     26 
     27         }
     28     </script>
     29 </head>
     30 <body onload='setTimeout("navigateAwayAndBack()", 0 );'>
     31     <a id='anchor' href='data:text/html,
     32         
     33             
     34                 
     35             
     36             document.body.offsetTop; history.back();">
     37         '>
     38     </a>
     39 </body>
     40 </html>
     41