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

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

Issue 1814553003: IntersectionObserver: use border box rect for unclipped root. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@intersection-observer-idle-callback
Patch Set: rebase Created 4 years, 8 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
Index: third_party/WebKit/LayoutTests/intersection-observer/unclipped-root.html
diff --git a/third_party/WebKit/LayoutTests/intersection-observer/unclipped-root.html b/third_party/WebKit/LayoutTests/intersection-observer/unclipped-root.html
new file mode 100644
index 0000000000000000000000000000000000000000..2bb0c81f770ce185dc3840dd1e094648baa08ffa
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/intersection-observer/unclipped-root.html
@@ -0,0 +1,67 @@
+<!DOCTYPE html>
+<script src="../resources/js-test.js"></script>
+<script src="helper-functions.js"></script>
+<style>
+#root {
+ overflow: visible;
+ height: 200px;
+ width: 200px;
+ border: 7px solid black;
+}
+#target {
+ width: 100px;
+ height: 100px;
+ background-color: green;
+}
+</style>
+<div id="root">
+ <div id="target" style="transform: translateY(300px)"></div>
+</div>
+
+<script>
+description("Test that border bounding box is used to calculate intersection with a non-scrolling root.");
+var target = document.getElementById("target");
+var root = document.getElementById("root");
+var entries = [];
+var observer = new IntersectionObserver(
+ changes => { entries.push(...changes) },
+ { root: document.getElementById("root") }
+);
+
+onload = function() {
+ observer.observe(target);
+ entries.push(...observer.takeRecords());
+ shouldBeEqualToNumber("entries.length", 0);
+ // See README for explanation of double RAF.
+ requestAnimationFrame(() => { requestAnimationFrame(step0) });
+}
+
+function step0() {
+ entries.push(...observer.takeRecords());
+ shouldBeEqualToNumber("entries.length", 0);
+ target.style.transform = "translateY(195px)";
+ requestAnimationFrame(step1);
+}
+
+function step1() {
+ entries.push(...observer.takeRecords());
+ shouldBeEqualToNumber("entries.length", 1);
+ if (entries.length > 0) {
+ shouldBeEqualToNumber("entries[0].boundingClientRect.left", 15);
+ shouldBeEqualToNumber("entries[0].boundingClientRect.right", 115);
+ shouldBeEqualToNumber("entries[0].boundingClientRect.top", 210);
+ shouldBeEqualToNumber("entries[0].boundingClientRect.bottom", 310);
+ shouldBeEqualToNumber("entries[0].intersectionRect.left", 15);
+ shouldBeEqualToNumber("entries[0].intersectionRect.right", 115);
+ shouldBeEqualToNumber("entries[0].intersectionRect.top", 210);
+ shouldBeEqualToNumber("entries[0].intersectionRect.bottom", 222);
+ shouldBeEqualToNumber("entries[0].rootBounds.left", 8);
+ shouldBeEqualToNumber("entries[0].rootBounds.right", 222);
+ shouldBeEqualToNumber("entries[0].rootBounds.top", 8);
+ shouldBeEqualToNumber("entries[0].rootBounds.bottom", 222);
+ shouldEvaluateToSameObject("entries[0].target", target);
+ }
+
+ finishJSTest();
+}
+</script>

Powered by Google App Engine
This is Rietveld 408576698