summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/interaction/focus/the-autofocus-attribute/autofocus-on-stable-document.html
blob: 47e3e3fd0abdc93e8447c099314935f8cdc31c42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/utils.js"></script>

<body>
<script>
'use strict';

promise_test(async t => {
  await waitForLoad(window);
  await timeOut(t, 1000);
  let element = document.createElement('input');
  element.autofocus = true;
  document.body.appendChild(element);
  await waitUntilStableAutofocusState();
  assert_equals(document.activeElement, element);
}, 'Autofocus should work if an element with autofocus is inserted into a ' +
    'document which was loaded some time ago.');
</script>
</body>