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

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

Issue 1449623002: IntersectionObserver: second cut. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Fix rootMargin parsing Created 5 years 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
(Empty)
1 <!DOCTYPE html>
2 <div style="width:100%;height:700px;"></div>
3 <div id="root" style="display: inline-block; overflow-y: scroll; height: 200px;" >
4 <div id="target" style="width:100px; height:300px"></div>
5 <iframe id="target-iframe" src="subframe.html" style="width: 300px; height: 10 0px; overflow-y: scroll" onload="runtests()"></iframe>
6 </div>
7 <div style="width:100%; height:700px;"></div>
8
9 <script src="../resources/js-test.js"></script>
10 <script src="helper-functions.js"></script>
11 <script>
12 description("Simple intersection observer test with no explicit root and target in an iframe.");
13 var entries = [];
14
15 function runtests() {
16 var root = document.getElementById("root");
17 var targetIframe = document.getElementById("target-iframe");
18 var target = targetIframe.contentDocument.getElementById("target");
19 var iframeScroller = targetIframe.contentDocument.scrollingElement;
20
21 observer_callback = function(changes) {
22 for (var i in changes) {
23 console.log(entryToString(changes[i]));
24 entries.push(changes[i]);
25 }
26 };
27 var observer = new IntersectionObserver(observer_callback, {"root": document.g etElementById("root")});
28 observer.observe(target);
29
30 // TODO: It shouldn't be necessary to RAF after the call to observer()
31 // and before changing the scroll position, but it is.
32
33 var expected0 = [];
34 function step0() {
35 setTimeout(function() {
36 checkResults(expected0, "entries");
37 document.scrollingElement.scrollTop = 250;
38 requestAnimationFrame(step1);
39 });
40 }
41
42 var expected1 = [];
43 function step1() {
44 setTimeout(function() {
45 checkResults(expected1, "entries");
46 iframeScroller.scrollTop = 200;
47 requestAnimationFrame(step2);
48 });
49 }
50
51 var expected2 = [];
52 function step2() {
53 setTimeout(function() {
54 checkResults(expected2, "entries");
55 root.scrollTop = 175;
56 requestAnimationFrame(step3);
57 });
58 }
59
60 var expected3 = [
61 {
62 'boundingClientRect': [ 18, 118, 593, 693 ],
63 'intersectionRect': [ 18, 118, 593, 658 ],
64 'rootBounds' : [ 8, 312, 458, 658 ],
65 'target': target
66 }
67 ];
68 function step3() {
69 setTimeout(function() {
70 checkResults(expected3, "entries");
71 document.scrollingElement.scrollTop = 100;
72 requestAnimationFrame(step4);
73 });
74 }
75
76 var expected4 = expected3;
77 function step4() {
78 setTimeout(function() {
79 checkResults(expected4, "entries", 1);
80 root.scrollTop = 100;
81 requestAnimationFrame(step5);
82 });
83 }
84
85 var expected5 = expected4.concat([
86 {
87 'boundingClientRect': [ 18, 118, 818, 918 ],
88 'intersectionRect': [ 0, 0, 0, 0 ],
89 'rootBounds' : [ 8, 312, 608, 808 ],
90 'target': target
91 }
92 ]);
93 function step5() {
94 setTimeout(function() {
95 checkResults(expected5, "entries", 1);
96 finishTest();
97 document.scrollingElement.scrollTop = 0;
98 });
99 }
100
101 requestAnimationFrame(step0);
102 }
103 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698