scroll-state-scrolled-home-end-scroll.html (2360B)
1 <!DOCTYPE html> 2 <title>@container: scroll-state(scrolled) Home/End keys press scroll</title> 3 <link rel="help" href="https://drafts.csswg.org/css-conditional-5/#scrolled"> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <script src="/resources/testdriver.js"></script> 7 <script src="/resources/testdriver-actions.js"></script> 8 <script src="/resources/testdriver-vendor.js"></script> 9 <script src="/css/css-conditional/container-queries/support/cq-testcommon.js"></script> 10 <script src="/css/css-transitions/support/helper.js"></script> 11 <style> 12 #scroller { 13 width: 200px; 14 height: 200px; 15 container-type: scroll-state; 16 overflow-y: scroll; 17 } 18 #filler { 19 height: 600px; 20 } 21 #target { 22 --none: no; 23 --top: no; 24 --bottom: no; 25 @container scroll-state(scrolled: none) { 26 --none: yes; 27 } 28 @container scroll-state(scrolled: top) { 29 --top: yes; 30 } 31 @container scroll-state(scrolled: bottom) { 32 --bottom: yes; 33 } 34 } 35 </style> 36 <div id="scroller"> 37 <div id="filler"> 38 <div id="target"></div> 39 </div> 40 </div> 41 <script> 42 setup(() => assert_implements_scroll_state_container_queries()); 43 44 promise_test(async t => { 45 const end = "\uE010"; 46 scroller.focus(); 47 await new test_driver.Actions() 48 .keyDown(end) 49 .keyUp(end) 50 .send(); 51 await new test_driver.Actions() 52 .keyDown(end) 53 .keyUp(end) 54 .send(); 55 await waitForAnimationFrames(2); 56 assert_equals(getComputedStyle(target).getPropertyValue("--none"), "yes"); 57 assert_equals(getComputedStyle(target).getPropertyValue("--top"), "no"); 58 assert_equals(getComputedStyle(target).getPropertyValue("--bottom"), "no"); 59 }, "End key scroll is an absolute scroll"); 60 61 promise_test(async t => { 62 const home = "\uE011"; 63 scroller.focus(); 64 await new test_driver.Actions() 65 .keyDown(home) 66 .keyUp(home) 67 .send(); 68 await new test_driver.Actions() 69 .keyDown(home) 70 .keyUp(home) 71 .send(); 72 await waitForAnimationFrames(2); 73 assert_equals(getComputedStyle(target).getPropertyValue("--none"), "yes"); 74 assert_equals(getComputedStyle(target).getPropertyValue("--top"), "no"); 75 assert_equals(getComputedStyle(target).getPropertyValue("--bottom"), "no"); 76 }, "Home key scroll is an absolute scroll"); 77 78 </script>