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-test-utils.js"></script> | 4 <script src="./resources/intersection-observer-test-utils.js"></script> |
5 | 5 |
6 <style> | 6 <style> |
7 pre, #log { | 7 pre, #log { |
8 position: absolute; | 8 position: absolute; |
9 top: 0; | 9 top: 0; |
10 left: 200px; | 10 left: 200px; |
(...skipping 20 matching lines...) Expand all Loading... |
31 assert_equals(window.innerWidth, 800, "Window must be 800 pixels wide."); | 31 assert_equals(window.innerWidth, 800, "Window must be 800 pixels wide."); |
32 assert_equals(window.innerHeight, 600, "Window must be 600 pixels high."); | 32 assert_equals(window.innerHeight, 600, "Window must be 600 pixels high."); |
33 | 33 |
34 target = document.getElementById("target"); | 34 target = document.getElementById("target"); |
35 var observer = new IntersectionObserver(function(changes) { | 35 var observer = new IntersectionObserver(function(changes) { |
36 entries = entries.concat(changes) | 36 entries = entries.concat(changes) |
37 }, { threshold: [0, 0.25, 0.5, 0.75, 1] }); | 37 }, { threshold: [0, 0.25, 0.5, 0.75, 1] }); |
38 observer.observe(target); | 38 observer.observe(target); |
39 entries = entries.concat(observer.takeRecords()); | 39 entries = entries.concat(observer.takeRecords()); |
40 assert_equals(entries.length, 0, "No initial notifications."); | 40 assert_equals(entries.length, 0, "No initial notifications."); |
41 runTestCycle(step0, "No notifications after first rAF."); | 41 runTestCycle(step0, "First rAF."); |
42 }, "Observer with multiple thresholds."); | 42 }, "Observer with multiple thresholds."); |
43 | 43 |
44 function step0() { | 44 function step0() { |
45 document.scrollingElement.scrollTop = 120; | 45 document.scrollingElement.scrollTop = 120; |
46 runTestCycle(step1, "document.scrollingElement.scrollTop = 120"); | 46 runTestCycle(step1, "document.scrollingElement.scrollTop = 120"); |
47 assert_equals(entries.length, 0, "No notifications after first rAF."); | 47 checkLastEntry(entries, 0, [8, 108, 708, 808, 0, 0, 0, 0, 0, 785, 0, 600, targ
et]); |
48 } | 48 } |
49 | 49 |
50 function step1() { | 50 function step1() { |
51 document.scrollingElement.scrollTop = 160; | 51 document.scrollingElement.scrollTop = 160; |
52 runTestCycle(step2, "document.scrollingElement.scrollTop = 160"); | 52 runTestCycle(step2, "document.scrollingElement.scrollTop = 160"); |
53 checkLastEntry(entries, 0, [8, 108, 588, 688, 8, 108, 588, 600, 0, 785, 0, 600
, target]); | 53 checkLastEntry(entries, 1, [8, 108, 588, 688, 8, 108, 588, 600, 0, 785, 0, 600
, target]); |
54 } | 54 } |
55 | 55 |
56 function step2() { | 56 function step2() { |
57 document.scrollingElement.scrollTop = 200; | 57 document.scrollingElement.scrollTop = 200; |
58 runTestCycle(step3, "document.scrollingElement.scrollTop = 200"); | 58 runTestCycle(step3, "document.scrollingElement.scrollTop = 200"); |
59 checkLastEntry(entries, 1, [8, 108, 548, 648, 8, 108, 548, 600, 0, 785, 0, 600
, target]); | 59 checkLastEntry(entries, 2, [8, 108, 548, 648, 8, 108, 548, 600, 0, 785, 0, 600
, target]); |
60 } | 60 } |
61 | 61 |
62 function step3() { | 62 function step3() { |
63 document.scrollingElement.scrollTop = 240; | 63 document.scrollingElement.scrollTop = 240; |
64 runTestCycle(step4, "document.scrollingElement.scrollTop = 240"); | 64 runTestCycle(step4, "document.scrollingElement.scrollTop = 240"); |
65 checkLastEntry(entries, 2, [8, 108, 508, 608, 8, 108, 508, 600, 0, 785, 0, 600
, target]); | 65 checkLastEntry(entries, 3, [8, 108, 508, 608, 8, 108, 508, 600, 0, 785, 0, 600
, target]); |
66 } | 66 } |
67 | 67 |
68 function step4() { | 68 function step4() { |
69 document.scrollingElement.scrollTop = 740; | 69 document.scrollingElement.scrollTop = 740; |
70 runTestCycle(step5, "document.scrollingElement.scrollTop = 740"); | 70 runTestCycle(step5, "document.scrollingElement.scrollTop = 740"); |
71 checkLastEntry(entries, 3, [8, 108, 468, 568, 8, 108, 468, 568, 0, 785, 0, 600
, target]); | 71 checkLastEntry(entries, 4, [8, 108, 468, 568, 8, 108, 468, 568, 0, 785, 0, 600
, target]); |
72 } | 72 } |
73 | 73 |
74 function step5() { | 74 function step5() { |
75 document.scrollingElement.scrollTop = 760; | 75 document.scrollingElement.scrollTop = 760; |
76 runTestCycle(step6, "document.scrollingElement.scrollTop = 760"); | 76 runTestCycle(step6, "document.scrollingElement.scrollTop = 760"); |
77 checkLastEntry(entries, 4, [8, 108, -32, 68, 8, 108, 0, 68, 0, 785, 0, 600, ta
rget]); | 77 checkLastEntry(entries, 5, [8, 108, -32, 68, 8, 108, 0, 68, 0, 785, 0, 600, ta
rget]); |
78 } | 78 } |
79 | 79 |
80 function step6() { | 80 function step6() { |
81 document.scrollingElement.scrollTop = 800; | 81 document.scrollingElement.scrollTop = 800; |
82 runTestCycle(step7, "document.scrollingElement.scrollTop = 800"); | 82 runTestCycle(step7, "document.scrollingElement.scrollTop = 800"); |
83 checkLastEntry(entries, 5, [8, 108, -52, 48, 8, 108, 0, 48, 0, 785, 0, 600, ta
rget]); | 83 checkLastEntry(entries, 6, [8, 108, -52, 48, 8, 108, 0, 48, 0, 785, 0, 600, ta
rget]); |
84 } | 84 } |
85 | 85 |
86 function step7() { | 86 function step7() { |
87 checkLastEntry(entries, 6, [8, 108, -92, 8, 8, 108, 0, 8, 0, 785, 0, 600, targ
et]); | 87 checkLastEntry(entries, 7, [8, 108, -92, 8, 8, 108, 0, 8, 0, 785, 0, 600, targ
et]); |
88 document.scrollingElement.scrollTop = 820; | 88 document.scrollingElement.scrollTop = 820; |
89 runTestCycle(step8, "document.scrollingElement.scrollTop = 820"); | 89 runTestCycle(step8, "document.scrollingElement.scrollTop = 820"); |
90 } | 90 } |
91 | 91 |
92 function step8() { | 92 function step8() { |
93 checkLastEntry(entries, 7, [8, 108, -112, -12, 0, 0, 0, 0, 0, 785, 0, 600, tar
get]); | 93 checkLastEntry(entries, 8, [8, 108, -112, -12, 0, 0, 0, 0, 0, 785, 0, 600, tar
get]); |
94 document.scrollingElement.scrollTop = 0; | 94 document.scrollingElement.scrollTop = 0; |
95 } | 95 } |
96 </script> | 96 </script> |
OLD | NEW |