OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src="../resources/testharness.js"></script> | 2 <script src="../../resources/testharness.js"></script> |
3 <script src="../resources/testharnessreport.js"></script> | 3 <script src="../../resources/testharnessreport.js"></script> |
4 <script src="../resources/intersection-observer-helper-functions.js"></script> | |
5 | 4 |
6 <div style="height: 200px; width: 100px;"></div> | 5 <div style="height: 200px; width: 100px;"></div> |
7 <div id="target" style="background-color: green; width:100px; height:100px"></di
v> | 6 <div id="target" style="background-color: green; width:100px; height:100px"></di
v> |
8 <div style="height: 200px; width: 100px;"></div> | 7 <div style="height: 200px; width: 100px;"></div> |
9 | 8 |
10 <script> | 9 <script> |
| 10 function waitForNotification(f) { |
| 11 requestAnimationFrame(() => { |
| 12 setTimeout(() => { |
| 13 setTimeout(f); |
| 14 }); |
| 15 }); |
| 16 } |
| 17 |
11 setup({message_events: [], output_document: window.parent.document}); | 18 setup({message_events: [], output_document: window.parent.document}); |
12 onload = function() { | 19 onload = function() { |
13 var entries = []; | 20 var entries = []; |
14 var observer = new IntersectionObserver(function(changes) { entries = entries.
concat(changes) }, {}); | 21 var observer = new IntersectionObserver(function(changes) { entries = entries.
concat(changes) }, {}); |
15 var target = document.getElementById("target"); | 22 var target = document.getElementById("target"); |
16 var scroller = document.scrollingElement; | 23 var scroller = document.scrollingElement; |
17 observer.observe(target); | 24 observer.observe(target); |
18 entries = entries.concat(observer.takeRecords()); | 25 entries = entries.concat(observer.takeRecords()); |
19 var t = async_test("IntersectionObserver in iframe with explicit root."); | 26 var t = async_test("IntersectionObserver in iframe with explicit root."); |
20 test(function() { assert_equals(entries.length, 0) }, "No initial notification
s.") | 27 test(function() { assert_equals(entries.length, 0) }, "No initial notification
s.") |
(...skipping 19 matching lines...) Expand all Loading... |
40 test(function() { assert_equals(entries[0].rootBounds.left, 0) }, "entries
[0].rootBounds.left"); | 47 test(function() { assert_equals(entries[0].rootBounds.left, 0) }, "entries
[0].rootBounds.left"); |
41 test(function() { assert_equals(entries[0].rootBounds.right, 800) }, "entr
ies[0].rootBounds.right"); | 48 test(function() { assert_equals(entries[0].rootBounds.right, 800) }, "entr
ies[0].rootBounds.right"); |
42 test(function() { assert_equals(entries[0].rootBounds.top, 0) }, "entries[
0].rootBounds.top"); | 49 test(function() { assert_equals(entries[0].rootBounds.top, 0) }, "entries[
0].rootBounds.top"); |
43 test(function() { assert_equals(entries[0].rootBounds.bottom, 600) }, "ent
ries[0].rootBounds.bottom"); | 50 test(function() { assert_equals(entries[0].rootBounds.bottom, 600) }, "ent
ries[0].rootBounds.bottom"); |
44 test(function() { assert_true(entries[0].target === target) }, "entries[0]
.target object identity"); | 51 test(function() { assert_true(entries[0].target === target) }, "entries[0]
.target object identity"); |
45 } | 52 } |
46 t.done(); | 53 t.done(); |
47 } | 54 } |
48 }; | 55 }; |
49 </script> | 56 </script> |
OLD | NEW |