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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 }; | 60 }; |
61 }, timeSkew); | 61 }, timeSkew); |
62 }, "Check that timestamps correspond to the to execution context that created th
e observer."); | 62 }, "Check that timestamps correspond to the to execution context that created th
e observer."); |
63 | 63 |
64 function step1() { | 64 function step1() { |
65 document.scrollingElement.scrollTop = 200; | 65 document.scrollingElement.scrollTop = 200; |
66 targetIframe.contentDocument.scrollingElement.scrollTop = 250; | 66 targetIframe.contentDocument.scrollingElement.scrollTop = 250; |
67 topWindowTimeBeforeNotification = performance.now(); | 67 topWindowTimeBeforeNotification = performance.now(); |
68 iframeWindowTimeBeforeNotification = targetIframe.contentWindow.performance.no
w(); | 68 iframeWindowTimeBeforeNotification = targetIframe.contentWindow.performance.no
w(); |
69 runTestCycle(step2, "Generate notifications."); | 69 runTestCycle(step2, "Generate notifications."); |
70 assert_equals(topWindowEntries.length, 0, "No notifications to top window obse
rver."); | 70 assert_equals(topWindowEntries.length, 1, "One notification to top window obse
rver."); |
71 assert_equals(iframeWindowEntries.length, 0, "No notifications to iframe obser
ver."); | 71 assert_equals(iframeWindowEntries.length, 1, "One notification to iframe obser
ver."); |
72 } | 72 } |
73 | 73 |
74 function step2() { | 74 function step2() { |
75 document.scrollingElement.scrollTop = 0; | 75 document.scrollingElement.scrollTop = 0; |
76 var topWindowTimeAfterNotification = performance.now(); | 76 var topWindowTimeAfterNotification = performance.now(); |
77 var iframeWindowTimeAfterNotification = targetIframe.contentWindow.performance
.now(); | 77 var iframeWindowTimeAfterNotification = targetIframe.contentWindow.performance
.now(); |
78 | 78 |
79 // Test results are only significant if there's a gap between | 79 // Test results are only significant if there's a gap between |
80 // top window time and iframe window time. | 80 // top window time and iframe window time. |
81 assert_greater_than(topWindowTimeBeforeNotification, iframeWindowTimeAfterNoti
fication, | 81 assert_greater_than(topWindowTimeBeforeNotification, iframeWindowTimeAfterNoti
fication, |
82 "Time ranges for top and iframe windows are disjoint."); | 82 "Time ranges for top and iframe windows are disjoint."); |
83 | 83 |
84 assert_equals(topWindowEntries.length, 1, "Top window observer has one notific
ation."); | 84 assert_equals(topWindowEntries.length, 2, "Top window observer has two notific
ations."); |
85 assert_between_inclusive( | 85 assert_between_inclusive( |
86 topWindowEntries[0].time, | 86 topWindowEntries[1].time, |
87 topWindowTimeBeforeNotification, | 87 topWindowTimeBeforeNotification, |
88 topWindowTimeAfterNotification, | 88 topWindowTimeAfterNotification, |
89 "Notification to top window observer is within the expected range."); | 89 "Notification to top window observer is within the expected range."); |
90 | 90 |
91 assert_equals(iframeWindowEntries.length, 1, "Iframe observer has one notifica
tion."); | 91 assert_equals(iframeWindowEntries.length, 2, "Iframe observer has two notifica
tions."); |
92 assert_between_inclusive( | 92 assert_between_inclusive( |
93 iframeWindowEntries[0].time, | 93 iframeWindowEntries[1].time, |
94 iframeWindowTimeBeforeNotification, | 94 iframeWindowTimeBeforeNotification, |
95 iframeWindowTimeAfterNotification, | 95 iframeWindowTimeAfterNotification, |
96 "Notification to iframe observer is within the expected range."); | 96 "Notification to iframe observer is within the expected range."); |
97 } | 97 } |
98 </script> | 98 </script> |
OLD | NEW |