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

Side by Side Diff: third_party/WebKit/LayoutTests/intersection-observer/containing-block.html

Issue 1780163002: Revert of IntersectionObserver: use an idle callback to send notifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 4 years, 9 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/js-test.js"></script> 2 <script src="../resources/js-test.js"></script>
3 <script src="helper-functions.js"></script> 3 <script src="helper-functions.js"></script>
4 <style> 4 <style>
5 #root { 5 #root {
6 width: 200px; 6 width: 200px;
7 height: 200px; 7 height: 200px;
8 overflow-y: scroll; 8 overflow-y: scroll;
9 } 9 }
10 #target { 10 #target {
11 width: 100px; 11 width: 100px;
12 height: 100px; 12 height: 100px;
13 background-color: green; 13 background-color: green;
14 position: absolute; 14 position: absolute;
15 } 15 }
16 </style> 16 </style>
17 <div id="root" style="position: absolute"> 17 <div id="root" style="position: absolute">
18 <div id="target" style="left: 50px; top: 250px"></div> 18 <div id="target" style="left: 50px; top: 250px"></div>
19 </div> 19 </div>
20 20
21 <script> 21 <script>
22 description("Test that no notifications are generated when root is not in the co ntaining block chain of target."); 22 description("Test that no notifications are generated when root is not in the containing block chain of target.");
23 var root = document.getElementById("root"); 23 var root = document.getElementById("root");
24 var target = document.getElementById("target"); 24 var target = document.getElementById("target");
25 var entries = []; 25 var entries = [];
26 26
27 var observer = new IntersectionObserver( 27 function observer_callback(changes) {
28 changes => { entries = entries.concat(changes) }, 28 changes.forEach(function(e) { entries.push(e) });
29 { root: root } 29 }
30 ); 30 new IntersectionObserver(observer_callback, {root: root}).observe(target);
31 31
32 onload = function() { 32 function step0() {
33 observer.observe(target); 33 setTimeout(function() {
34 shouldBeEqualToNumber("entries.length", 0); 34 shouldBeEqualToNumber("entries.length", 0);
35 target.style.top = "10px"; 35 target.style.top = "10px";
36 // See README for explanation of double RAF. 36 requestAnimationFrame(step1);
37 requestAnimationFrame(() => { requestAnimationFrame(step1) }); 37 });
38 }; 38 }
39 39
40 function step1() { 40 function step1() {
41 entries = entries.concat(observer.takeRecords()); 41 setTimeout(function() {
42 shouldBeEqualToNumber("entries.length", 1); 42 shouldBeEqualToNumber("entries.length", 1);
43 if (entries.length > 0) { 43 shouldBeEqualToNumber("entries[0].boundingClientRect.left", 58);
44 shouldBeEqualToNumber("entries[0].boundingClientRect.left", 58); 44 shouldBeEqualToNumber("entries[0].boundingClientRect.right", 158);
45 shouldBeEqualToNumber("entries[0].boundingClientRect.right", 158); 45 shouldBeEqualToNumber("entries[0].boundingClientRect.top", 18);
46 shouldBeEqualToNumber("entries[0].boundingClientRect.top", 18); 46 shouldBeEqualToNumber("entries[0].boundingClientRect.bottom", 118);
47 shouldBeEqualToNumber("entries[0].boundingClientRect.bottom", 118); 47 shouldBeEqualToNumber("entries[0].intersectionRect.left", 58);
48 shouldBeEqualToNumber("entries[0].intersectionRect.left", 58); 48 shouldBeEqualToNumber("entries[0].intersectionRect.right", 158);
49 shouldBeEqualToNumber("entries[0].intersectionRect.right", 158); 49 shouldBeEqualToNumber("entries[0].intersectionRect.top", 18);
50 shouldBeEqualToNumber("entries[0].intersectionRect.top", 18); 50 shouldBeEqualToNumber("entries[0].intersectionRect.bottom", 118);
51 shouldBeEqualToNumber("entries[0].intersectionRect.bottom", 118); 51 shouldBeEqualToNumber("entries[0].rootBounds.left", 8);
52 shouldBeEqualToNumber("entries[0].rootBounds.left", 8); 52 shouldBeEqualToNumber("entries[0].rootBounds.right", 193);
53 shouldBeEqualToNumber("entries[0].rootBounds.right", 193); 53 shouldBeEqualToNumber("entries[0].rootBounds.top", 8);
54 shouldBeEqualToNumber("entries[0].rootBounds.top", 8); 54 shouldBeEqualToNumber("entries[0].rootBounds.bottom", 208);
55 shouldBeEqualToNumber("entries[0].rootBounds.bottom", 208); 55 shouldEvaluateToSameObject("entries[0].target", target);
56 shouldEvaluateToSameObject("entries[0].target", target); 56 target.style.top = "250px";
57 requestAnimationFrame(step2);
58 });
57 } 59 }
58 target.style.top = "250px";
59 requestAnimationFrame(step2);
60 }
61 60
62 function step2() { 61 function step2() {
63 entries = entries.concat(observer.takeRecords()); 62 setTimeout(function() {
64 shouldBeEqualToNumber("entries.length", 2); 63 shouldBeEqualToNumber("entries.length", 2);
65 if (entries.length > 1) { 64 shouldBeEqualToNumber("entries[1].boundingClientRect.left", 58);
66 shouldBeEqualToNumber("entries[1].boundingClientRect.left", 58); 65 shouldBeEqualToNumber("entries[1].boundingClientRect.right", 158);
67 shouldBeEqualToNumber("entries[1].boundingClientRect.right", 158); 66 shouldBeEqualToNumber("entries[1].boundingClientRect.top", 258);
68 shouldBeEqualToNumber("entries[1].boundingClientRect.top", 258); 67 shouldBeEqualToNumber("entries[1].boundingClientRect.bottom", 358);
69 shouldBeEqualToNumber("entries[1].boundingClientRect.bottom", 358); 68 shouldBeEqualToNumber("entries[1].intersectionRect.left", 0);
70 shouldBeEqualToNumber("entries[1].intersectionRect.left", 0); 69 shouldBeEqualToNumber("entries[1].intersectionRect.right", 0);
71 shouldBeEqualToNumber("entries[1].intersectionRect.right", 0); 70 shouldBeEqualToNumber("entries[1].intersectionRect.top", 0);
72 shouldBeEqualToNumber("entries[1].intersectionRect.top", 0); 71 shouldBeEqualToNumber("entries[1].intersectionRect.bottom", 0);
73 shouldBeEqualToNumber("entries[1].intersectionRect.bottom", 0); 72 shouldBeEqualToNumber("entries[1].rootBounds.left", 8);
74 shouldBeEqualToNumber("entries[1].rootBounds.left", 8); 73 shouldBeEqualToNumber("entries[1].rootBounds.right", 193);
75 shouldBeEqualToNumber("entries[1].rootBounds.right", 193); 74 shouldBeEqualToNumber("entries[1].rootBounds.top", 8);
76 shouldBeEqualToNumber("entries[1].rootBounds.top", 8); 75 shouldBeEqualToNumber("entries[1].rootBounds.bottom", 208);
77 shouldBeEqualToNumber("entries[1].rootBounds.bottom", 208); 76 shouldEvaluateToSameObject("entries[1].target", target);
78 shouldEvaluateToSameObject("entries[1].target", target); 77 root.style.position = "static";
78 target.style.top = "10px";
79 requestAnimationFrame(step3);
80 });
79 } 81 }
80 root.style.position = "static";
81 target.style.top = "10px";
82 requestAnimationFrame(step3);
83 }
84 82
85 function step3() { 83 function step3() {
86 entries = entries.concat(observer.takeRecords()); 84 setTimeout(function() {
87 shouldBeEqualToNumber("entries.length", 2); 85 shouldBeEqualToNumber("entries.length", 2);
88 target.style.top = "250px"; 86 target.style.top = "250px";
89 requestAnimationFrame(step4); 87 requestAnimationFrame(step4);
90 } 88 });
89 }
91 90
92 function step4() { 91 function step4() {
93 entries = entries.concat(observer.takeRecords()); 92 setTimeout(function() {
94 shouldBeEqualToNumber("entries.length", 2); 93 shouldBeEqualToNumber("entries.length", 2);
95 finishJSTest(); 94 finishJSTest();
96 } 95 });
96 }
97
98 step0();
97 </script> 99 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698