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