File: child-sequential-focus.html

package info (click to toggle)
thunderbird 1%3A140.4.0esr-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,609,432 kB
  • sloc: cpp: 7,672,442; javascript: 5,901,613; ansic: 3,898,954; python: 1,413,343; xml: 653,997; asm: 462,286; java: 180,927; sh: 113,489; makefile: 20,460; perl: 14,288; objc: 13,059; yacc: 4,583; pascal: 3,352; lex: 1,720; ruby: 1,222; exp: 762; sql: 715; awk: 580; php: 436; lisp: 430; sed: 70; csh: 10
file content (60 lines) | stat: -rw-r--r-- 2,332 bytes parent folder | download | duplicates (10)
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
<!DOCTYPE html>
<link rel=author href="mailto:jarhar@chromium.org">
<link rel=help href="https://github.com/whatwg/html/pull/8199">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<dialog autofocus id=autofocusdialog data-description="dialog element with autofocus should get initial focus." class=target>
  <button tabindex="0">focusable button</button>
  <button tabindex="0" autofocus>autofocusable button</button>
</dialog>

<dialog id=keyboardfocusdialog data-description="Only keyboard-focusable elements should get dialog initial focus.">
  <button tabindex="-1">mouse focusable button</button>
  <button tabindex="0" class=target>keyboard focusable button</button>
</dialog>

<dialog id=autofocuswithoutkeyboarddialog data-description="Autofocus takes precedence over keyboard-focusable requirement.">
  <button tabindex="0">keyboard focusable button</button>
  <button tabindex="-1" autofocus class=target>mouse focusable autofocus button</button>
</dialog>

<dialog id=subtree data-description="Only keyboard-focusable elements should get dialog initial focus including in subtrees.">
  <div>
    <button tabindex="-1">mouse focusable button</button>
    <button tabindex="0" class=target>keyboard focusable button</button>
  </div>
</dialog>

<dialog id=nestedbuttons data-description="Only keyboard-focusable elements should get dialog initial focus including in nested buttons.">
  <button tabindex="-1">
    <span>mouse focusable button</span>
    <button tabindex="-1">nested mouse focusable button</button>
  </button>
  <button tabindex="0" class=target>keyboard focusable button</button>
</dialog>

<script>
document.querySelectorAll('dialog').forEach(dialog => {
  test(t => {
    let target = dialog.querySelector('.target');
    if (dialog.classList.contains('target')) {
      target = dialog;
    }
    t.add_cleanup(() => {
      if (dialog.open)
        dialog.close();
    });

    dialog.showModal();
    assert_equals(document.activeElement, target,
      'showModal: the target element did not receive initial focus.');
    dialog.close();

    dialog.show();
    assert_equals(document.activeElement, target,
      'show: the target element did not receive initial focus.');
    dialog.close();
  }, dialog.dataset.description);
});
</script>