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

Unified Diff: third_party/WebKit/LayoutTests/intersection-observer/root-margin.html

Issue 1559593002: Add root margin support for IntersectionObserver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@intersection-observer-no-root-margin
Patch Set: Initialize margin members to Fixed Created 4 years, 11 months 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/intersection-observer/root-margin-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/intersection-observer/root-margin.html
diff --git a/third_party/WebKit/LayoutTests/intersection-observer/iframe-root.html b/third_party/WebKit/LayoutTests/intersection-observer/root-margin.html
similarity index 50%
copy from third_party/WebKit/LayoutTests/intersection-observer/iframe-root.html
copy to third_party/WebKit/LayoutTests/intersection-observer/root-margin.html
index de889a579138f68b06f8320d65c54898a74841e7..2373843e7994164e8ec5a7f868d08398596f862c 100644
--- a/third_party/WebKit/LayoutTests/intersection-observer/iframe-root.html
+++ b/third_party/WebKit/LayoutTests/intersection-observer/root-margin.html
@@ -2,106 +2,98 @@
<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 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"></iframe>
+<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("Simple intersection observer test with no explicit root and target in an iframe.");
-var entries = [];
-var root = document.getElementById("root");
-var targetIframe = document.getElementById("target-iframe");
+ description("Intersection observer test with root margin and implicit root.");
+ var target = document.getElementById("target");
+ var entries = [];
-targetIframe.onload = function() {
- var target = targetIframe.contentDocument.getElementById("target");
- var iframeScroller = targetIframe.contentDocument.scrollingElement;
-
- observer_callback = function(changes) {
+ function observer_callback(changes) {
for (var i in changes)
entries.push(changes[i]);
- };
- var observer = new IntersectionObserver(observer_callback, {"root": document.getElementById("root")});
+ }
+
+ 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.
+ setTimeout(function() {
+ shouldThrow("new IntersectionObserver(observer_callback, { rootMargin: '1' })");
+ shouldThrow("new IntersectionObserver(observer_callback, { rootMargin: '1em' })");
+ shouldThrow("new IntersectionObserver(observer_callback, { rootMargin: 'auto' })");
+ shouldNotThrow("new IntersectionObserver(observer_callback, { rootMargin: '1.4px' })");
+ shouldNotThrow("new IntersectionObserver(observer_callback, { rootMargin: '1.4px 2px' })");
+ shouldNotThrow("new IntersectionObserver(observer_callback, { rootMargin: '1.4px 2px 3%' })");
+ shouldNotThrow("new IntersectionObserver(observer_callback, { rootMargin: '1.4px 2px 3% 40px junk junk junk' })");
+ requestAnimationFrame(step0);
+ }, 0);
+
function step0() {
setTimeout(function() {
shouldBeEqualToNumber("entries.length", 0);
- document.scrollingElement.scrollTop = 250;
+ document.scrollingElement.scrollLeft = 100;
requestAnimationFrame(step1);
});
}
function step1() {
setTimeout(function() {
- shouldBeEqualToNumber("entries.length", 0);
- iframeScroller.scrollTop = 200;
+ 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", 0);
- root.scrollTop = 175;
+ shouldBeEqualToNumber("entries.length", 1);
+ document.scrollingElement.scrollTop = 900;
requestAnimationFrame(step3);
});
}
function step3() {
setTimeout(function() {
- shouldBeEqualToNumber("entries.length", 1);
- shouldBeEqualToNumber("entries[0].boundingClientRect.left", 18);
- shouldBeEqualToNumber("entries[0].boundingClientRect.right", 118);
- shouldBeEqualToNumber("entries[0].boundingClientRect.top", 593);
- shouldBeEqualToNumber("entries[0].boundingClientRect.bottom", 693);
- shouldBeEqualToNumber("entries[0].intersectionRect.left", 18);
- shouldBeEqualToNumber("entries[0].intersectionRect.right", 118);
- shouldBeEqualToNumber("entries[0].intersectionRect.top", 593);
- shouldBeEqualToNumber("entries[0].intersectionRect.bottom", 658);
- shouldBeEqualToNumber("entries[0].rootBounds.left", 8);
- shouldBeEqualToNumber("entries[0].rootBounds.right", 312);
- shouldBeEqualToNumber("entries[0].rootBounds.top", 458);
- shouldBeEqualToNumber("entries[0].rootBounds.bottom", 658);
- shouldEvaluateToSameObject("entries[0].target", target);
- document.scrollingElement.scrollTop = 100;
- requestAnimationFrame(step4);
- });
- }
-
- function step4() {
- setTimeout(function() {
- shouldBeEqualToNumber("entries.length", 1);
- root.scrollTop = 100;
- requestAnimationFrame(step5);
- });
- }
-
- function step5() {
- setTimeout(function() {
shouldBeEqualToNumber("entries.length", 2);
- shouldBeEqualToNumber("entries[1].boundingClientRect.left", 18);
- shouldBeEqualToNumber("entries[1].boundingClientRect.right", 118);
- shouldBeEqualToNumber("entries[1].boundingClientRect.top", 818);
- shouldBeEqualToNumber("entries[1].boundingClientRect.bottom", 918);
+ 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", 8);
- shouldBeEqualToNumber("entries[1].rootBounds.right", 312);
- shouldBeEqualToNumber("entries[1].rootBounds.top", 608);
- shouldBeEqualToNumber("entries[1].rootBounds.bottom", 808);
+ 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>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/intersection-observer/root-margin-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698