scroll-initial-target-with-hash-fragment-navigation.tentative.html (1450B)
1 <!DOCTYPE html> 2 <html> 3 4 <head> 5 <meta charset="utf-8"> 6 <title> CSS Scroll Snap 2 Test: scroll-initial-target interaction with fragment-navigation</title> 7 <link rel="help" href="https://drafts.csswg.org/css-scroll-snap-2/#scroll-initial-target"> 8 <script src="/resources/testharness.js"></script> 9 <script src="/resources/testharnessreport.js"></script> 10 </head> 11 12 <body> 13 <iframe id="frame" src="scroll-initial-target-with-fragment-navigation-inner-frame.html#fragment_target" 14 onload="runTest()"></iframe> 15 <script> 16 function runTest() { 17 test((t) => { 18 let scroller = frame.contentDocument.scrollingElement; 19 // fragment_target is at the bottom of the frame so the frame should be 20 // fully scrolled down to bring it into view (despite middle_box being 21 // the scroll-initial-target). 22 let expected_scroll_top = scroller.scrollHeight - scroller.clientHeight; 23 // The scroll-initial-target is just below top_box which has a height of 24 // 60vh. 25 const scroll_start_target_top = 0.6 * frame.contentWindow.innerHeight; 26 27 assert_equals(frame.contentWindow.location.hash, "#fragment_target"); 28 assert_not_equals(scroll_start_target_top, expected_scroll_top); 29 assert_equals(frame.contentDocument.scrollingElement.scrollTop, 30 expected_scroll_top); 31 }, "scroll-initial-target does not override hash fragment navigation"); 32 } 33 </script> 34 </body>