chromium/third_party/blink/web_tests/editing/spelling/spellcheck-password.html

<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<p>Spell checker should not make spell check request in password field.</p>
<div><input type="password" id="pwd" /></div>
<script>
const password = document.getElementById("pwd");

function spinSpellChecker() {
  while (internals.idleTimeSpellCheckerState(document) !== 'Inactive')
    internals.runIdleTimeSpellChecker(document);
}

setup(() => {
  assert_own_property(window, 'testRunner', 'This test requires window.testRunner');
  assert_own_property(window, 'internals', 'This test requires window.internals');
  testRunner.setMockSpellCheckerEnabled(true);
  password.focus();
});

test(() => {
  assert_false(password.spellcheck);

  const sequenceBefore = internals.lastSpellCheckRequestSequence(document);

  document.execCommand("insertText", false, "zz. ");
  assert_equals(password.value.length, 4);

  spinSpellChecker();
  assert_equals(internals.lastSpellCheckRequestSequence(document), sequenceBefore);
}, "Spellchecker does not request checking for password fields");

test(() => {
  // Some websites toggle between "password" and "text" types for hiding and
  // revealing passwords. Make sure not to spellcheck in this case.
  password.type = "text";
  assert_false(password.spellcheck);

  const sequenceBefore = internals.lastSpellCheckRequestSequence(document);

  document.execCommand("insertText", false, "zz. ");
  assert_equals(password.value.length, 8);

  spinSpellChecker();
  assert_equals(internals.lastSpellCheckRequestSequence(document), sequenceBefore);
}, "Spellchecker does not request checking for revealed password fields");
</script>