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

Side by Side Diff: third_party/WebKit/LayoutTests/intersection-observer/same-document-no-root.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 <div style="width:100%; height:700px;"></div> 4 <div style="width:100%; height:700px;"></div>
5 <div id="target" style="background-color: green; width:100px; height:100px"></di v> 5 <div id="target" style="background-color: green; width:100px; height:100px"></di v>
6 <div style="width:100%; height:700px;"></div> 6 <div style="width:100%; height:700px;"></div>
7 7
8 <script> 8 <script>
9 description("Simple intersection observer test with no explicit root and one doc ument."); 9 description("Simple intersection observer test with no explicit root and one d ocument.");
10 var target = document.getElementById("target"); 10 var target = document.getElementById("target");
11 var entries = []; 11 var entries = [];
12 var observer = new IntersectionObserver(changes => { entries = entries.concat(ch anges) }); 12 observer_callback = function(changes) {
13 for (var i in changes)
14 entries.push(changes[i]);
15 };
16 var observer = new IntersectionObserver(observer_callback, {});
17 observer.observe(target);
13 18
14 onload = function() { 19 onload = function() {
15 observer.observe(target); 20 shouldBeEqualToNumber("entries.length", 0);
16 entries = entries.concat(observer.takeRecords()); 21 document.scrollingElement.scrollTop = 300;
17 shouldBeEqualToNumber("entries.length", 0); 22 requestAnimationFrame(step1);
18 document.scrollingElement.scrollTop = 300; 23 };
19 // See README for explanation of double RAF.
20 requestAnimationFrame(() => { requestAnimationFrame(step1) });
21 };
22 24
23 function step1() { 25 function step1() {
24 entries = entries.concat(observer.takeRecords()); 26 setTimeout(function() {
25 shouldBeEqualToNumber("entries.length", 1); 27 shouldBeEqualToNumber("entries.length", 1);
26 if (entries.length > 0) { 28 shouldBeEqualToNumber("entries[0].boundingClientRect.left", 8);
27 shouldBeEqualToNumber("entries[0].boundingClientRect.left", 8); 29 shouldBeEqualToNumber("entries[0].boundingClientRect.right", 108);
28 shouldBeEqualToNumber("entries[0].boundingClientRect.right", 108); 30 shouldBeEqualToNumber("entries[0].boundingClientRect.top", 408);
29 shouldBeEqualToNumber("entries[0].boundingClientRect.top", 408); 31 shouldBeEqualToNumber("entries[0].boundingClientRect.bottom", 508);
30 shouldBeEqualToNumber("entries[0].boundingClientRect.bottom", 508); 32 shouldBeEqualToNumber("entries[0].intersectionRect.left", 8);
31 shouldBeEqualToNumber("entries[0].intersectionRect.left", 8); 33 shouldBeEqualToNumber("entries[0].intersectionRect.right", 108);
32 shouldBeEqualToNumber("entries[0].intersectionRect.right", 108); 34 shouldBeEqualToNumber("entries[0].intersectionRect.top", 408);
33 shouldBeEqualToNumber("entries[0].intersectionRect.top", 408); 35 shouldBeEqualToNumber("entries[0].intersectionRect.bottom", 508);
34 shouldBeEqualToNumber("entries[0].intersectionRect.bottom", 508); 36 shouldBeEqualToNumber("entries[0].rootBounds.left", 0);
35 shouldBeEqualToNumber("entries[0].rootBounds.left", 0); 37 shouldBeEqualToNumber("entries[0].rootBounds.right", 785);
36 shouldBeEqualToNumber("entries[0].rootBounds.right", 785); 38 shouldBeEqualToNumber("entries[0].rootBounds.top", 0);
37 shouldBeEqualToNumber("entries[0].rootBounds.top", 0); 39 shouldBeEqualToNumber("entries[0].rootBounds.bottom", 600);
38 shouldBeEqualToNumber("entries[0].rootBounds.bottom", 600); 40 shouldEvaluateToSameObject("entries[0].target", target);
39 shouldEvaluateToSameObject("entries[0].target", target);
40 41
41 // ClientRect members of IntersectionObserverEntry should be stable. 42 // ClientRect members of IntersectionObserverEntry should be stable.
42 shouldEvaluateToSameObject("entries[0].boundingClientRect", entries[0].bound ingClientRect); 43 shouldEvaluateToSameObject("entries[0].boundingClientRect", entries[0].bou ndingClientRect);
43 shouldEvaluateToSameObject("entries[0].intersectionRect", entries[0].interse ctionRect); 44 shouldEvaluateToSameObject("entries[0].intersectionRect", entries[0].inter sectionRect);
44 shouldEvaluateToSameObject("entries[0].rootBounds", entries[0].rootBounds); 45 shouldEvaluateToSameObject("entries[0].rootBounds", entries[0].rootBounds) ;
46
47 document.scrollingElement.scrollTop = 100;
48 requestAnimationFrame(step2);
49 });
45 } 50 }
46 document.scrollingElement.scrollTop = 100;
47 requestAnimationFrame(step2);
48 }
49 51
50 function step2() { 52 function step2() {
51 entries = entries.concat(observer.takeRecords()); 53 setTimeout(function() {
52 shouldBeEqualToNumber("entries.length", 2); 54 shouldBeEqualToNumber("entries.length", 2);
53 if (entries.length > 1) { 55 shouldBeEqualToNumber("entries[1].boundingClientRect.left", 8);
54 shouldBeEqualToNumber("entries[1].boundingClientRect.left", 8); 56 shouldBeEqualToNumber("entries[1].boundingClientRect.right", 108);
55 shouldBeEqualToNumber("entries[1].boundingClientRect.right", 108); 57 shouldBeEqualToNumber("entries[1].boundingClientRect.top", 608);
56 shouldBeEqualToNumber("entries[1].boundingClientRect.top", 608); 58 shouldBeEqualToNumber("entries[1].boundingClientRect.bottom", 708);
57 shouldBeEqualToNumber("entries[1].boundingClientRect.bottom", 708); 59 shouldBeEqualToNumber("entries[1].intersectionRect.left", 0);
58 shouldBeEqualToNumber("entries[1].intersectionRect.left", 0); 60 shouldBeEqualToNumber("entries[1].intersectionRect.right", 0);
59 shouldBeEqualToNumber("entries[1].intersectionRect.right", 0); 61 shouldBeEqualToNumber("entries[1].intersectionRect.top", 0);
60 shouldBeEqualToNumber("entries[1].intersectionRect.top", 0); 62 shouldBeEqualToNumber("entries[1].intersectionRect.bottom", 0);
61 shouldBeEqualToNumber("entries[1].intersectionRect.bottom", 0); 63 shouldBeEqualToNumber("entries[1].rootBounds.left", 0);
62 shouldBeEqualToNumber("entries[1].rootBounds.left", 0); 64 shouldBeEqualToNumber("entries[1].rootBounds.right", 785);
63 shouldBeEqualToNumber("entries[1].rootBounds.right", 785); 65 shouldBeEqualToNumber("entries[1].rootBounds.top", 0);
64 shouldBeEqualToNumber("entries[1].rootBounds.top", 0); 66 shouldBeEqualToNumber("entries[1].rootBounds.bottom", 600);
65 shouldBeEqualToNumber("entries[1].rootBounds.bottom", 600); 67 shouldEvaluateToSameObject("entries[1].target", target);
66 shouldEvaluateToSameObject("entries[1].target", target); 68 finishJSTest();
69 document.scrollingElement.scrollTop = 0;
70 });
67 } 71 }
68 finishJSTest();
69 document.scrollingElement.scrollTop = 0;
70 }
71 72
72 </script> 73 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698