shadow-content.html (1416B)
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 pre, #log { 9 position: absolute; 10 top: 0; 11 left: 200px; 12 } 13 </style> 14 15 <div id="host"></div> 16 17 <script> 18 var vw = document.documentElement.clientWidth; 19 var vh = document.documentElement.clientHeight; 20 21 var entries = []; 22 var target; 23 24 runTestCycle(function() { 25 var shadowHost = document.getElementById("host"); 26 assert_true(!!shadowHost, "Host exists"); 27 var shadowRoot = shadowHost.attachShadow({ mode: "open" }); 28 assert_true(!!shadowRoot, "Shadow root exists"); 29 shadowRoot.innerHTML = "<div id='target' style='width: 100px; height: 100px; background-color: green;'></div>"; 30 target = shadowRoot.getElementById("target"); 31 assert_true(!!target, "target exists"); 32 33 var observer = new IntersectionObserver(function(changes) { 34 entries = entries.concat(changes) 35 }); 36 observer.observe(target); 37 entries = entries.concat(observer.takeRecords()); 38 assert_equals(entries.length, 0, "No initial notifications."); 39 runTestCycle(step0, "First rAF after creating shadow DOM."); 40 }, "Observing a target inside shadow DOM."); 41 42 function step0() { 43 checkLastEntry(entries, 0, [8, 108, 8, 108, 8, 108, 8, 108, 0, vw, 0, vh, true]); 44 } 45 </script>