summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-anchor-position/anchor-size-parse-valid.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/css/css-anchor-position/anchor-size-parse-valid.html
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/css/css-anchor-position/anchor-size-parse-valid.html')
-rw-r--r--testing/web-platform/tests/css/css-anchor-position/anchor-size-parse-valid.html65
1 files changed, 65 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-anchor-position/anchor-size-parse-valid.html b/testing/web-platform/tests/css/css-anchor-position/anchor-size-parse-valid.html
new file mode 100644
index 0000000000..32b308f056
--- /dev/null
+++ b/testing/web-platform/tests/css/css-anchor-position/anchor-size-parse-valid.html
@@ -0,0 +1,65 @@
+<!DOCTYPE html>
+<title>Tests parsing of the anchor-size() function</title>
+<link rel="help" href="https://drafts.csswg.org/css-anchor-1/#anchor-size">
+<link rel="author" href="mailto:xiaochengh@chromium.org">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/parsing-testcommon.js"></script>
+
+<script>
+const anchorNames = [
+ '--foo',
+ '',
+];
+
+const sizeProperties = [
+ 'width',
+ 'min-width',
+ 'max-width',
+ 'height',
+ 'min-height',
+ 'max-height',
+ 'block-size',
+ 'min-block-size',
+ 'max-block-size',
+ 'inline-size',
+ 'min-inline-size',
+ 'max-inline-size',
+];
+
+const anchorSizes = [
+ 'width',
+ 'height',
+ 'block',
+ 'inline',
+ 'self-block',
+ 'self-inline',
+];
+
+const fallbacks = [
+ null,
+ '1px',
+ '50%',
+ 'calc(50% + 1px)',
+ 'anchor-size(block)',
+ 'anchor-size(--bar block)',
+ 'anchor-size(--bar block, anchor-size(--baz inline))',
+];
+
+// Tests basic combinations
+for (let name of anchorNames) {
+ for (let property of sizeProperties) {
+ for (let size of anchorSizes) {
+ for (let fallback of fallbacks) {
+ let value = `anchor-size(${name ? name + ' ' : ''}${size}${fallback ? ', ' + fallback : ''})`;
+ test_valid_value(property, value);
+ }
+ }
+ }
+}
+
+// Tests that anchor-size() can be used in a calc tree
+test_valid_value('width', 'calc((anchor-size(--foo width) + anchor-size(--bar height)) / 2)');
+test_valid_value('width', 'anchor-size(--foo width, calc(anchor-size(--bar height) * 0.5))');
+test_valid_value('width', 'min(100px, 10%, anchor-size(--foo width), anchor-size(--bar height))');
+</script>