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

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: Implemented root margin 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>
esprehn 2015/12/12 00:14:12 space after ; to be consistent?
szager1 2015/12/16 19:15:33 Done.
3 <iframe id="target-iframe" src="../resources/intersection-observer-subframe.html " style="height: 100px; overflow-y: scroll" onload="runtests()"></iframe>
esprehn 2015/12/12 00:14:12 runTests(), but just wait for onload, doesn't that
szager1 2015/12/16 19:15:33 Done.
4 <div style="width:100%; height:700px;"></div>
5
6 <script src="../resources/js-test.js"></script>
7 <script src="helper-functions.js"></script>
esprehn 2015/12/12 00:14:12 these should always be first, before the test stuf
szager1 2015/12/16 19:15:33 Done.
8 <script>
9 description("Simple intersection observer test with no explicit root and target in an iframe.");
10 var entries = [];
11
12 function runtests() {
esprehn 2015/12/12 00:14:12 onload = function() {
szager1 2015/12/16 19:15:33 Done.
13 var targetIframe = document.getElementById("target-iframe");
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: It shouldn't be necessary to RAF after the call to observer()
25 // and before changing the scroll position, but it is.
26
27 var expected0 = [];
28 function step0() {
29 setTimeout(function() {
30 checkResults(expected0, "entries");
31 document.scrollingElement.scrollTop = 200;
32 requestAnimationFrame(step1);
33 });
34 }
35
36 var expected1 = [];
37 function step1() {
38 setTimeout(function() {
39 checkResults(expected1, "entries");
40 iframeScroller.scrollTop = 250;
41 requestAnimationFrame(step2);
42 });
43 }
44
45 var expected2 = [
46 {
47 'boundingClientRect': [ 18, 118, 468, 568 ],
esprehn 2015/12/12 00:14:12 no quotes needed
szager1 2015/12/16 19:15:33 I removed all of the 'expected' variables, here an
48 'intersectionRect': [ 18, 118, 510, 568],
49 'rootBounds' : [ 0, 785, 0, 600 ],
50 'target': target
51 }
52 ];
53 function step2() {
54 setTimeout(function() {
55 checkResults(expected2, "entries");
56 document.scrollingElement.scrollTop = 100;
57 requestAnimationFrame(step3);
58 });
59 }
60
61 var expected3 = expected2.concat([
62 {
63 'boundingClientRect': [ 18, 118, 568, 668 ],
64 'intersectionRect': [ 0, 0, 0, 0 ],
esprehn 2015/12/12 00:14:12 remove quotes
szager1 2015/12/16 19:15:33 Same.
65 'rootBounds' : [ 0, 785, 0, 600 ],
66 'target': target
67 }
68 ]);
69 function step3() {
70 setTimeout(function() {
71 checkResults(expected3, "entries", 1);
esprehn 2015/12/12 00:14:12 these tests are super hard to debug since the asse
szager1 2015/12/16 19:15:33 Inlined all asserts.
72 finishTest();
73 document.scrollingElement.scrollTop = 0;
74 });
75 }
76
77 requestAnimationFrame(step0);
78 }
79 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698