viewport-unscaled-scroll.html (1983B)
1 <!doctype html> 2 <html> 3 <head> 4 <title>Viewport: Scroll - no page scale</title> 5 <meta charset="utf-8"> 6 <meta name="viewport" content="width=device-width, minimum-scale=1"> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 <script src="viewport_support.js"></script> 10 </head> 11 <body> 12 <h1>Viewport: Scroll - no page scale</h1> 13 <h4>Test Description: This test checks that window.visualViewport returns correct offset and scroll values without any pinch-zoom page scale applied.</h4> 14 <div id="complete-notice"> 15 <p>window.visualViewport's offsetLeft and offsetTop is (<span id="scroll-offset-log"></span>).</p> 16 <p>window.visualViewport's pageLeft and pageTop is (<span id="scroll-page-log"></span>).</p> 17 </div> 18 <div id="log"></div> 19 </body> 20 <script> 21 // Add overflow we can scroll. 22 document.body.style.width = "5000px"; 23 document.body.style.height = "5000px"; 24 25 scrollTo(1000, 1200); 26 27 test(function() { 28 assert_equals(window.visualViewport.offsetLeft, 0); 29 }, "offsetLeft must be 0."); 30 test(function() { 31 assert_equals(window.visualViewport.offsetTop, 0); 32 }, "offsetTop must be 0."); 33 test(function() { 34 assert_equals(window.visualViewport.pageLeft, 1000); 35 }, "pageLeft must reflect location of viewport in document."); 36 test(function() { 37 assert_equals(window.visualViewport.pageTop, 1200); 38 }, "pageTop must reflect location of viewport in document."); 39 40 document.getElementById("scroll-offset-log").innerText = window.visualViewport.offsetLeft+ ", " + window.visualViewport.offsetTop; 41 document.getElementById("scroll-page-log").innerText = window.visualViewport.pageLeft + ", " + window.visualViewport.pageTop; 42 43 scrollTo(0, 0); 44 </script> 45 </html>