same-origin-grand-child-iframe.sub.html (1489B)
1 <!DOCTYPE html> 2 <meta charset=utf-8> 3 <meta name="viewport" content="width=device-width,initial-scale=1"> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <script src="/common/get-host-info.sub.js"></script> 7 <script src="./resources/intersection-observer-test-utils.js"></script> 8 <iframe scrolling="no" frameborder="0" id="iframe"></iframe> 9 <script> 10 promise_test(async t => { 11 iframe.src = 12 get_host_info().HTTP_NOTSAMESITE_ORIGIN + "/intersection-observer/resources/cross-origin-child-iframe.sub.html"; 13 14 const { rootBounds, intersectionRect } = await new Promise(resolve => { 15 window.addEventListener("message", event => resolve(event.data)); 16 }, { once: true } ); 17 18 // 300px = iframe viewport width 19 // 8px = default body margin 20 // (intersectionRect is in the coordinate space of the target iframe) 21 assert_equals(intersectionRect.top, 8); 22 assert_equals(intersectionRect.left, 200); 23 assert_equals(intersectionRect.right, 300 - 8); 24 assert_equals(intersectionRect.width, 100 - 8); 25 assert_equals(intersectionRect.height, 100); 26 27 assert_equals(rootBounds.left, 0); 28 assert_equals(rootBounds.top, 0); 29 assert_equals(rootBounds.right, document.documentElement.clientWidth); 30 assert_equals(rootBounds.bottom, document.documentElement.clientHeight); 31 }, "rootBounds in a same-origin iframe in the case where there is a cross-origin " 32 + "iframe in between the top document and the same origin iframe"); 33 </script>