target-in-detached-document.html (1310B)
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 #target { 14 width: 100px; 15 height: 100px; 16 background-color: green; 17 } 18 </style> 19 20 <script> 21 var vw = document.documentElement.clientWidth; 22 var vh = document.documentElement.clientHeight; 23 24 var entries = []; 25 var target; 26 27 runTestCycle(function() { 28 var detached_document = document.implementation.createHTMLDocument("test"); 29 target = detached_document.createElement("div"); 30 target.id = "target"; 31 var observer = new IntersectionObserver(function(changes) { 32 entries = entries.concat(changes) 33 }); 34 observer.observe(target); 35 runTestCycle(step0, "First rAF."); 36 }, "IntersectionObserver in a single document using the implicit root."); 37 38 function step0() { 39 document.adoptNode(target); 40 document.body.appendChild(target); 41 assert_equals(entries.length, 0, "No initial notification while in detached document."); 42 runTestCycle(step1, "Adopt target."); 43 } 44 45 function step1() { 46 checkLastEntry(entries, 0, [8, 108, 8, 108, 8, 108, 8, 108, 0, vw, 0, vh, true]); 47 } 48 </script>