summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/dialog-autofocus-just-once.html
blob: 894efd59dc290d682b6732e49782606a90f4fad1 (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
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/html/interaction/focus/the-autofocus-attribute/resources/utils.js"></script>
<body>
<dialog>
<input>
<input autofocus>
</dialog>
<script>
// https://github.com/whatwg/html/issues/4788
promise_test(async () => {
  const dialog = document.querySelector('dialog');
  dialog.show();
  assert_equals(document.activeElement, dialog.querySelector('[autofocus]'),
      'dialog.show() should set focus on a descendant element with an ' +
      'autofocus attribute.');
  document.activeElement.blur();
  await waitUntilStableAutofocusState();
  assert_equals(document.activeElement, document.body,
      'Non-dialog autofocus processing should be skipped.');
}, 'An autofocus element in a dialog element should not try to get focus twice.');
</script>
</body>