summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/intersection-observer/resources/same-origin-grand-child-iframe.html
blob: 0a1426ef0211f9109162a5a6f04fa9b3e260fed0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<!DOCTYPE html>
<!--
  target should be fully vertically in-viewport as 100px is way less than the
  default iframe height.

  right: 0 makes sure that we're occluded by 8px by the intermediate iframe.
-->
<div id="target" style="width: 100px; height: 100px; position: absolute; right: 0"></div>
<script>
const observer = new IntersectionObserver(records => {
  if (records[0].isIntersecting) {
    let { rootBounds, intersectionRect } = records[0];
    window.top.postMessage({ rootBounds, intersectionRect }, "*");
  }
}, {});
observer.observe(document.getElementById("target"));
</script>