summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-cascade/scope-focus.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-focus.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-focus.html')
-rw-r--r--testing/web-platform/tests/css/css-cascade/scope-focus.html106
1 files changed, 106 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-cascade/scope-focus.html b/testing/web-platform/tests/css/css-cascade/scope-focus.html
new file mode 100644
index 0000000000..578a7702c1
--- /dev/null
+++ b/testing/web-platform/tests/css/css-cascade/scope-focus.html
@@ -0,0 +1,106 @@
+<!DOCTYPE html>
+<title>@scope and :focus</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>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<main id=main></main>
+
+<template id=test_subject>
+ <div>
+ <style>
+ @scope (.a:focus) {
+ :scope { z-index: 1; }
+ }
+ </style>
+ <div class=a tabindex=0>1</div>
+</template>
+<script>
+promise_test(async (t) => {
+ t.add_cleanup(() => main.replaceChildren());
+ main.append(test_subject.content.cloneNode(true));
+
+ let a = main.querySelector('.a');
+
+ assert_equals(getComputedStyle(a).zIndex, 'auto');
+ await test_driver.bless('focus', () => a.focus());
+ assert_equals(getComputedStyle(a).zIndex, '1');
+}, ':focus via :scope in subject');
+</script>
+
+<template id=test_non_subject>
+ <div>
+ <style>
+ @scope (.a:focus) {
+ :scope .b { z-index: 1; }
+ }
+ </style>
+ <div class=a tabindex=0>
+ <div class=b>2</div>
+ </div>
+</template>
+<script>
+promise_test(async (t) => {
+ t.add_cleanup(() => main.replaceChildren());
+ main.append(test_non_subject.content.cloneNode(true));
+
+ let a = main.querySelector('.a');
+ let b = main.querySelector('.b');
+
+ assert_equals(getComputedStyle(b).zIndex, 'auto');
+ await test_driver.bless('focus', () => a.focus());
+ assert_equals(getComputedStyle(b).zIndex, '1');
+}, ':focus via :scope in non-subject');
+</script>
+
+<template id=test_subject_limit>
+ <div>
+ <style>
+ @scope (.a) to (:scope:focus) {
+ :scope { z-index: 1; }
+ }
+ </style>
+ <div class=a tabindex=0>3</div>
+</template>
+<script>
+promise_test(async (t) => {
+ t.add_cleanup(() => main.replaceChildren());
+ main.append(test_subject_limit.content.cloneNode(true));
+
+ let a = main.querySelector('.a');
+
+ assert_equals(getComputedStyle(a).zIndex, '1');
+ await test_driver.bless('focus', () => a.focus());
+ // After focus(), we're no longer in scope because the limit (to-selector)
+ // kicks in.
+ assert_equals(getComputedStyle(a).zIndex, 'auto');
+}, ':focus in limit, :scope in subject');
+</script>
+
+<template id=test_non_subject_limit>
+ <div>
+ <style>
+ @scope (.a) to (.b:focus) {
+ .b { z-index: 1; }
+ }
+ </style>
+ <div class=a tabindex=0>
+ <div class=b tabindex=1>4</div>
+ </div>
+</template>
+<script>
+promise_test(async (t) => {
+ t.add_cleanup(() => main.replaceChildren());
+ main.append(test_non_subject_limit.content.cloneNode(true));
+
+ let a = main.querySelector('.a');
+ let b = main.querySelector('.b');
+
+ assert_equals(getComputedStyle(b).zIndex, '1');
+ await test_driver.bless('focus', () => b.focus());
+ // After focus(), we're no longer in scope because the limit (to-selector)
+ // kicks in.
+ assert_equals(getComputedStyle(b).zIndex, 'auto');
+}, ':focus in intermediate limit, :scope in subject');
+</script>