| Tobias Schneider | 9a6600e | 2017-06-28 17:46:45 | [diff] [blame] | 1 | <!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> |
| 7 | pre, #log { |
| 8 | position: absolute; |
| 9 | top: 0; |
| 10 | left: 200px; |
| 11 | } |
| 12 | #target { |
| 13 | width: 0px; |
| 14 | height: 0px; |
| 15 | } |
| 16 | </style> |
| 17 | |
| 18 | <div id='target'></div> |
| 19 | |
| 20 | <script> |
| 21 | var entries = []; |
| 22 | |
| 23 | runTestCycle(function() { |
| 24 | var target = document.getElementById('target'); |
| 25 | assert_true(!!target, "target exists"); |
| 26 | var observer = new IntersectionObserver(function(changes) { |
| 27 | entries = entries.concat(changes) |
| 28 | }); |
| 29 | observer.observe(target); |
| 30 | entries = entries.concat(observer.takeRecords()); |
| 31 | assert_equals(entries.length, 0, "No initial notifications."); |
| 32 | runTestCycle(step0, "First rAF should generate a notification."); |
| 33 | }, "Ensure that a zero-area target intersecting root generates a notification with intersectionRatio == 1"); |
| 34 | |
| 35 | function step0() { |
| 36 | assert_equals(entries.length, 1, "One notification."); |
| 37 | assert_equals(entries[0].intersectionRatio, 1, "intersectionRatio == 1"); |
| 38 | } |
| 39 | </script> |