summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/selectors/focus-visible-005.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/selectors/focus-visible-005.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/selectors/focus-visible-005.html')
-rw-r--r--testing/web-platform/tests/css/selectors/focus-visible-005.html54
1 files changed, 54 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/selectors/focus-visible-005.html b/testing/web-platform/tests/css/selectors/focus-visible-005.html
new file mode 100644
index 0000000000..a678261f69
--- /dev/null
+++ b/testing/web-platform/tests/css/selectors/focus-visible-005.html
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8" />
+ <title>CSS Test (Selectors): Programmatic focus causes :focus-visible to match</title>
+ <link rel="author" title="Alice Boxhall" href="aboxhall@chromium.org" />
+ <link rel="help" href="https://drafts.csswg.org/selectors-4/#the-focus-visible-pseudo" />
+ <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>
+ <style>
+ @supports not selector(:focus-visible) {
+ :focus {
+ outline: red solid 5px;
+ background-color: red;
+ }
+ }
+
+ :focus-visible {
+ outline: red solid 5px;
+ }
+
+ :focus:not(:focus-visible) {
+ outline: 0;
+ background-color: lime;
+ }
+ </style>
+</head>
+<body>
+ This test checks that programmatically focusing an element after a click does not cause <code>:focus-visible</code> matching to trigger.
+ <ol id="instructions">
+ <li>If the user-agent does not claim to support the <code>:focus-visible</code> pseudo-class then SKIP this test.</li>
+ <li>Click the button below that says "Click me."</li>
+ <li>If the element that says "I will be focused programmatically." has a red outline, then the test result is FAILURE. If the element has a green background, then the test result is SUCCESS.</li>
+ </ol>
+ <br />
+ <button id="button">Click me.</button>
+ <div id="el" tabindex="-1">I will be focused programmatically.</div>
+ <script>
+ button.addEventListener("click", () => {
+ el.focus();
+ });
+ async_test(function(t) {
+ el.addEventListener("focus", t.step_func(function() {
+ assert_equals(getComputedStyle(el).backgroundColor, "rgb(0, 255, 0)", `backgroundColor for ${el.tagName}#${el.id} should be lime`);
+ assert_not_equals(getComputedStyle(el).outlineColor, "rgb(255, 0, 0)", `outlineColor for ${el.tagName}#${el.id} should NOT be red`);
+ t.done();
+ }));
+ test_driver.click(button);
+ }, "Programmatic focus after click should not match :focus-visible");
+ </script>
+</body>
+</html>