blob: 24ae01cedc2ef95f6dd04a722d47aefa30e8b777 [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}
12#root {
13 overflow: visible;
14 height: 200px;
15 width: 160px;
16 border: 7px solid black;
17}
18#target {
19 width: 100px;
20 height: 100px;
21 background-color: green;
22}
23</style>
24
25<div id="root">
26 <div id="target" style="transform: translateY(300px)"></div>
27</div>
28
29<script>
30var entries = [];
31var target;
32
33runTestCycle(function() {
34 target = document.getElementById("target");
35 assert_true(!!target, "target exists");
36 var root = document.getElementById("root");
37 assert_true(!!root, "root exists");
38 var observer = new IntersectionObserver(function(changes) {
39 entries = entries.concat(changes)
40 }, {root: root});
41 observer.observe(target);
42 entries = entries.concat(observer.takeRecords());
43 assert_equals(entries.length, 0, "No initial notifications.");
44 runTestCycle(step0, "First rAF.");
45}, "Test that border bounding box is used to calculate intersection with a non-scrolling root.");
46
47function step0() {
48 target.style.transform = "translateY(195px)";
49 runTestCycle(step1, "target.style.transform = 'translateY(195px)'");
50 checkLastEntry(entries, 0, [15, 115, 315, 415, 0, 0, 0, 0, 8, 182, 8, 222, false]);
51}
52
53function step1() {
54 target.style.transform = "";
55 checkLastEntry(entries, 1, [15, 115, 210, 310, 15, 115, 210, 222, 8, 182, 8, 222, true]);
56}
57</script>