Index: third_party/WebKit/LayoutTests/intersection-observer/same-document-root.html |
diff --git a/third_party/WebKit/LayoutTests/intersection-observer/same-document-root.html b/third_party/WebKit/LayoutTests/intersection-observer/same-document-root.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..09b9d6b2b83712de2cf0f70678266e9ff86bb35f |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/intersection-observer/same-document-root.html |
@@ -0,0 +1,102 @@ |
+<!DOCTYPE html> |
+<div style="width:100%;height:700px;"></div> |
+<div id="root" style="display: inline-block; overflow-y: scroll; height: 200px;"> |
+ <div style="width:100px; height: 300px;"></div> |
+ <div id="target" style="width:100px; height:100px"></div> |
+</div> |
+<div style="width:100%;height:700px;"></div> |
+ |
+<script src="../resources/js-test.js"></script> |
+<script src="helper-functions.js"></script> |
+<script> |
+ description("Simple intersection observer test with explicit root and target in the same document."); |
+ var target = document.getElementById("target"); |
+ var root = document.getElementById("root"); |
+ var entries = []; |
+ |
+ 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); |
+ |
+ // Test that notifications are not generated when the target is overflow clipped by the root. |
+ var expected0 = []; |
+ function step0() { |
+ setTimeout(function() { |
+ checkResults(expected0, "entries"); |
+ document.scrollingElement.scrollTop = 600; |
+ requestAnimationFrame(step1); |
+ }); |
+ } |
+ |
+ var expected1 = []; |
+ function step1() { |
+ setTimeout(function() { |
+ checkResults(expected1, "entries"); |
+ checkResults([], "entries"); |
+ root.scrollTop = 150; |
+ requestAnimationFrame(step2); |
+ }); |
+ } |
+ |
+ var expected2 = [ |
+ { |
+ 'boundingClientRect': [ 8, 108, 258, 358 ], |
+ 'intersectionRect': [ 8, 108, 258, 308 ], |
+ 'rootBounds' : [ 8, 108, 108, 308 ], |
+ 'target': target |
+ } |
+ ]; |
+ function step2() { |
+ setTimeout(function() { |
+ checkResults(expected2, "entries"); |
+ document.scrollingElement.scrollTop = 0; |
+ requestAnimationFrame(step3); |
+ }); |
+ } |
+ |
+ var expected3 = expected2; |
+ function step3() { |
+ setTimeout(function() { |
+ checkResults(expected3, "entries", 1); |
+ root.scrollTop = 0; |
+ requestAnimationFrame(step4); |
+ }); |
+ } |
+ |
+ var expected4 = Array.prototype.concat(expected3, [ |
+ { |
+ 'boundingClientRect': [ 8, 108, 1008, 1108 ], |
+ 'intersectionRect': [ 0, 0, 0, 0 ], |
+ 'rootBounds' : [ 8, 108, 708, 908 ], |
+ 'target': target |
+ } |
+ ]); |
+ function step4() { |
+ setTimeout(function() { |
+ checkResults(expected4, "entries", 1); |
+ root.scrollTop = 150; |
+ requestAnimationFrame(step5); |
+ }); |
+ } |
+ |
+ // This tests that notifications are generated even when the root element is off screen. |
+ var expected5 = Array.prototype.concat(expected4, [ |
+ { |
+ 'boundingClientRect': [ 8, 108, 858, 958 ], |
+ 'intersectionRect': [ 8, 108, 858, 908 ], |
+ 'rootBounds' : [ 8, 108, 708, 908 ], |
+ 'target': target |
+ } |
+ ]); |
+ function step5() { |
+ setTimeout(function() { |
+ checkResults(expected5, "entries", 2); |
+ finishTest(); |
+ }); |
+ } |
+ |
+ requestAnimationFrame(step0); |
+</script> |