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

Side by Side Diff: third_party/WebKit/LayoutTests/intersection-observer/iframe-no-root.html

Issue 1983383002: Convert IntersectionObserver tests to use testRunner.runIdleTasks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: rebase Created 4 years, 7 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="../resources/intersection-observer-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) }, {}); 11 var observer = new IntersectionObserver(changes => { entries = entries.concat(ch anges) }, {});
12 var targetIframe = document.getElementById("target-iframe"); 12 var targetIframe = document.getElementById("target-iframe");
13 var target; 13 var target;
14 var iframeScroller; 14 var iframeScroller;
15 15
16 targetIframe.onload = function() { 16 targetIframe.onload = function() {
17 target = targetIframe.contentDocument.getElementById("target"); 17 target = targetIframe.contentDocument.getElementById("target");
18 iframeScroller = targetIframe.contentDocument.scrollingElement; 18 iframeScroller = targetIframe.contentDocument.scrollingElement;
19 observer.observe(target); 19 observer.observe(target);
20 entries = entries.concat(observer.takeRecords()); 20 entries = entries.concat(observer.takeRecords());
21 shouldBeEqualToNumber("entries.length", 0); 21 shouldBeEqualToNumber("entries.length", 0);
22 // See README for explanation of double RAF. 22 waitForNotification(step0);
23 requestAnimationFrame(() => { requestAnimationFrame(step0) });
24 } 23 }
25 24
26 function step0() { 25 function step0() {
27 entries = entries.concat(observer.takeRecords());
28 shouldBeEqualToNumber("entries.length", 0); 26 shouldBeEqualToNumber("entries.length", 0);
29 document.scrollingElement.scrollTop = 200; 27 document.scrollingElement.scrollTop = 200;
30 requestAnimationFrame(step1); 28 waitForNotification(step1);
31 } 29 }
32 30
33 function step1() { 31 function step1() {
34 entries = entries.concat(observer.takeRecords());
35 shouldBeEqualToNumber("entries.length", 0); 32 shouldBeEqualToNumber("entries.length", 0);
36 iframeScroller.scrollTop = 250; 33 iframeScroller.scrollTop = 250;
37 requestAnimationFrame(step2); 34 waitForNotification(step2);
38 } 35 }
39 36
40 function step2() { 37 function step2() {
41 entries = entries.concat(observer.takeRecords());
42 shouldBeEqualToNumber("entries.length", 1); 38 shouldBeEqualToNumber("entries.length", 1);
43 if (entries.length > 0) { 39 if (entries.length > 0) {
44 shouldBeEqualToNumber("entries[0].boundingClientRect.left", 8); 40 shouldBeEqualToNumber("entries[0].boundingClientRect.left", 8);
45 shouldBeEqualToNumber("entries[0].boundingClientRect.right", 108); 41 shouldBeEqualToNumber("entries[0].boundingClientRect.right", 108);
46 shouldBeEqualToNumber("entries[0].boundingClientRect.top", -42); 42 shouldBeEqualToNumber("entries[0].boundingClientRect.top", -42);
47 shouldBeEqualToNumber("entries[0].boundingClientRect.bottom", 58); 43 shouldBeEqualToNumber("entries[0].boundingClientRect.bottom", 58);
48 shouldBeEqualToNumber("entries[0].intersectionRect.left", 8); 44 shouldBeEqualToNumber("entries[0].intersectionRect.left", 8);
49 shouldBeEqualToNumber("entries[0].intersectionRect.right", 108); 45 shouldBeEqualToNumber("entries[0].intersectionRect.right", 108);
50 shouldBeEqualToNumber("entries[0].intersectionRect.top", 0); 46 shouldBeEqualToNumber("entries[0].intersectionRect.top", 0);
51 shouldBeEqualToNumber("entries[0].intersectionRect.bottom", 58); 47 shouldBeEqualToNumber("entries[0].intersectionRect.bottom", 58);
52 shouldBeEqualToNumber("entries[0].rootBounds.left", 0); 48 shouldBeEqualToNumber("entries[0].rootBounds.left", 0);
53 shouldBeEqualToNumber("entries[0].rootBounds.right", 785); 49 shouldBeEqualToNumber("entries[0].rootBounds.right", 785);
54 shouldBeEqualToNumber("entries[0].rootBounds.top", 0); 50 shouldBeEqualToNumber("entries[0].rootBounds.top", 0);
55 shouldBeEqualToNumber("entries[0].rootBounds.bottom", 600); 51 shouldBeEqualToNumber("entries[0].rootBounds.bottom", 600);
56 shouldEvaluateToSameObject("entries[0].target", target); 52 shouldEvaluateToSameObject("entries[0].target", target);
57 } 53 }
58 document.scrollingElement.scrollTop = 100; 54 document.scrollingElement.scrollTop = 100;
59 requestAnimationFrame(step3); 55 waitForNotification(step3);
60 } 56 }
61 57
62 function step3() { 58 function step3() {
63 entries = entries.concat(observer.takeRecords());
64 shouldBeEqualToNumber("entries.length", 2); 59 shouldBeEqualToNumber("entries.length", 2);
65 if (entries.length > 1) { 60 if (entries.length > 1) {
66 shouldBeEqualToNumber("entries[1].boundingClientRect.left", 8); 61 shouldBeEqualToNumber("entries[1].boundingClientRect.left", 8);
67 shouldBeEqualToNumber("entries[1].boundingClientRect.right", 108); 62 shouldBeEqualToNumber("entries[1].boundingClientRect.right", 108);
68 shouldBeEqualToNumber("entries[1].boundingClientRect.top", -42); 63 shouldBeEqualToNumber("entries[1].boundingClientRect.top", -42);
69 shouldBeEqualToNumber("entries[1].boundingClientRect.bottom", 58); 64 shouldBeEqualToNumber("entries[1].boundingClientRect.bottom", 58);
70 shouldBeEqualToNumber("entries[1].intersectionRect.left", 0); 65 shouldBeEqualToNumber("entries[1].intersectionRect.left", 0);
71 shouldBeEqualToNumber("entries[1].intersectionRect.right", 0); 66 shouldBeEqualToNumber("entries[1].intersectionRect.right", 0);
72 shouldBeEqualToNumber("entries[1].intersectionRect.top", 0); 67 shouldBeEqualToNumber("entries[1].intersectionRect.top", 0);
73 shouldBeEqualToNumber("entries[1].intersectionRect.bottom", 0); 68 shouldBeEqualToNumber("entries[1].intersectionRect.bottom", 0);
74 shouldBeEqualToNumber("entries[1].rootBounds.left", 0); 69 shouldBeEqualToNumber("entries[1].rootBounds.left", 0);
75 shouldBeEqualToNumber("entries[1].rootBounds.right", 785); 70 shouldBeEqualToNumber("entries[1].rootBounds.right", 785);
76 shouldBeEqualToNumber("entries[1].rootBounds.top", 0); 71 shouldBeEqualToNumber("entries[1].rootBounds.top", 0);
77 shouldBeEqualToNumber("entries[1].rootBounds.bottom", 600); 72 shouldBeEqualToNumber("entries[1].rootBounds.bottom", 600);
78 shouldEvaluateToSameObject("entries[1].target", target); 73 shouldEvaluateToSameObject("entries[1].target", target);
79 } 74 }
80 finishJSTest(); 75 finishJSTest();
81 document.scrollingElement.scrollTop = 0; 76 document.scrollingElement.scrollTop = 0;
82 } 77 }
83 </script> 78 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698