summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-cascade/scope-deep.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-cascade/scope-deep.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-cascade/scope-deep.html')
-rw-r--r--testing/web-platform/tests/css/css-cascade/scope-deep.html52
1 files changed, 52 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-cascade/scope-deep.html b/testing/web-platform/tests/css/css-cascade/scope-deep.html
new file mode 100644
index 0000000000..0e88778202
--- /dev/null
+++ b/testing/web-platform/tests/css/css-cascade/scope-deep.html
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<title>@scope - deeply nested</title>
+<link rel="help" href="https://drafts.csswg.org/css-cascade-6/#scope-atrule">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<style>
+ main * { background-color: black; }
+</style>
+<main id=main></main>
+<script>
+
+// @scope (.s0) { @scope (.s1) { ... span {} ... } }
+function createStyleSheet(length, i) {
+ if (length == 0)
+ return 'span { background-color: green; }';
+ if (i === undefined)
+ i = 0;
+ return `
+ @scope (.s${i}) {
+ ${createStyleSheet(length - 1, i + 1)}
+ }
+ `.trim();
+}
+
+// <div class=s0><div class=s1>...<span></span>...</div></div>
+function createElementChain(length, i) {
+ if (length < 1)
+ throw 'Invalid length';
+ if (i === undefined)
+ i = 0;
+ let e = document.createElement('div');
+ e.classList.add(`s${i}`);
+ if (length > 1)
+ e.append(createElementChain(length - 1, i + 1));
+ else
+ e.append(document.createElement('span'));
+ return e;
+}
+
+const COUNT = 90;
+
+let style_node = document.createElement('style');
+style_node.textContent = createStyleSheet(COUNT);
+main.append(style_node);
+
+main.append(createElementChain(COUNT));
+
+test(() => {
+ for (let span of main.querySelectorAll('span'))
+ assert_equals(getComputedStyle(span).backgroundColor, 'rgb(0, 128, 0)');
+}, 'Deep @scope nesting');
+</script>