| 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..fb4a857b04abd49a30b30c70536730d341c639fa
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/intersection-observer/same-document-root.html
|
| @@ -0,0 +1,113 @@
|
| +<!DOCTYPE html>
|
| +<script src="../resources/js-test.js"></script>
|
| +<script src="helper-functions.js"></script>
|
| +<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="background-color: green; width:100px; height:100px"></div>
|
| +</div>
|
| +<div style="width:100%;height:700px;"></div>
|
| +
|
| +<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.
|
| + function step0() {
|
| + setTimeout(function() {
|
| + shouldBeEqualToNumber("entries.length", 0);
|
| + document.scrollingElement.scrollTop = 600;
|
| + requestAnimationFrame(step1);
|
| + });
|
| + }
|
| +
|
| + function step1() {
|
| + setTimeout(function() {
|
| + shouldBeEqualToNumber("entries.length", 0);
|
| + root.scrollTop = 150;
|
| + requestAnimationFrame(step2);
|
| + });
|
| + }
|
| +
|
| + function step2() {
|
| + setTimeout(function() {
|
| + shouldBeEqualToNumber("entries.length", 1);
|
| + shouldBeEqualToNumber("entries[0].boundingClientRect.left", 8);
|
| + shouldBeEqualToNumber("entries[0].boundingClientRect.right", 108);
|
| + shouldBeEqualToNumber("entries[0].boundingClientRect.top", 258);
|
| + shouldBeEqualToNumber("entries[0].boundingClientRect.bottom", 358);
|
| + shouldBeEqualToNumber("entries[0].intersectionRect.left", 8);
|
| + shouldBeEqualToNumber("entries[0].intersectionRect.right", 108);
|
| + shouldBeEqualToNumber("entries[0].intersectionRect.top", 258);
|
| + shouldBeEqualToNumber("entries[0].intersectionRect.bottom", 308);
|
| + shouldBeEqualToNumber("entries[0].rootBounds.left", 8);
|
| + shouldBeEqualToNumber("entries[0].rootBounds.right", 108);
|
| + shouldBeEqualToNumber("entries[0].rootBounds.top", 108);
|
| + shouldBeEqualToNumber("entries[0].rootBounds.bottom", 308);
|
| + shouldEvaluateToSameObject("entries[0].target", target);
|
| + document.scrollingElement.scrollTop = 0;
|
| + requestAnimationFrame(step3);
|
| + });
|
| + }
|
| +
|
| + function step3() {
|
| + setTimeout(function() {
|
| + shouldBeEqualToNumber("entries.length", 1);
|
| + root.scrollTop = 0;
|
| + requestAnimationFrame(step4);
|
| + });
|
| + }
|
| +
|
| + function step4() {
|
| + setTimeout(function() {
|
| + shouldBeEqualToNumber("entries.length", 2);
|
| + shouldBeEqualToNumber("entries[1].boundingClientRect.left", 8);
|
| + shouldBeEqualToNumber("entries[1].boundingClientRect.right", 108);
|
| + shouldBeEqualToNumber("entries[1].boundingClientRect.top", 1008);
|
| + shouldBeEqualToNumber("entries[1].boundingClientRect.bottom", 1108);
|
| + shouldBeEqualToNumber("entries[1].intersectionRect.left", 0);
|
| + shouldBeEqualToNumber("entries[1].intersectionRect.right", 0);
|
| + shouldBeEqualToNumber("entries[1].intersectionRect.top", 0);
|
| + shouldBeEqualToNumber("entries[1].intersectionRect.bottom", 0);
|
| + shouldBeEqualToNumber("entries[1].rootBounds.left", 8);
|
| + shouldBeEqualToNumber("entries[1].rootBounds.right", 108);
|
| + shouldBeEqualToNumber("entries[1].rootBounds.top", 708);
|
| + shouldBeEqualToNumber("entries[1].rootBounds.bottom", 908);
|
| + shouldEvaluateToSameObject("entries[1].target", target);
|
| + root.scrollTop = 150;
|
| + requestAnimationFrame(step5);
|
| + });
|
| + }
|
| +
|
| + // This tests that notifications are generated even when the root element is off screen.
|
| + function step5() {
|
| + setTimeout(function() {
|
| + shouldBeEqualToNumber("entries.length", 3);
|
| + shouldBeEqualToNumber("entries[2].boundingClientRect.left", 8);
|
| + shouldBeEqualToNumber("entries[2].boundingClientRect.right", 108);
|
| + shouldBeEqualToNumber("entries[2].boundingClientRect.top", 858);
|
| + shouldBeEqualToNumber("entries[2].boundingClientRect.bottom", 958);
|
| + shouldBeEqualToNumber("entries[2].intersectionRect.left", 8);
|
| + shouldBeEqualToNumber("entries[2].intersectionRect.right", 108);
|
| + shouldBeEqualToNumber("entries[2].intersectionRect.top", 858);
|
| + shouldBeEqualToNumber("entries[2].intersectionRect.bottom", 908);
|
| + shouldBeEqualToNumber("entries[2].rootBounds.left", 8);
|
| + shouldBeEqualToNumber("entries[2].rootBounds.right", 108);
|
| + shouldBeEqualToNumber("entries[2].rootBounds.top", 708);
|
| + shouldBeEqualToNumber("entries[2].rootBounds.bottom", 908);
|
| + shouldEvaluateToSameObject("entries[2].target", target);
|
| + finishTest();
|
| + });
|
| + }
|
| +
|
| + requestAnimationFrame(step0);
|
| +</script>
|
|
|