content-visibility-with-top-layer-008.html (1655B)
1 <!doctype html> 2 <meta charset="utf8"> 3 <title>CSS Content Visibility: Contentvisibilityautostatechange fires once when c-v auto's dialog ancestor show</title> 4 <link rel="author" title="Cathie Chen" href="mailto:cathiechen@igalia.com"> 5 <link rel="help" href="https://drafts.csswg.org/css-contain/#content-visibility"> 6 <meta name="assert" content="Contentvisibilityautostatechange fires once when c-v auto's dialog ancestor show"> 7 8 <script src="/resources/testharness.js"></script> 9 <script src="/resources/testharnessreport.js"></script> 10 <script src="/common/rendering-utils.js"></script> 11 12 <style> 13 #inner { 14 content-visibility: auto; 15 contain-intrinsic-size: 100px 100px; 16 } 17 </style> 18 19 <dialog id="dialog"> 20 <div id="inner"> 21 <div style="height: 200px; width: 200px;">content</div> 22 </div> 23 <div id="spacer" style="height: 100000px;"></div> 24 </dialog> 25 26 <script> 27 promise_test(async () => { 28 let count = 0; 29 inner.addEventListener("contentvisibilityautostatechange", (e) => { 30 count++; 31 }); 32 33 dialog.show(); 34 // getBoundingClientRect shouldn't trigger "contentvisibilityautostatechange", because the proximity to the viewport is not determined now. 35 inner.getBoundingClientRect().height; 36 37 // It takes at least one frame to determine the proximity to the viewport. 38 await waitForAtLeastOneFrame(); 39 // getBoundingClientRect should trigger "contentvisibilityautostatechange" now. 40 inner.getBoundingClientRect().height; 41 42 await waitForAtLeastOneFrame(); 43 assert_equals(count, 1); 44 dialog.close(); 45 }, "Contentvisibilityautostatechange fires once when c-v auto's dialog ancestor show()"); 46 </script>