| Index: third_party/WebKit/LayoutTests/intersection-observer/root-margin.html
|
| diff --git a/third_party/WebKit/LayoutTests/intersection-observer/root-margin.html b/third_party/WebKit/LayoutTests/intersection-observer/root-margin.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..57d49244cab43fa699f55561dfe72650d7faa060
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/intersection-observer/root-margin.html
|
| @@ -0,0 +1,89 @@
|
| +<!DOCTYPE html>
|
| +<script src="../resources/js-test.js"></script>
|
| +<script src="helper-functions.js"></script>
|
| +<div style="width:100%; height:700px;"></div>
|
| +<div style="white-space: nowrap;">
|
| + <div style="display: inline-block; width: 1000px; height: 100px"></div>
|
| + <div id="target" style="display: inline-block; background-color: green; width:100px; height:100px"></div>
|
| + <div style="display: inline-block; width: 1000px; height: 100px"></div>
|
| +</div>
|
| +<div style="width:100%; height:700px;"></div>
|
| +
|
| +<script>
|
| + description("Intersection observer test with root margin and implicit root.");
|
| + var target = document.getElementById("target");
|
| + var entries = [];
|
| +
|
| + observer_callback = function(changes) {
|
| + for (var i in changes)
|
| + entries.push(changes[i]);
|
| + };
|
| + var observer = new IntersectionObserver(observer_callback, {
|
| + rootMargin: "10px 20% 40% 30px"
|
| + });
|
| + observer.observe(target);
|
| +
|
| + // TODO(szager): It shouldn't be necessary to RAF after the call to observer()
|
| + // and before changing the scroll position, but it is.
|
| +
|
| + function step0() {
|
| + setTimeout(function() {
|
| + shouldBeEqualToNumber("entries.length", 0);
|
| + document.scrollingElement.scrollLeft = 100;
|
| + requestAnimationFrame(step1);
|
| + });
|
| + }
|
| +
|
| + function step1() {
|
| + setTimeout(function() {
|
| + shouldBeEqualToNumber("entries.length", 1);
|
| + shouldBeEqualToNumber("entries[0].boundingClientRect.left", 912);
|
| + shouldBeEqualToNumber("entries[0].boundingClientRect.right", 1012);
|
| + shouldBeEqualToNumber("entries[0].boundingClientRect.top", 708);
|
| + shouldBeEqualToNumber("entries[0].boundingClientRect.bottom", 808);
|
| + shouldBeEqualToNumber("entries[0].intersectionRect.left", 912);
|
| + shouldBeEqualToNumber("entries[0].intersectionRect.right", 942);
|
| + shouldBeEqualToNumber("entries[0].intersectionRect.top", 708);
|
| + shouldBeEqualToNumber("entries[0].intersectionRect.bottom", 808);
|
| + shouldBeEqualToNumber("entries[0].rootBounds.left", -30);
|
| + shouldBeEqualToNumber("entries[0].rootBounds.right", 942);
|
| + shouldBeEqualToNumber("entries[0].rootBounds.top", -10);
|
| + shouldBeEqualToNumber("entries[0].rootBounds.bottom", 819);
|
| + shouldEvaluateToSameObject("entries[0].target", target);
|
| + document.scrollingElement.scrollTop = 800;
|
| + requestAnimationFrame(step2);
|
| + });
|
| + }
|
| +
|
| + function step2() {
|
| + setTimeout(function() {
|
| + shouldBeEqualToNumber("entries.length", 1);
|
| + document.scrollingElement.scrollTop = 900;
|
| + requestAnimationFrame(step3);
|
| + });
|
| + }
|
| +
|
| + function step3() {
|
| + setTimeout(function() {
|
| + shouldBeEqualToNumber("entries.length", 2);
|
| + shouldBeEqualToNumber("entries[1].boundingClientRect.left", 912);
|
| + shouldBeEqualToNumber("entries[1].boundingClientRect.right", 1012);
|
| + shouldBeEqualToNumber("entries[1].boundingClientRect.top", -192);
|
| + shouldBeEqualToNumber("entries[1].boundingClientRect.bottom", -92);
|
| + 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", -30);
|
| + shouldBeEqualToNumber("entries[1].rootBounds.right", 942);
|
| + shouldBeEqualToNumber("entries[1].rootBounds.top", -10);
|
| + shouldBeEqualToNumber("entries[1].rootBounds.bottom", 819);
|
| + shouldEvaluateToSameObject("entries[1].target", target);
|
| + finishTest();
|
| + document.scrollingElement.scrollLeft = 0;
|
| + document.scrollingElement.scrollTop = 0;
|
| + });
|
| + }
|
| +
|
| + requestAnimationFrame(step0);
|
| +</script>
|
|
|