summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-anchor-position/inset-area-align-justify.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/css/css-anchor-position/inset-area-align-justify.html')
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/inset-area-align-justify.html65
1 files changed, 65 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-anchor-position/inset-area-align-justify.html b/testing/web-platform/tests/css/css-anchor-position/inset-area-align-justify.html
new file mode 100644
index 0000000000..7f7f05ccf3
--- /dev/null
+++ b/testing/web-platform/tests/css/css-anchor-position/inset-area-align-justify.html
@@ -0,0 +1,65 @@
+<!DOCTYPE html>
+<title>CSS Anchor Positioning: inset-area positioning - alignment</title>
+<link rel="help" href="https://drafts.csswg.org/css-anchor-position/#inset-area">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<style>
+ /* A 300x300 container with a 100x100 centered anchor */
+ #container {
+ position: relative;
+ width: 300px;
+ height: 300px;
+ }
+ #anchor {
+ position: absolute;
+ top: 100px;
+ left: 100px;
+ width: 100px;
+ height: 100px;
+ anchor-name: --anchor;
+ }
+ #anchored {
+ position: absolute;
+ width: 10px;
+ height: 10px;
+ inset: 10px;
+ position-anchor: --anchor;
+ }
+</style>
+<div id="container">
+ <div id="anchor"></div>
+ <div id="anchored"></div>
+</div>
+<script>
+ function test_inset_area(inset_area, expected_offsets) {
+ anchored.style.insetArea = inset_area;
+
+ test(() => {
+ assert_equals(anchored.offsetLeft, expected_offsets.left, "Check expected offsetLeft");
+ assert_equals(anchored.offsetTop, expected_offsets.top, "Check expected offsetTop");
+ assert_equals(anchored.offsetWidth, expected_offsets.width, "Check expected offsetWidth");
+ assert_equals(anchored.offsetHeight, expected_offsets.height, "Check expected offsetHeight");
+ }, "Offsets for inset-area: " + inset_area);
+ }
+
+ // anchor-center in both directions
+ test_inset_area("span-all", {left:145, top:145, width:10, height:10});
+
+ // Single region spans
+ test_inset_area("top left", {left:80, top:80, width:10, height:10});
+ test_inset_area("top center", {left:145, top:80, width:10, height:10});
+ test_inset_area("top right", {left:210, top:80, width:10, height:10});
+ test_inset_area("center left", {left:80, top:145, width:10, height:10});
+ test_inset_area("center center", {left:145, top:145, width:10, height:10});
+ test_inset_area("center right", {left:210, top:145, width:10, height:10});
+ test_inset_area("bottom left", {left:80, top:210, width:10, height:10});
+ test_inset_area("bottom center", {left:145, top:210, width:10, height:10});
+ test_inset_area("bottom right", {left:210, top:210, width:10, height:10});
+
+ // Multi-region spans
+ test_inset_area("top span-left", {left:180, top:80, width:10, height:10});
+ test_inset_area("top span-right", {left:110, top:80, width:10, height:10});
+ test_inset_area("span-top left", {left:80, top:180, width:10, height:10});
+ test_inset_area("span-bottom left", {left:80, top:110, width:10, height:10});
+
+</script>