LEFT | RIGHT |
(no file at all) | |
| 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 #root { |
| 13 width: 200px; |
| 14 height: 200px; |
| 15 overflow: visible; |
| 16 } |
| 17 #target { |
| 18 background-color: green; |
| 19 } |
| 20 </style> |
| 21 |
| 22 <div id="root"> |
| 23 <div id="target" style="width: 100px; height: 100px; transform: translateY(250
px)"></div> |
| 24 </div> |
| 25 |
| 26 <script> |
| 27 var entries = []; |
| 28 |
| 29 runTestCycle(function() { |
| 30 var root = document.getElementById('root'); |
| 31 assert_true(!!root, "root element exists."); |
| 32 var target = document.getElementById('target'); |
| 33 assert_true(!!target, "target element exists."); |
| 34 var observer = new IntersectionObserver(function(changes) { |
| 35 entries = entries.concat(changes); |
| 36 }, { root: root }); |
| 37 observer.observe(target); |
| 38 entries = entries.concat(observer.takeRecords()); |
| 39 assert_equals(entries.length, 0, "No initial notifications."); |
| 40 runTestCycle(step0, "First rAF."); |
| 41 }, "IntersectionObserver should detect and report edge-adjacent and zero-area in
tersections."); |
| 42 |
| 43 function step0() { |
| 44 runTestCycle(step1, "Set transform=translateY(200px) on target."); |
| 45 checkLastEntry(entries, 0, [8, 108, 258, 358, 0, 0, 0, 0, 8, 208, 8, 208, fals
e]); |
| 46 target.style.transform = "translateY(200px)"; |
| 47 } |
| 48 |
| 49 function step1() { |
| 50 runTestCycle(step2, "Set transform=translateY(201px) on target."); |
| 51 checkLastEntry(entries, 1, [8, 108, 208, 308, 8, 108, 208, 208, 8, 208, 8, 208
, true]); |
| 52 target.style.transform = "translateY(201px)"; |
| 53 } |
| 54 |
| 55 function step2() { |
| 56 runTestCycle(step3, "Set transform=translateY(185px) on target."); |
| 57 checkLastEntry(entries, 2); |
| 58 target.style.height = "0px"; |
| 59 target.style.width = "300px"; |
| 60 target.style.transform = "translateY(185px)"; |
| 61 } |
| 62 |
| 63 function step3() { |
| 64 checkLastEntry(entries, 3, [8, 308, 193, 193, 8, 208, 193, 193, 8, 208, 8, 208
, true]); |
| 65 } |
| 66 </script> |
LEFT | RIGHT |