Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(600)

Side by Side Diff: third_party/WebKit/LayoutTests/intersection-observer/same-document-root.html

Issue 2645283008: IntersectionObserver: Always send an initial notification. (Closed)
Patch Set: Fix unit test Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 }, { root: root }); 49 }, { root: root });
50 observer.observe(target); 50 observer.observe(target);
51 entries = entries.concat(observer.takeRecords()); 51 entries = entries.concat(observer.takeRecords());
52 assert_equals(entries.length, 0, "No initial notifications."); 52 assert_equals(entries.length, 0, "No initial notifications.");
53 runTestCycle(step0, "First rAF"); 53 runTestCycle(step0, "First rAF");
54 }, "IntersectionObserver in a single document with explicit root."); 54 }, "IntersectionObserver in a single document with explicit root.");
55 55
56 function step0() { 56 function step0() {
57 document.scrollingElement.scrollTop = 600; 57 document.scrollingElement.scrollTop = 600;
58 runTestCycle(step1, "document.scrollingElement.scrollTop = 600."); 58 runTestCycle(step1, "document.scrollingElement.scrollTop = 600.");
59 assert_equals(entries.length, 0, "No notifications after first rAF."); 59 checkLastEntry(entries, 0, [11, 111, 1011, 1111, 0, 0, 0, 0, 11, 111, 711, 911 , target]);
60 } 60 }
61 61
62 function step1() { 62 function step1() {
63 root.scrollTop = 150; 63 root.scrollTop = 150;
64 runTestCycle(step2, "root.scrollTop = 150 with root scrolled into view."); 64 runTestCycle(step2, "root.scrollTop = 150 with root scrolled into view.");
65 assert_equals(entries.length, 0, "No notifications after scrolling frame."); 65 assert_equals(entries.length, 1, "No notifications after scrolling frame.");
66 } 66 }
67 67
68 function step2() { 68 function step2() {
69 document.scrollingElement.scrollTop = 0; 69 document.scrollingElement.scrollTop = 0;
70 runTestCycle(step3, "document.scrollingElement.scrollTop = 0."); 70 runTestCycle(step3, "document.scrollingElement.scrollTop = 0.");
71 checkLastEntry(entries, 0, [11, 111, 261, 361, 11, 111, 261, 311, 11, 111, 111 , 311, target]); 71 checkLastEntry(entries, 1, [11, 111, 261, 361, 11, 111, 261, 311, 11, 111, 111 , 311, target]);
72 } 72 }
73 73
74 function step3() { 74 function step3() {
75 root.scrollTop = 0; 75 root.scrollTop = 0;
76 runTestCycle(step4, "root.scrollTop = 0"); 76 runTestCycle(step4, "root.scrollTop = 0");
77 checkLastEntry(entries, 0); 77 checkLastEntry(entries, 1);
78 } 78 }
79 79
80 function step4() { 80 function step4() {
81 root.scrollTop = 150; 81 root.scrollTop = 150;
82 runTestCycle(step5, "root.scrollTop = 150 with root scrolled out of view."); 82 runTestCycle(step5, "root.scrollTop = 150 with root scrolled out of view.");
83 checkLastEntry(entries, 1, [11, 111, 1011, 1111, 0, 0, 0, 0, 11, 111, 711, 911 , target]); 83 checkLastEntry(entries, 2, [11, 111, 1011, 1111, 0, 0, 0, 0, 11, 111, 711, 911 , target]);
84 } 84 }
85 85
86 // This tests that notifications are generated even when the root element is off screen. 86 // This tests that notifications are generated even when the root element is off screen.
87 function step5() { 87 function step5() {
88 checkLastEntry(entries, 2, [11, 111, 861, 961, 11, 111, 861, 911, 11, 111, 711 , 911, target]); 88 checkLastEntry(entries, 3, [11, 111, 861, 961, 11, 111, 861, 911, 11, 111, 711 , 911, target]);
89 } 89 }
90 </script> 90 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698