box-reflect.html (1423B)
1 <!DOCTYPE html> 2 <meta name="viewport" content="width=device-width,initial-scale=1"> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <script src="../resources/intersection-observer-test-utils.js"></script> 6 7 <style> 8 body, html { 9 margin: 0; 10 } 11 pre, #log { 12 position: absolute; 13 top: 0; 14 left: 200px; 15 } 16 #reflect { 17 width: 100px; 18 height: 100px; 19 background-color: hotpink; 20 -webkit-box-reflect: below 10px; 21 margin: 10px 0; 22 } 23 </style> 24 25 <div id="reflect"></div> 26 <div id="target">Hello, world!</div> 27 28 <script> 29 var delay = 100; 30 var entries = []; 31 var target; 32 var supported = CSS.supports("-webkit-box-reflect", "below 10px"); 33 34 runTestCycle(function() { 35 target = document.getElementById("target"); 36 assert_true(!!target, "target exists"); 37 let observer = new IntersectionObserver(function(changes) { 38 entries = entries.concat(changes) 39 }, {trackVisibility: true, delay: delay}); 40 observer.observe(target); 41 entries = entries.concat(observer.takeRecords()); 42 assert_equals(entries.length, 0, "No initial notifications."); 43 runTestCycle(step0, "First rAF.", delay); 44 }, "IntersectionObserverV2 detects occlusion from -webkit-box-reflect (if supported).", delay); 45 46 function step0() { 47 assert_equals(entries.length, 1, "Initial notification."); 48 assert_equals(entries[0].isVisible, !supported, "Occluded if -webkit-box-reflect is supported."); 49 } 50 </script>