cross-document-root.html (1522B)
1 <!DOCTYPE html> 2 <meta name="viewport" content="width=device-width,initial-scale=1"> 3 <link rel="author" href="mailto:szager@chromium.org" title="Stefan Zager"> 4 <link rel="help" href="https://w3c.github.io/IntersectionObserver/#update-intersection-observations-algo"> 5 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 <script src="./resources/intersection-observer-test-utils.js"></script> 9 10 <style> 11 pre, #log { 12 position: absolute; 13 top: 0; 14 left: 200px; 15 } 16 iframe { 17 height: 250px; 18 width: 150px; 19 border: 0; 20 } 21 </style> 22 <iframe id="target-iframe" src="resources/iframe-no-root-subframe.html"></iframe> 23 24 <script> 25 var iframe = document.getElementById("target-iframe"); 26 var target; 27 var root; 28 var entries = []; 29 30 iframe.onload = function() { 31 runTestCycle(function() { 32 assert_true(!!iframe, "iframe exists"); 33 34 target = iframe.contentDocument.getElementById("target"); 35 assert_true(!!target, "Target element exists."); 36 var observer = new IntersectionObserver(function(changes) { 37 entries = entries.concat(changes) 38 }, { root: document }); 39 observer.observe(target); 40 entries = entries.concat(observer.takeRecords()); 41 assert_equals(entries.length, 0, "No initial notifications."); 42 runTestCycle(step0, "First rAF."); 43 }, "Observer with explicit root which is the document, observing a target in a same-origin iframe."); 44 }; 45 46 function step0() { 47 checkLastEntry(entries, 0, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false]); 48 } 49 </script>