content-visibility-generated-content-removal.html (1036B)
1 <!DOCTYPE HTML> 2 <html class="test-wait"> 3 <style> 4 div { content-visibility: auto; } 5 div::after { content: "Bar" } 6 </style> 7 <div>Foo</div> 8 <div style="height:4000px"></div> 9 <script> 10 // Ensure no crash when removing element with generated content after 11 // `content-visibility: auto` content goes out of view. 12 requestAnimationFrame(() => { 13 requestAnimationFrame(() => { 14 // Let one layout run with the div content in view, then 15 // scroll it out of view. 16 document.scrollingElement.scrollTop = 3000; 17 18 // Run three frames to ensure a new layout happens with the 19 // 'auto' content hidden (i.e. layout structures are 20 // destroyed), then remove the div with a pseudo element which 21 // was previously problematic. 22 requestAnimationFrame(() => { 23 requestAnimationFrame(() => { 24 requestAnimationFrame(() => { 25 document.querySelector('div').remove(); 26 document.documentElement.className = ''; 27 }) 28 }) 29 }) 30 }) 31 }); 32 </script>