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

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

Issue 1449623002: IntersectionObserver: second cut. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Add RuntimeEnabled flags to all idl's, fix test expectations. Created 4 years, 11 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
(Empty)
1 <!DOCTYPE html>
2 <script src="../resources/js-test.js"></script>
3 <script src="helper-functions.js"></script>
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>
6 <div style="width:100%; height:700px;"></div>
7
8 <script>
9 description("Simple intersection observer test with no explicit root and target in an iframe.");
10 var entries = [];
11 var targetIframe = document.getElementById("target-iframe");
12
13 targetIframe.onload = function() {
14 var target = targetIframe.contentDocument.getElementById("target");
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, {});
22 observer.observe(target);
23
24 // TODO(szager): It shouldn't be necessary to RAF after the call to observer()
25 // and before changing the scroll position, but it is.
26
27 function step0() {
28 setTimeout(function() {
29 shouldBeEqualToNumber("entries.length", 0);
30 document.scrollingElement.scrollTop = 200;
31 requestAnimationFrame(step1);
32 });
33 }
34
35 function step1() {
36 setTimeout(function() {
37 shouldBeEqualToNumber("entries.length", 0);
38 iframeScroller.scrollTop = 250;
39 requestAnimationFrame(step2);
40 });
41 }
42
43 function step2() {
44 setTimeout(function() {
45 shouldBeEqualToNumber("entries.length", 1);
46 shouldBeEqualToNumber("entries[0].boundingClientRect.left", 18);
47 shouldBeEqualToNumber("entries[0].boundingClientRect.right", 118);
48 shouldBeEqualToNumber("entries[0].boundingClientRect.top", 468);
49 shouldBeEqualToNumber("entries[0].boundingClientRect.bottom", 568);
50 shouldBeEqualToNumber("entries[0].intersectionRect.left", 18);
51 shouldBeEqualToNumber("entries[0].intersectionRect.right", 118);
52 shouldBeEqualToNumber("entries[0].intersectionRect.top", 510);
53 shouldBeEqualToNumber("entries[0].intersectionRect.bottom", 568);
54 shouldBeEqualToNumber("entries[0].rootBounds.left", 0);
55 shouldBeEqualToNumber("entries[0].rootBounds.right", 785);
56 shouldBeEqualToNumber("entries[0].rootBounds.top", 0);
57 shouldBeEqualToNumber("entries[0].rootBounds.bottom", 600);
58 shouldEvaluateToSameObject("entries[0].target", target);
59 document.scrollingElement.scrollTop = 100;
60 requestAnimationFrame(step3);
61 });
62 }
63
64 function step3() {
65 setTimeout(function() {
66 shouldBeEqualToNumber("entries.length", 2);
67 shouldBeEqualToNumber("entries[1].boundingClientRect.left", 18);
68 shouldBeEqualToNumber("entries[1].boundingClientRect.right", 118);
69 shouldBeEqualToNumber("entries[1].boundingClientRect.top", 568);
70 shouldBeEqualToNumber("entries[1].boundingClientRect.bottom", 668);
71 shouldBeEqualToNumber("entries[1].intersectionRect.left", 0);
72 shouldBeEqualToNumber("entries[1].intersectionRect.right", 0);
73 shouldBeEqualToNumber("entries[1].intersectionRect.top", 0);
74 shouldBeEqualToNumber("entries[1].intersectionRect.bottom", 0);
75 shouldBeEqualToNumber("entries[1].rootBounds.left", 0);
76 shouldBeEqualToNumber("entries[1].rootBounds.right", 785);
77 shouldBeEqualToNumber("entries[1].rootBounds.top", 0);
78 shouldBeEqualToNumber("entries[1].rootBounds.bottom", 600);
79 shouldEvaluateToSameObject("entries[1].target", target);
80 finishTest();
81 document.scrollingElement.scrollTop = 0;
82 });
83 }
84
85 requestAnimationFrame(step0);
86 }
87 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698