blob: 6c50fdb14ac4e094ca8e42a4bfafb83f36e15a59 [file] [log] [blame]
Tobias Schneider9a6600e2017-06-28 17:46:451<!DOCTYPE html>
2<script src="/resources/testharness.js"></script>
3<script src="/resources/testharnessreport.js"></script>
4<script src="./resources/intersection-observer-test-utils.js"></script>
5
6<style>
7pre, #log {
8 position: absolute;
9 top: 0;
10 left: 200px;
11}
12iframe {
13 width: 180px;
14 height: 100px;
15}
16</style>
17
Ali Juma69f77c22018-07-17 21:31:4318<iframe id="iframe" srcdoc="<div id='target' style='margin:0.5px;width:1000px;height:1000px;'></div>"></iframe>
Tobias Schneider9a6600e2017-06-28 17:46:4519
20<script>
21var target;
22var entries = [];
23var observer;
24var iframe = document.getElementById("iframe");
25
26iframe.onload = function() {
27 runTestCycle(function() {
28 target = iframe.contentDocument.getElementById("target");
29 assert_true(!!target, "Target element exists.");
30 observer = new IntersectionObserver(function(changes) {
31 entries = entries.concat(changes);
32 });
33 observer.observe(target);
34 entries = entries.concat(observer.takeRecords());
35 assert_equals(entries.length, 0, "No initial notifications.");
36 runTestCycle(test0, "First rAF should generate notification.");
37 }, "IntersectionObserverEntry.boundingClientRect should match target.boundingClientRect()");
38};
39
40function test0() {
41 assert_equals(entries.length, 1, "One notification.");
42 var bcr = target.getBoundingClientRect();
43 checkLastEntry(entries, 0, [bcr.left, bcr.right, bcr.top, bcr.bottom]);
44}
45</script>