key-scrolling.https.html (2319B)
1 <!DOCTYPE html> 2 <title>Test keyboard scroll bubbling from a fenced frame.</title> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <script src="/resources/testdriver.js"></script> 6 <script src="/resources/testdriver-actions.js"></script> 7 <script src="/resources/testdriver-vendor.js"></script> 8 <script src="/common/utils.js"></script> 9 <script src="/common/dispatcher/dispatcher.js"></script> 10 <script src="resources/utils.js"></script> 11 <style> 12 body { 13 /* Make main frame scrollable */ 14 width: 200vw; 15 height: 200vh; 16 } 17 </style> 18 19 <body> 20 <script> 21 22 // Ensure keyboard scrolling from inside a fenced frame is bubbled out to the 23 // embedding frame. 24 promise_test(async t => { 25 const frame = attachFencedFrameContext({html: ` 26 <!DOCTYPE html> 27 <style> 28 body { 29 /* Make fenced frame scrollable */ 30 width: 200vw; 31 height: 200vh; 32 } 33 </style> 34 <script src="/resources/testdriver.js"><\/script> 35 <script src="/resources/testdriver-actions.js"><\/script> 36 <script src="/resources/testdriver-vendor.js"><\/script> 37 `}); 38 39 // Scroll the fenced frame to its full extent so that left/down arrow key 40 // scrolling will bubble to the embedder. 41 await frame.execute(async () => { 42 window.scrollTo(10000, 10000); 43 }); 44 45 assert_equals(window.scrollX, 0, '[PRECONDITION] main frame has no x scroll.'); 46 assert_equals(window.scrollY, 0, '[PRECONDITION] main frame has no y scroll.'); 47 48 // Simulate a right arrow and down arrow key in the fenced frame. 49 await frame.execute(async () => { 50 const arrow_right = "\uE014"; 51 const arrow_down = "\uE015"; 52 53 test_driver.send_keys(document.body, arrow_right); 54 test_driver.send_keys(document.body, arrow_down); 55 }); 56 57 // Use step_wait to poll since the scroll may be executed asynchronously 58 // (e.g. IPC to embedder, scroll animation). 59 await t.step_wait(() => window.scrollX > 0, "Wait for horizontal scroll."); 60 assert_greater_than(window.scrollX, 0, 'Horizontal scroll should bubble to main frame.'); 61 62 await t.step_wait(() => window.scrollY > 0, "Wait for vertical scroll."); 63 assert_greater_than(window.scrollY, 0, 'Vertical scroll should bubble to main frame.'); 64 }, 'Keyboard scrolling bubbles out of fenced frame'); 65 66 </script> 67 </body>