summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-layout-api/fallback-layout
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-layout-api/fallback-layout
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-layout-api/fallback-layout')
-rw-r--r--testing/web-platform/tests/css/css-layout-api/fallback-layout/bad-return.https.html50
-rw-r--r--testing/web-platform/tests/css/css-layout-api/fallback-layout/constructor-error.https.html51
-rw-r--r--testing/web-platform/tests/css/css-layout-api/fallback-layout/error.https.html50
-rw-r--r--testing/web-platform/tests/css/css-layout-api/fallback-layout/fallback-layout-fallback-ref.html11
-rw-r--r--testing/web-platform/tests/css/css-layout-api/fallback-layout/invalid-child.https.html84
-rw-r--r--testing/web-platform/tests/css/css-layout-api/fallback-layout/invalid-fragment.https.html82
-rw-r--r--testing/web-platform/tests/css/css-layout-api/fallback-layout/no-promise.https.html41
-rw-r--r--testing/web-platform/tests/css/css-layout-api/fallback-layout/unresolved-promise.https.html41
8 files changed, 410 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-layout-api/fallback-layout/bad-return.https.html b/testing/web-platform/tests/css/css-layout-api/fallback-layout/bad-return.https.html
new file mode 100644
index 0000000000..3e671537c9
--- /dev/null
+++ b/testing/web-platform/tests/css/css-layout-api/fallback-layout/bad-return.https.html
@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<html class=reftest-wait>
+<link rel="help" href="https://drafts.css-houdini.org/css-layout-api/#invoke-a-layout-callback">
+<link rel="match" href="fallback-layout-fallback-ref.html">
+<meta name="assert" content="This test checks that a layout() class with the layout function returning a bad value will fallback to block layout." />
+<style>
+.test {
+ background: red;
+ border: solid 2px;
+ width: 100px;
+}
+
+.float {
+ float: left;
+ width: 50%;
+ height: 100px;
+}
+
+.fc {
+ display: flow-root;
+ height: 100px;
+}
+
+@supports (display: layout(bad-return)) {
+ .test {
+ display: layout(bad-return);
+ background: green;
+ }
+}
+</style>
+<script src="/common/reftest-wait.js"></script>
+<script src="/common/worklet-reftest.js"></script>
+
+<!-- This tests that when the "layout()" layout function returns a bad value, it will fallback to block layout. -->
+<div class="test">
+ <div class="float"></div>
+ <div class="fc"></div>
+</div>
+
+<script id="code" type="text/worklet">
+registerLayout('bad-return', class {
+ async intrinsicSizes() {}
+ async layout() { return 42; }
+});
+</script>
+
+<script>
+importWorkletAndTerminateTestAfterAsyncPaint(CSS.layoutWorklet, document.getElementById('code').textContent);
+</script>
+</html>
diff --git a/testing/web-platform/tests/css/css-layout-api/fallback-layout/constructor-error.https.html b/testing/web-platform/tests/css/css-layout-api/fallback-layout/constructor-error.https.html
new file mode 100644
index 0000000000..9ce791ab5b
--- /dev/null
+++ b/testing/web-platform/tests/css/css-layout-api/fallback-layout/constructor-error.https.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html class=reftest-wait>
+<link rel="help" href="https://drafts.css-houdini.org/css-layout-api/#get-a-layout-class-instance">
+<link rel="match" href="fallback-layout-fallback-ref.html">
+<meta name="assert" content="This test checks that a layout() class with a throwing constructor will fallback to block layout." />
+<style>
+.test {
+ background: red;
+ border: solid 2px;
+ width: 100px;
+}
+
+.float {
+ float: left;
+ width: 50%;
+ height: 100px;
+}
+
+.fc {
+ display: flow-root;
+ height: 100px;
+}
+
+@supports (display: layout(throwing-ctor)) {
+ .test {
+ display: layout(throwing-ctor);
+ background: green;
+ }
+}
+</style>
+<script src="/common/reftest-wait.js"></script>
+<script src="/common/worklet-reftest.js"></script>
+
+<!-- This tests that when the "layout()" constructor fails, it will fallback to block layout. -->
+<div class="test">
+ <div class="float"></div>
+ <div class="fc"></div>
+</div>
+
+<script id="code" type="text/worklet">
+registerLayout('throwing-ctor', class {
+ constructor() { throw Error('fail!'); }
+ async intrinsicSizes() {}
+ async layout() {}
+});
+</script>
+
+<script>
+importWorkletAndTerminateTestAfterAsyncPaint(CSS.layoutWorklet, document.getElementById('code').textContent);
+</script>
+</html>
diff --git a/testing/web-platform/tests/css/css-layout-api/fallback-layout/error.https.html b/testing/web-platform/tests/css/css-layout-api/fallback-layout/error.https.html
new file mode 100644
index 0000000000..0631193e1f
--- /dev/null
+++ b/testing/web-platform/tests/css/css-layout-api/fallback-layout/error.https.html
@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<html class=reftest-wait>
+<link rel="help" href="https://drafts.css-houdini.org/css-layout-api/#invoke-a-layout-callback">
+<link rel="match" href="fallback-layout-fallback-ref.html">
+<meta name="assert" content="This test checks that a layout() class with a throwing layout function will fallback to block layout." />
+<style>
+.test {
+ background: red;
+ border: solid 2px;
+ width: 100px;
+}
+
+.float {
+ float: left;
+ width: 50%;
+ height: 100px;
+}
+
+.fc {
+ display: flow-root;
+ height: 100px;
+}
+
+@supports (display: layout(throwing-layout)) {
+ .test {
+ display: layout(throwing-layout);
+ background: green;
+ }
+}
+</style>
+<script src="/common/reftest-wait.js"></script>
+<script src="/common/worklet-reftest.js"></script>
+
+<!-- This tests that when the "layout()" layout function fails, it will fallback to block layout. -->
+<div class="test">
+ <div class="float"></div>
+ <div class="fc"></div>
+</div>
+
+<script id="code" type="text/worklet">
+registerLayout('throwing-layout', class {
+ async intrinsicSizes() {}
+ async layout() { throw Error('fail!'); }
+});
+</script>
+
+<script>
+importWorkletAndTerminateTestAfterAsyncPaint(CSS.layoutWorklet, document.getElementById('code').textContent);
+</script>
+</html>
diff --git a/testing/web-platform/tests/css/css-layout-api/fallback-layout/fallback-layout-fallback-ref.html b/testing/web-platform/tests/css/css-layout-api/fallback-layout/fallback-layout-fallback-ref.html
new file mode 100644
index 0000000000..63bb91e90c
--- /dev/null
+++ b/testing/web-platform/tests/css/css-layout-api/fallback-layout/fallback-layout-fallback-ref.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<style>
+.result {
+ background: green;
+ border: solid 2px;
+ height: 100px;
+ width: 100px;
+}
+</style>
+
+<div class="result"></div>
diff --git a/testing/web-platform/tests/css/css-layout-api/fallback-layout/invalid-child.https.html b/testing/web-platform/tests/css/css-layout-api/fallback-layout/invalid-child.https.html
new file mode 100644
index 0000000000..fb48ac7602
--- /dev/null
+++ b/testing/web-platform/tests/css/css-layout-api/fallback-layout/invalid-child.https.html
@@ -0,0 +1,84 @@
+<!DOCTYPE html>
+<html class=reftest-wait>
+<link rel="help" href="https://drafts.css-houdini.org/css-layout-api/#invoke-a-layout-callback">
+<link rel="match" href="fallback-layout-fallback-ref.html">
+<meta name="assert" content="This test checks that a layout() class performing layout on an invalid child will fallback to block layout." />
+<style>
+.test {
+ background: red;
+ border: solid 2px;
+ width: 100px;
+}
+
+.test > div {
+ height: 100px;
+}
+
+@supports (display: layout(bad-child-layout)) {
+ .test {
+ display: layout(bad-child-layout);
+ background: green;
+ }
+}
+</style>
+<script src="/common/reftest-wait.js"></script>
+<script src="/common/worklet-reftest.js"></script>
+
+<div class="test">
+ <div></div>
+</div>
+
+<script id="code" type="text/worklet">
+registerLayout('bad-child-layout', class {
+ static get inputProperties() { return ['--fail']; }
+
+ async intrinsicSizes() {}
+ async layout(children, _, __, styleMap) {
+ if (styleMap.get('--fail').toString() !== 'true') {
+ this.child = children[0];
+ }
+
+ // Try to perform layout on the child. If its invalid (we skipped the if
+ // statement above) we should fallback to block layout.
+ const fragment = await this.child.layoutNextFragment({});
+
+ return {autoBlockSize: 0, childFragments: [fragment]};
+ }
+});
+</script>
+
+<script>
+function raf() {
+ return new Promise((resolve) => {
+ requestAnimationFrame(() => {
+ resolve();
+ });
+ });
+}
+
+(async function() {
+ if (typeof CSS.layoutWorklet === 'undefined') {
+ takeScreenshot();
+ return;
+ }
+
+ await importWorklet(CSS.layoutWorklet, document.getElementById('code').textContent);
+
+ // Ensure that all instances have a child to perform an invalid layout upon.
+ const test = document.getElementsByClassName('test')[0];
+ for (let i = 0; i < 100; i++) {
+ test.innerHTML = '<div><div>';
+ await raf();
+ }
+
+ // The next layout should mean that we will fallback to block.
+ test.innerHTML = '<div></div>';
+ test.style.setProperty('--fail', 'true');
+
+ // Finish up the test.
+ await raf();
+ await raf();
+ takeScreenshot();
+})();
+</script>
+</html>
diff --git a/testing/web-platform/tests/css/css-layout-api/fallback-layout/invalid-fragment.https.html b/testing/web-platform/tests/css/css-layout-api/fallback-layout/invalid-fragment.https.html
new file mode 100644
index 0000000000..d954f44ba3
--- /dev/null
+++ b/testing/web-platform/tests/css/css-layout-api/fallback-layout/invalid-fragment.https.html
@@ -0,0 +1,82 @@
+<!DOCTYPE html>
+<html class=reftest-wait>
+<link rel="help" href="https://drafts.css-houdini.org/css-layout-api/#invoke-a-layout-callback">
+<link rel="match" href="fallback-layout-fallback-ref.html">
+<meta name="assert" content="This test checks that a layout() class returning an invalid fragment will fallback to block layout." />
+<style>
+.test {
+ background: red;
+ border: solid 2px;
+ width: 100px;
+}
+
+.test > div {
+ height: 100px;
+}
+
+@supports (display: layout(bad-request)) {
+ .test {
+ display: layout(bad-request);
+ background: green;
+ }
+}
+</style>
+<script src="/common/reftest-wait.js"></script>
+<script src="/common/worklet-reftest.js"></script>
+
+<div class="test">
+ <div></div>
+</div>
+
+<script id="code" type="text/worklet">
+registerLayout('bad-request', class {
+ static get inputProperties() { return ['--fail']; }
+
+ async intrinsicSizes() {}
+ async layout(children, _, __, styleMap) {
+ if (styleMap.get('--fail').toString() !== 'true') {
+ this.fragment = await children[0].layoutNextFragment({});
+ }
+
+ // Return, if the fragment is invalid (we skipped the if statement above)
+ // we should fallback to block layout.
+ return {autoBlockSize: 0, childFragments: [this.fragment]};
+ }
+});
+</script>
+
+<script>
+function raf() {
+ return new Promise((resolve) => {
+ requestAnimationFrame(() => {
+ resolve();
+ });
+ });
+}
+
+(async function() {
+ if (typeof CSS.layoutWorklet === 'undefined') {
+ takeScreenshot();
+ return;
+ }
+
+ await importWorklet(CSS.layoutWorklet, document.getElementById('code').textContent);
+
+ // Ensure that all instances have a child to perform an invalid layout upon.
+ const test = document.getElementsByClassName('test')[0];
+ for (let i = 0; i < 100; i++) {
+ test.innerHTML = '<div><div>';
+ await raf();
+ }
+
+ // The next layout should mean that we will fallback to block.
+ test.innerHTML = '<div></div>';
+ test.style.setProperty('--fail', 'true');
+
+ // Finish up the test.
+ await raf();
+ await raf();
+ takeScreenshot();
+})();
+</script>
+</html>
diff --git a/testing/web-platform/tests/css/css-layout-api/fallback-layout/no-promise.https.html b/testing/web-platform/tests/css/css-layout-api/fallback-layout/no-promise.https.html
new file mode 100644
index 0000000000..00670f7bbe
--- /dev/null
+++ b/testing/web-platform/tests/css/css-layout-api/fallback-layout/no-promise.https.html
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html class=reftest-wait>
+<link rel="help" href="https://drafts.css-houdini.org/css-layout-api/#invoke-a-layout-callback">
+<link rel="match" href="fallback-layout-fallback-ref.html">
+<meta name="assert" content="This test checks that a layout() class with a layout function that doesn't return a promise will fallback to block layout." />
+<style>
+.test {
+ background: red;
+ border: solid 2px;
+ width: 100px;
+}
+
+.child {
+ height: 100px;
+}
+
+@supports (display: layout(no-promise)) {
+ .test {
+ display: layout(no-promise);
+ background: green;
+ }
+}
+</style>
+<script src="/common/reftest-wait.js"></script>
+<script src="/common/worklet-reftest.js"></script>
+
+<div class="test">
+ <div class="child"></div>
+</div>
+
+<script id="code" type="text/worklet">
+registerLayout('no-promise', class {
+ async intrinsicSizes() {}
+ layout() { return {autoBlockSize: 50}; }
+});
+</script>
+
+<script>
+importWorkletAndTerminateTestAfterAsyncPaint(CSS.layoutWorklet, document.getElementById('code').textContent);
+</script>
+</html>
diff --git a/testing/web-platform/tests/css/css-layout-api/fallback-layout/unresolved-promise.https.html b/testing/web-platform/tests/css/css-layout-api/fallback-layout/unresolved-promise.https.html
new file mode 100644
index 0000000000..72ce549acf
--- /dev/null
+++ b/testing/web-platform/tests/css/css-layout-api/fallback-layout/unresolved-promise.https.html
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html class=reftest-wait>
+<link rel="help" href="https://drafts.css-houdini.org/css-layout-api/#invoke-a-layout-callback">
+<link rel="match" href="fallback-layout-fallback-ref.html">
+<meta name="assert" content="This test checks that a layout() class with a layout function that doesn't return a promise will fallback to block layout." />
+<style>
+.test {
+ background: red;
+ border: solid 2px;
+ width: 100px;
+}
+
+.child {
+ height: 100px;
+}
+
+@supports (display: layout(unresolved-promise)) {
+ .test {
+ display: layout(unresolved-promise);
+ background: green;
+ }
+}
+</style>
+<script src="/common/reftest-wait.js"></script>
+<script src="/common/worklet-reftest.js"></script>
+
+<div class="test">
+ <div class="child"></div>
+</div>
+
+<script id="code" type="text/worklet">
+registerLayout('unresolved-promise', class {
+ async intrinsicSizes() {}
+ layout() { return new Promise(() => { /* never resolves */ }); }
+});
+</script>
+
+<script>
+importWorkletAndTerminateTestAfterAsyncPaint(CSS.layoutWorklet, document.getElementById('code').textContent);
+</script>
+</html>