blob: d049c70919e129fa6c335e8601f6ce6a6cd73a9d [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</style>
13
14<div id="host"></div>
15
16<script>
17var vw = document.documentElement.clientWidth;
18var vh = document.documentElement.clientHeight;
19
20var entries = [];
21var target;
22
23runTestCycle(function() {
24 var shadowHost = document.getElementById("host");
25 assert_true(!!shadowHost, "Host exists");
Emilio Cobos Álvarezae860132018-04-13 22:03:0526 var shadowRoot = shadowHost.attachShadow({ mode: "open" });
Tobias Schneider9a6600e2017-06-28 17:46:4527 assert_true(!!shadowRoot, "Shadow root exists");
28 shadowRoot.innerHTML = "<div id='target' style='width: 100px; height: 100px; background-color: green;'></div>";
29 target = shadowRoot.getElementById("target");
30 assert_true(!!target, "target exists");
31
32 var observer = new IntersectionObserver(function(changes) {
33 entries = entries.concat(changes)
34 });
35 observer.observe(target);
36 entries = entries.concat(observer.takeRecords());
37 assert_equals(entries.length, 0, "No initial notifications.");
38 runTestCycle(step0, "First rAF after creating shadow DOM.");
39}, "Observing a target inside shadow DOM.");
40
41function step0() {
42 checkLastEntry(entries, 0, [8, 108, 8, 108, 8, 108, 8, 108, 0, vw, 0, vh, true]);
43}
44</script>