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/no-autofocus-on-changing-input-type.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>
<input id="input1" autofocus>
<select><option>o1</option></select>
<script>
"use strict";
// WebKit had a bug that reattaching RenderObject triggered autofocus again.
promise_test(async () => {
const input1 = document.querySelector('input');
const select = document.querySelector('select');
await waitUntilStableAutofocusState();
assert_equals(document.activeElement, input1);
input1.onblur = () => { input1.type = 'password'; };
select.focus();
await waitUntilStableAutofocusState();
assert_equals(document.activeElement, select);
}, 'Changing input type should not refocus on the element.');
</script>
</body>