scrollIntoView-multiple.html (3160B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>CSSOM View - Simultaneous scrollIntoViews</title> 5 <link rel="help" href="https://drafts.csswg.org/cssom-view/#dom-element-scrollintoview"> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 <script src="/dom/events/scrolling/scroll_support.js"></script> 9 <script src="/css/css-scroll-snap/support/common.js"></script> 10 <script src="resources/simultaneousScrollIntoViews.js"></script> 11 </head> 12 <body> 13 <style> 14 .scroller { 15 overflow-y: scroll; 16 height: 200px; 17 width: 200px; 18 background-color: teal; 19 border: solid 1px black; 20 position: relative; 21 display: inline-block; 22 } 23 .space { 24 height: 200vh; 25 width: 200vw; 26 } 27 .box { 28 height: 50px; 29 width: 50px; 30 background-color: purple; 31 } 32 .target { 33 position: absolute; 34 top: 150%; 35 } 36 </style> 37 <div id="scroller1" class="scroller"> 38 <div class="space"></div> 39 <div class="box target" id="target1"></div> 40 </div> 41 <div id="scroller2" class="scroller"> 42 <div class="space"></div> 43 <div class="box target" id="target2"></div> 44 </div> 45 <script> 46 const scroller1 = document.getElementById("scroller1"); 47 const scroller2 = document.getElementById("scroller2"); 48 const target1 = document.getElementById("target1"); 49 const target2 = document.getElementById("target2"); 50 51 const targets = [target1, target2]; 52 const scrollers = [scroller1, scroller2]; 53 const target_offsets = [target1.offsetTop, target2.offsetTop]; 54 55 promise_test(async (t) => { 56 await simultaneousScrollIntoViewsTest(t, 57 ["smooth", "smooth"], 58 targets, 59 scrollers, 60 target_offsets); 61 }, "Simultaneous smooth scrollIntoViews run to completion"); 62 63 promise_test(async (t) => { 64 await simultaneousScrollIntoViewsTest(t, 65 ["smooth", "instant"], 66 targets, 67 scrollers, 68 target_offsets); 69 }, "Simultaneous smooth,instant scrollIntoViews run to completion"); 70 71 promise_test(async (t) => { 72 await simultaneousScrollIntoViewsTest(t, 73 ["instant", "smooth"], 74 targets, 75 scrollers, 76 target_offsets); 77 }, "Simultaneous instant,smooth scrollIntoViews run to completion"); 78 79 promise_test(async (t) => { 80 await simultaneousScrollIntoViewsTest(t, 81 ["instant", "instant"], 82 targets, 83 scrollers, 84 target_offsets); 85 }, "Simultaneous instant scrollIntoViews run to completion"); 86 </script> 87 </body> 88 </html>