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

Side by Side Diff: third_party/WebKit/LayoutTests/intersection-observer/iframe-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 <iframe id="target-iframe" src="../resources/intersection-observer-subframe.html " style="height: 100px; overflow-y: scroll"></iframe> 5 <iframe id="target-iframe" src="../resources/intersection-observer-subframe.html " style="height: 100px; overflow-y: scroll"></iframe>
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 target in an iframe."); 9 description("Simple intersection observer test with no explicit root and target in an iframe.");
10 var entries = []; 10 var entries = [];
11 var observer = new IntersectionObserver(changes => { entries = entries.concat(ch anges) }, {});
12 var targetIframe = document.getElementById("target-iframe"); 11 var targetIframe = document.getElementById("target-iframe");
13 var target;
14 var iframeScroller;
15 12
16 targetIframe.onload = function() { 13 targetIframe.onload = function() {
17 target = targetIframe.contentDocument.getElementById("target"); 14 var target = targetIframe.contentDocument.getElementById("target");
18 iframeScroller = targetIframe.contentDocument.scrollingElement; 15 var iframeScroller = targetIframe.contentDocument.scrollingElement;
16
17 observer_callback = function(changes) {
18 for (var i in changes)
19 entries.push(changes[i]);
20 };
21 var observer = new IntersectionObserver(observer_callback, {});
19 observer.observe(target); 22 observer.observe(target);
20 entries = entries.concat(observer.takeRecords());
21 shouldBeEqualToNumber("entries.length", 0);
22 // See README for explanation of double RAF.
23 requestAnimationFrame(() => { requestAnimationFrame(step0) });
24 }
25 23
26 function step0() { 24 function step0() {
27 entries = entries.concat(observer.takeRecords()); 25 setTimeout(function() {
28 shouldBeEqualToNumber("entries.length", 0); 26 shouldBeEqualToNumber("entries.length", 0);
29 document.scrollingElement.scrollTop = 200; 27 document.scrollingElement.scrollTop = 200;
30 requestAnimationFrame(step1); 28 requestAnimationFrame(step1);
31 } 29 });
30 }
32 31
33 function step1() { 32 function step1() {
34 entries = entries.concat(observer.takeRecords()); 33 setTimeout(function() {
35 shouldBeEqualToNumber("entries.length", 0); 34 shouldBeEqualToNumber("entries.length", 0);
36 iframeScroller.scrollTop = 250; 35 iframeScroller.scrollTop = 250;
37 requestAnimationFrame(step2); 36 requestAnimationFrame(step2);
38 } 37 });
38 }
39 39
40 function step2() { 40 function step2() {
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 if (entries.length > 0) {
44 shouldBeEqualToNumber("entries[0].boundingClientRect.left", 8); 44 shouldBeEqualToNumber("entries[0].boundingClientRect.left", 8);
45 shouldBeEqualToNumber("entries[0].boundingClientRect.right", 108); 45 shouldBeEqualToNumber("entries[0].boundingClientRect.right", 108);
46 shouldBeEqualToNumber("entries[0].boundingClientRect.top", -42); 46 shouldBeEqualToNumber("entries[0].boundingClientRect.top", -42);
47 shouldBeEqualToNumber("entries[0].boundingClientRect.bottom", 58); 47 shouldBeEqualToNumber("entries[0].boundingClientRect.bottom", 58);
48 shouldBeEqualToNumber("entries[0].intersectionRect.left", 8); 48 shouldBeEqualToNumber("entries[0].intersectionRect.left", 8);
49 shouldBeEqualToNumber("entries[0].intersectionRect.right", 108); 49 shouldBeEqualToNumber("entries[0].intersectionRect.right", 108);
50 shouldBeEqualToNumber("entries[0].intersectionRect.top", 0); 50 shouldBeEqualToNumber("entries[0].intersectionRect.top", 0);
51 shouldBeEqualToNumber("entries[0].intersectionRect.bottom", 58); 51 shouldBeEqualToNumber("entries[0].intersectionRect.bottom", 58);
52 shouldBeEqualToNumber("entries[0].rootBounds.left", 0); 52 shouldBeEqualToNumber("entries[0].rootBounds.left", 0);
53 shouldBeEqualToNumber("entries[0].rootBounds.right", 785); 53 shouldBeEqualToNumber("entries[0].rootBounds.right", 785);
54 shouldBeEqualToNumber("entries[0].rootBounds.top", 0); 54 shouldBeEqualToNumber("entries[0].rootBounds.top", 0);
55 shouldBeEqualToNumber("entries[0].rootBounds.bottom", 600); 55 shouldBeEqualToNumber("entries[0].rootBounds.bottom", 600);
56 shouldEvaluateToSameObject("entries[0].target", target); 56 shouldEvaluateToSameObject("entries[0].target", target);
57 }
58 document.scrollingElement.scrollTop = 100;
59 requestAnimationFrame(step3);
60 });
57 } 61 }
58 document.scrollingElement.scrollTop = 100;
59 requestAnimationFrame(step3);
60 }
61 62
62 function step3() { 63 function step3() {
63 entries = entries.concat(observer.takeRecords()); 64 setTimeout(function() {
64 shouldBeEqualToNumber("entries.length", 2); 65 shouldBeEqualToNumber("entries.length", 2);
65 if (entries.length > 1) { 66 if (entries.length > 1) {
66 shouldBeEqualToNumber("entries[1].boundingClientRect.left", 8); 67 shouldBeEqualToNumber("entries[1].boundingClientRect.left", 8);
67 shouldBeEqualToNumber("entries[1].boundingClientRect.right", 108); 68 shouldBeEqualToNumber("entries[1].boundingClientRect.right", 108);
68 shouldBeEqualToNumber("entries[1].boundingClientRect.top", -42); 69 shouldBeEqualToNumber("entries[1].boundingClientRect.top", -42);
69 shouldBeEqualToNumber("entries[1].boundingClientRect.bottom", 58); 70 shouldBeEqualToNumber("entries[1].boundingClientRect.bottom", 58);
70 shouldBeEqualToNumber("entries[1].intersectionRect.left", 0); 71 shouldBeEqualToNumber("entries[1].intersectionRect.left", 0);
71 shouldBeEqualToNumber("entries[1].intersectionRect.right", 0); 72 shouldBeEqualToNumber("entries[1].intersectionRect.right", 0);
72 shouldBeEqualToNumber("entries[1].intersectionRect.top", 0); 73 shouldBeEqualToNumber("entries[1].intersectionRect.top", 0);
73 shouldBeEqualToNumber("entries[1].intersectionRect.bottom", 0); 74 shouldBeEqualToNumber("entries[1].intersectionRect.bottom", 0);
74 shouldBeEqualToNumber("entries[1].rootBounds.left", 0); 75 shouldBeEqualToNumber("entries[1].rootBounds.left", 0);
75 shouldBeEqualToNumber("entries[1].rootBounds.right", 785); 76 shouldBeEqualToNumber("entries[1].rootBounds.right", 785);
76 shouldBeEqualToNumber("entries[1].rootBounds.top", 0); 77 shouldBeEqualToNumber("entries[1].rootBounds.top", 0);
77 shouldBeEqualToNumber("entries[1].rootBounds.bottom", 600); 78 shouldBeEqualToNumber("entries[1].rootBounds.bottom", 600);
78 shouldEvaluateToSameObject("entries[1].target", target); 79 shouldEvaluateToSameObject("entries[1].target", target);
80 }
81 finishJSTest();
82 document.scrollingElement.scrollTop = 0;
83 });
79 } 84 }
80 finishJSTest(); 85
81 document.scrollingElement.scrollTop = 0; 86 step0();
82 } 87 }
83 </script> 88 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698