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

Unified 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: 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/intersection-observer/iframe-root.html
diff --git a/third_party/WebKit/LayoutTests/intersection-observer/iframe-root.html b/third_party/WebKit/LayoutTests/intersection-observer/iframe-root.html
new file mode 100644
index 0000000000000000000000000000000000000000..aee7c92f79bde0b43bd493b18aac4de29a966578
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/intersection-observer/iframe-root.html
@@ -0,0 +1,101 @@
+<!DOCTYPE html>
+<div style="width:100%;height:700px;"></div>
esprehn 2015/12/12 00:14:13 ditto
szager1 2015/12/16 19:15:34 Done.
+<div id="root" style="display: inline-block; overflow-y: scroll; height: 200px;">
+ <div id="target" style="width:100px; height:300px"></div>
+ <iframe id="target-iframe" src="../resources/intersection-observer-subframe.html" style="width: 300px; height: 100px; overflow-y: scroll" onload="runtests()"></iframe>
+</div>
+<div style="width:100%; height:700px;"></div>
+
+<script src="../resources/js-test.js"></script>
+<script src="helper-functions.js"></script>
esprehn 2015/12/12 00:14:12 ditto
szager1 2015/12/16 19:15:34 Done.
+<script>
+description("Simple intersection observer test with no explicit root and target in an iframe.");
+var entries = [];
+
+function runtests() {
esprehn 2015/12/12 00:14:12 ditto
szager1 2015/12/16 19:15:34 Done.
+ var root = document.getElementById("root");
+ var targetIframe = document.getElementById("target-iframe");
+ var target = targetIframe.contentDocument.getElementById("target");
+ var iframeScroller = targetIframe.contentDocument.scrollingElement;
+
+ observer_callback = function(changes) {
+ for (var i in changes)
+ entries.push(changes[i]);
+ };
+ var observer = new IntersectionObserver(observer_callback, {"root": document.getElementById("root")});
+ observer.observe(target);
+
+ // TODO: It shouldn't be necessary to RAF after the call to observer()
+ // and before changing the scroll position, but it is.
+
+ var expected0 = [];
+ function step0() {
+ setTimeout(function() {
+ checkResults(expected0, "entries");
+ document.scrollingElement.scrollTop = 250;
+ requestAnimationFrame(step1);
+ });
+ }
+
+ var expected1 = [];
+ function step1() {
+ setTimeout(function() {
+ checkResults(expected1, "entries");
+ iframeScroller.scrollTop = 200;
+ requestAnimationFrame(step2);
+ });
+ }
+
+ var expected2 = [];
+ function step2() {
+ setTimeout(function() {
+ checkResults(expected2, "entries");
+ root.scrollTop = 175;
+ requestAnimationFrame(step3);
+ });
+ }
+
+ var expected3 = [
+ {
+ 'boundingClientRect': [ 18, 118, 593, 693 ],
+ 'intersectionRect': [ 18, 118, 593, 658 ],
+ 'rootBounds' : [ 8, 312, 458, 658 ],
+ 'target': target
esprehn 2015/12/12 00:14:12 ditto
szager1 2015/12/16 19:15:33 Done.
+ }
+ ];
+ function step3() {
+ setTimeout(function() {
+ checkResults(expected3, "entries");
+ document.scrollingElement.scrollTop = 100;
+ requestAnimationFrame(step4);
+ });
+ }
+
+ var expected4 = expected3;
+ function step4() {
+ setTimeout(function() {
+ checkResults(expected4, "entries", 1);
+ root.scrollTop = 100;
+ requestAnimationFrame(step5);
+ });
+ }
+
+ var expected5 = expected4.concat([
+ {
+ 'boundingClientRect': [ 18, 118, 818, 918 ],
+ 'intersectionRect': [ 0, 0, 0, 0 ],
+ 'rootBounds' : [ 8, 312, 608, 808 ],
esprehn 2015/12/12 00:14:12 ditto
szager1 2015/12/16 19:15:33 Done.
+ 'target': target
+ }
+ ]);
+ function step5() {
+ setTimeout(function() {
+ checkResults(expected5, "entries", 1);
+ finishTest();
+ document.scrollingElement.scrollTop = 0;
+ });
+ }
+
+ requestAnimationFrame(step0);
+}
+</script>

Powered by Google App Engine
This is Rietveld 408576698