vertical-scroll-disabled-frame-no-scroll-manual.tentative.html (3342B)
1 <!doctype html> 2 <meta name="timeout" content="long"> 3 <title>vertical-scroll test for touch-action</title> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <script src="/permissions-policy/experimental-features/resources/common.js"></script> 7 <script src="/permissions-policy/experimental-features/resources/vertical-scroll.js"></script> 8 <style> 9 html, body { 10 height: 100%; 11 width: 100%; 12 } 13 14 iframe { 15 width: 90%; 16 height: 90%; 17 margin: 0; 18 padding: 0; 19 } 20 21 .spacer { 22 width: 100%; 23 height: 100%; 24 margin: 100%; 25 } 26 </style> 27 <iframe></iframe> 28 <br/> 29 <p>Spacers below to make page scrollable</p> 30 <br/> 31 <div class="spacer"></div> 32 <div class="spacer"></div> 33 <p> EOF </p> 34 35 <script> 36 "use strict"; 37 38 let url = url_base + "vertical-scroll-scrollable-content.html"; 39 let iframeElement = document.querySelector("iframe"); 40 41 // Wait for the helper scripts to load. 42 promise_test(async() => { 43 if (window.input_api_ready) 44 return Promise.resolve(); 45 await new Promise( (r) => { 46 window.resolve_on_input_api_ready = r; 47 }); 48 }, "Make sure input injection API is ready."); 49 50 // Sanity-check: Verify we can scroll using the test-API (empty <iframe>). 51 promise_test(async() => { 52 window.scrollTo(0, 0); 53 54 await inject_input("down"); 55 assert_greater_than(window.scrollY, 0, "Page must have scrolled down."); 56 57 await inject_input("right"); 58 assert_greater_than(window.scrollX, 0, "Page must have scrolled right."); 59 }, "Verify that the page normally scrolls."); 60 61 // Sanity-check: <iframe> normally scrolls. 62 promise_test(async() => { 63 // Make sure <window> can scroll both towards right and bottom. 64 window.scrollTo(0, 0); 65 66 await loadUrlInIframe(iframeElement, url); 67 iframeElement.contentWindow.scrollTo(0, 0); 68 69 await inject_input("down"); 70 assert_greater_than( 71 iframeElement.contentWindow.scrollY, 72 0, 73 "<iframe> must have scrolled down."); 74 75 76 // Apply the scroll gesture. 77 await inject_input("right"); 78 assert_greater_than( 79 iframeElement.contentWindow.scrollX, 80 0, 81 "<iframe> must have scrolled right."); 82 83 }, "Verify that the <iframe> normally scrolls."); 84 85 // Disable 'vertical-scroll': <iframe> should only scroll horizontally. 86 promise_test(async() => { 87 window.scrollTo(0, 0); 88 89 // Disallow vertical scroll and reload the <iframe>. 90 setFeatureState(iframeElement, "vertical-scroll", "'none'"); 91 await loadUrlInIframe(iframeElement, url); 92 iframeElement.contentWindow.scrollTo(0, 0); 93 94 // Apply the scroll gesture. Main frame should and <iframe> should not 95 // scroll vertically. 96 await inject_input("down"); 97 assert_equals(iframeElement.contentWindow.scrollY, 98 0, 99 "<iframe> must not scroll vertically."); 100 assert_greater_than(window.scrollY, 101 0, 102 "Page must scroll vertically."); 103 104 window.scrollTo(0, 0); 105 iframeElement.contentWindow.scrollTo(0, 0); 106 107 await inject_input("right"); 108 assert_greater_than(iframeElement.contentWindow.scrollX, 109 0, 110 "<iframe> must have scrolled right."); 111 }, "When 'vertical-scroll' is disabled in a document, scrollable contents " + 112 "can only *horizontally* scroll."); 113 </script>