summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/intersection-observer/bounding-box.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /testing/web-platform/tests/intersection-observer/bounding-box.html
parentInitial commit. (diff)
downloadthunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz
thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/intersection-observer/bounding-box.html')
-rw-r--r--testing/web-platform/tests/intersection-observer/bounding-box.html85
1 files changed, 85 insertions, 0 deletions
diff --git a/testing/web-platform/tests/intersection-observer/bounding-box.html b/testing/web-platform/tests/intersection-observer/bounding-box.html
new file mode 100644
index 0000000000..367243d558
--- /dev/null
+++ b/testing/web-platform/tests/intersection-observer/bounding-box.html
@@ -0,0 +1,85 @@
+<!DOCTYPE html>
+<meta name="viewport" content="width=device-width,initial-scale=1">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="./resources/intersection-observer-test-utils.js"></script>
+
+<style>
+pre, #log {
+ position: absolute;
+ top: 0;
+ left: 200px;
+}
+#root {
+ overflow: visible;
+ height: 200px;
+ width: 160px;
+ border: 8px solid black;
+}
+#target {
+ margin: 10px;
+ width: 100px;
+ height: 100px;
+ padding: 10px;
+ background-color: green;
+}
+</style>
+
+<div id="root">
+ <div id="target" style="transform: translateY(300px)"></div>
+</div>
+
+<script>
+var entries = [];
+var target;
+
+runTestCycle(function() {
+ target = document.getElementById("target");
+ assert_true(!!target, "target exists");
+ var root = document.getElementById("root");
+ assert_true(!!root, "root exists");
+ var observer = new IntersectionObserver(function(changes) {
+ entries = entries.concat(changes)
+ }, {root: root});
+ observer.observe(target);
+ entries = entries.concat(observer.takeRecords());
+ assert_equals(entries.length, 0, "No initial notifications.");
+ runTestCycle(step0, "First rAF.");
+}, "Test that the target's border bounding box is used to calculate intersection.");
+
+function step0() {
+ var targetBounds = clientBounds(target);
+ target.style.transform = "translateY(195px)";
+ runTestCycle(step1, "target.style.transform = 'translateY(195px)'");
+ checkLastEntry(entries, 0, targetBounds.concat(0, 0, 0, 0, 8, 184, 8, 224, false));
+}
+
+function step1() {
+ var targetBounds = clientBounds(target);
+ target.style.transform = "translateY(300px)";
+ runTestCycle(step2, "target.style.transform = 'translateY(300px)'");
+ checkLastEntry(entries, 1, targetBounds.concat(26, 146, 221, 224, 8, 184, 8, 224, true));
+}
+
+function step2() {
+ var targetBounds = clientBounds(target);
+ target.style.transform = "";
+ target.style.zoom = "2";
+ runTestCycle(step3, "target.style.zoom = 2");
+ checkLastEntry(entries, 2, targetBounds.concat(0, 0, 0, 0, 8, 184, 8, 224, false));
+}
+
+function step3() {
+ var targetBounds = clientBounds(target);
+ var intersectionWidth = (
+ 176 // root width including border
+ -8 // root left border
+ -20 // target left margin * target zoom
+ ) / 2; // convert to target's zoom factor.
+ var intersectionHeight = (216 - 8 - 20) / 2;
+ var intersectionRect = [targetBounds[0], targetBounds[0] + intersectionWidth,
+ targetBounds[2], targetBounds[2] + intersectionHeight];
+ checkLastEntry(entries, 3, targetBounds.concat(intersectionRect).concat(8, 184, 8, 224, true));
+}
+
+</script>