summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/selectors/focus-visible-018-2.html
blob: 5481b56c26e741f8345f71d96a2a14a1e166e1b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<!DOCTYPE html>
<meta charset="utf-8" />
<title>CSS Test (Selectors): Mouse focus does not show a focus ring by default</title>
<link rel="author" title="Manuel Rego Casasnovas" href="mailto:rego@igalia.com">
<link rel="help" href="https://drafts.csswg.org/selectors-4/#the-focus-visible-pseudo" />
<link rel="help" href="https://html.spec.whatwg.org/#phrasing-content-3" />
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/css/support/parsing-testcommon.js"></script>
<style>
  #warning {
    display: none;
    background: red;
  }

  @supports not selector(:focus-visible) {
    #instructions {
      display: none;
    }

    #warning {
      display: block;
    }
  }
</style>

<p>This test checks that by default, using the mouse to focus a generic element does not show a focus ring (because it does not trigger <code>:focus-visible</code> matching).</p>
<ol id="instructions">
  <li>Click on the elements below"</li>
  <li>If the elements do not have a focus ring, then the test result is SUCCESS.</li>
</ol>
<p id="warning">Your user-agent does not support <code>:focus-visible</code> pseudo-class, please SKIP this test.</p>

<abbr tabindex="0">abbr</abbr>
<address tabindex="0">address</address>
<a href="#">a</a>
<bdi tabindex="0">bdi</bdi>
<blockquote tabindex="0">blockquote</blockquote>
<code tabindex="0">code</code>
<dd tabindex="0">dd</dd>
<details open><summary tabindex="0">summary</summary></details>
<details tabindex="0"></details>
<div tabindex="0">div</div>
<dl tabindex="0">dl</dl>
<dt tabindex="0">dt</dt>
<em tabindex="0">em</em>
<fieldset><legend tabindex="0">legend</legend></fieldset>
<figcaption tabindex="0">figcaption</figcaption>
<figure tabindex="0">figure</figure>
<form tabindex="0">form</form>
<hr tabindex="0" />
<img tabindex="0" src="/images/green.png" />
<label tabindex="0">label</label>
<li tabindex="0">li</li>
<mark tabindex="0">mark</mark>
<meter tabindex="0"></meter>
<ol tabindex="0">ol</ol>
<pre tabindex="0">pre</pre>
<progress tabindex="0"></progress>
<p tabindex="0">p</p>
<small tabindex="0">small</small>
<s tabindex="0">s</s>
<strong tabindex="0">strong</strong>
<sub tabindex="0">sub</sub>
<sup tabindex="0">sup</sup>
<table><caption tabindex="0">caption</caption></table>
<table tabindex="0"><td>table</td></table>
<table><td tabindex="0">td</td></table>
<time tabindex="0">time</time>
<ul tabindex="0">ul</ul>
<u tabindex="0">u</u>

<script>
  setup({ explicit_done: true });

  // Check that :focus-visible is supported.
  test_valid_selector(':focus-visible');

  const elements = document.querySelectorAll("[tabindex]");
  for (let i = 0; i < elements.length; i++) {
    const target = elements[i];
    promise_test(() => {
      return new Promise(resolve => {
        target.addEventListener("focus", resolve);
        test_driver.click(target).then(() => {
          if (i == (elements.length - 1))
            done();
        }).catch(resolve);
      }).then(() => {
        assert_equals(getComputedStyle(target).outlineStyle, "none", `outline-style for ${target.tagName} should be none`);
      });
    }, `Mouse focus does not show a focus ring by default in element ${target.tagName}`);
  }
</script>