| 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 | background-color: green; |
| 14 | width: 100px; |
| 15 | height: 100px; |
| 16 | } |
| 17 | </style> |
| 18 | |
| 19 | <div id="target"></div> |
| 20 | |
| 21 | <script> |
| 22 | var vw = document.documentElement.clientWidth; |
| 23 | var vh = document.documentElement.clientHeight; |
| 24 | |
| 25 | var entries = []; |
| 26 | |
| 27 | runTestCycle(function() { |
| 28 | var target = document.getElementById("target"); |
| 29 | var root = document.getElementById("root"); |
| 30 | var 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(step0, "Intersecting notification after first rAF."); |
| 37 | }, "IntersectionObserver should send a not-intersecting notification for a target that gets display:none."); |
| 38 | |
| 39 | function step0() { |
| 40 | runTestCycle(step1, "Not-intersecting notification after setting display:none on target."); |
| 41 | checkLastEntry(entries, 0, [8, 108, 8, 108, 8, 108, 8, 108, 0, vw, 0, vh, true]); |
| 42 | target.style.display = "none"; |
| 43 | } |
| 44 | |
| 45 | function step1() { |
| 46 | runTestCycle(step2, "Intersecting notification after removing display:none on target."); |
| 47 | checkLastEntry(entries, 1, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false]); |
| 48 | target.style.display = ""; |
| 49 | } |
| 50 | |
| 51 | function step2() { |
| 52 | checkLastEntry(entries, 2, [8, 108, 8, 108, 8, 108, 8, 108, 0, vw, 0, vh, true]); |
| 53 | } |
| 54 | </script> |