content-visibility-081.html (1431B)
1 <!doctype HTML> 2 <html id=html> 3 <meta charset="utf8"> 4 <title>Content Visibility: scroll position restoration</title> 5 <link rel="author" title="Vladimir Levin" href="mailto:vmpstr@chromium.org"> 6 <link rel="help" href="https://drafts.csswg.org/css-contain/#content-visibility"> 7 <meta name="assert" content="if an scroller is hidden via content-visibility and then shown again, its scroll offset should be restored"> 8 <meta name="viewport" content="width=device-width"> 9 10 <script src="/resources/testharness.js"></script> 11 <script src="/resources/testharnessreport.js"></script> 12 <script src="support/helper.js"></script> 13 14 <style> 15 .scroller { 16 width: 100px; 17 height: 500px; 18 overflow-y: scroll; 19 } 20 .spacer { height: 3000px; } 21 .hidden { content-visibility: hidden; } 22 </style> 23 24 <div id=target class=scroller> 25 <div class=spacer></div> 26 </div> 27 </style> 28 29 <script> 30 function removeHiddenAndScheduleTest(t) { 31 target.classList.remove("hidden"); 32 requestAnimationFrame(() => { 33 requestAnimationFrame(() => { 34 testScrollTop(t); 35 }); 36 }); 37 } 38 39 function testScrollTop(t) { 40 t.step(() => assert_equals(target.scrollTop, 2000)); 41 t.done(); 42 } 43 44 async_test((t) => { 45 target.scrollTop = 2000; 46 target.classList.add("hidden"); 47 48 requestAnimationFrame(() => { 49 requestAnimationFrame(() => { 50 removeHiddenAndScheduleTest(t); 51 }); 52 }); 53 }, "Scroll offset is restored when content-visibility hidden is removed"); 54 </script> 55 </html>