Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /html/interaction/focus/the-autofocus-attribute/autofocus-on-stable-document.html - WPT Dashboard Interop Dashboard
<!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>