chromium/third_party/blink/web_tests/external/wpt/html/interaction/focus/the-autofocus-attribute/no-autofocus-on-changing-input-type.html

<!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.
// https://bugs.webkit.org/show_bug.cgi?id=68513
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>