summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-cascade/scope-nesting.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
commit0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch)
treea31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /testing/web-platform/tests/css/css-cascade/scope-nesting.html
parentInitial commit. (diff)
downloadfirefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz
firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/css/css-cascade/scope-nesting.html')
-rw-r--r--testing/web-platform/tests/css/css-cascade/scope-nesting.html170
1 files changed, 170 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-cascade/scope-nesting.html b/testing/web-platform/tests/css/css-cascade/scope-nesting.html
new file mode 100644
index 0000000000..34a13a1cb1
--- /dev/null
+++ b/testing/web-platform/tests/css/css-cascade/scope-nesting.html
@@ -0,0 +1,170 @@
+<!DOCTYPE html>
+<title>@scope - nesting (&)</title>
+<link rel="help" href="https://drafts.csswg.org/css-cascade-6/#scope-atrule">
+<link rel="help" href="https://drafts.csswg.org/css-nesting-1/#nest-selector">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<main id=main></main>
+
+<template id=test_nest_scope_end>
+ <div>
+ <style>
+ @scope (.a) to (& > &) {
+ * { z-index:1; }
+ }
+ </style>
+ <div class=a> <!-- This scope is limited by the element below. -->
+ <div class=a> <!-- This scope is limited by its own root. -->
+ <div id=below></div>
+ </div>
+ </div>
+ </div>
+ <div id=outside></div>
+</template>
+<script>
+test((t) => {
+ t.add_cleanup(() => main.replaceChildren());
+ main.append(test_nest_scope_end.content.cloneNode(true));
+
+ assert_equals(getComputedStyle(below).zIndex, 'auto');
+ assert_equals(getComputedStyle(outside).zIndex, 'auto');
+}, 'Nesting-selector in <scope-end>');
+</script>
+
+<template id=test_nest_scope_end_implicit_scope>
+ <div>
+ <style>
+ /* (.b) behaves like (:scope .b), due :scope being prepended
+ implicitly. */
+ @scope (.a) to (.b) {
+ :scope { z-index:1; }
+ }
+
+ /* Should not match, since <scope-end> refers to the scope itself. */
+ @scope (.a) to (.b:scope) {
+ :scope { z-index:42; }
+ }
+ </style>
+ <div class="a b">
+ <div class=b>
+ <div id=below></div>
+ </div>
+ </div>
+ </div>
+ <div id=outside></div>
+</template>
+<script>
+test((t) => {
+ t.add_cleanup(() => main.replaceChildren());
+ main.append(test_nest_scope_end_implicit_scope.content.cloneNode(true));
+ let a = document.querySelector('.a');
+ let b = document.querySelector('.a > .b');
+ assert_equals(getComputedStyle(a).zIndex, '1');
+ assert_equals(getComputedStyle(b).zIndex, 'auto');
+ assert_equals(getComputedStyle(below).zIndex, 'auto');
+ assert_equals(getComputedStyle(outside).zIndex, 'auto');
+}, 'Implicit :scope in <scope-end>');
+</script>
+
+<template id=test_relative_selector_scope_end>
+ <div>
+ <style>
+ @scope (.a) to (> .b) {
+ *, :scope { z-index:1; }
+ }
+ </style>
+ <div class="a b">
+ <div class=b>
+ <div id=below></div>
+ </div>
+ </div>
+ </div>
+ <div id=outside></div>
+</template>
+<script>
+test((t) => {
+ t.add_cleanup(() => main.replaceChildren());
+ main.append(test_relative_selector_scope_end.content.cloneNode(true));
+ let a = document.querySelector('.a');
+ let b = document.querySelector('.a > .b');
+ assert_equals(getComputedStyle(a).zIndex, '1');
+ assert_equals(getComputedStyle(b).zIndex, 'auto');
+ assert_equals(getComputedStyle(below).zIndex, 'auto');
+ assert_equals(getComputedStyle(outside).zIndex, 'auto');
+}, 'Relative selectors in <scope-end>');
+</script>
+
+<template id=test_inner_nest>
+ <div>
+ <style>
+ @scope (.a) {
+ & + & {
+ z-index:1;
+ }
+ }
+ </style>
+ <div class=a>
+ <div id=inner1 class=a></div>
+ <div id=inner2 class=a></div>
+ </div>
+ </div>
+</template>
+<script>
+test((t) => {
+ t.add_cleanup(() => main.replaceChildren());
+ main.append(test_inner_nest.content.cloneNode(true));
+
+ assert_equals(getComputedStyle(inner1).zIndex, 'auto');
+ assert_equals(getComputedStyle(inner2).zIndex, '1');
+}, 'Nesting-selector in the scope\'s <stylesheet>');
+</script>
+
+<template id=test_parent_in_pseudo_scope>
+ <div>
+ <style>
+ @scope (#div) {
+ :scope {
+ z-index: 1;
+ & {
+ z-index: 2;
+ }
+ }
+ }
+ </style>
+ <div id=div></div>
+ </div>
+</template>
+<script>
+test((t) => {
+ t.add_cleanup(() => main.replaceChildren());
+ main.append(test_parent_in_pseudo_scope.content.cloneNode(true));
+
+ assert_equals(getComputedStyle(div).zIndex, '2');
+}, 'Nesting-selector within :scope rule');
+</script>
+
+<template id=test_parent_in_pseudo_scope_double>
+ <div>
+ <style>
+ @scope (#div) {
+ :scope {
+ z-index: 1;
+ & {
+ & {
+ z-index: 2;
+ }
+ }
+ }
+ }
+ </style>
+ <div id=div></div>
+ </div>
+</template>
+<script>
+test((t) => {
+ t.add_cleanup(() => main.replaceChildren());
+ main.append(test_parent_in_pseudo_scope_double.content.cloneNode(true));
+
+ assert_equals(getComputedStyle(div).zIndex, '2');
+}, 'Nesting-selector within :scope rule (double nested)');
+</script> \ No newline at end of file