chromium/third_party/blink/web_tests/editing/spelling/spellcheck-attribute-settings-default.html

<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script src="spellcheck_test.js"></script>

<script>
// Tests with spellcheck enabled by default.

spellcheck_test(
  '<input type="text" value="zz.">',
  document => {
    internals.settings.setSpellCheckEnabledByDefault(true);
    document.querySelector('input').focus();
  },
  '<input type="text" value="#zz#.">',
  'INPUT without spellcheck attribute is checked when spellcheck is enabled by default.');

spellcheck_test(
  '<input spellcheck="true" type="text" value="zz.">',
  document => {
    internals.settings.setSpellCheckEnabledByDefault(true);
    document.querySelector('input').focus();
  },
  '<input spellcheck="true" type="text" value="#zz#.">',
  'INPUT with spellcheck=true is checked when spellcheck is enabled by default.');

spellcheck_test(
  '<input spellcheck="false" type="text" value="zz.">',
  document => {
    internals.settings.setSpellCheckEnabledByDefault(true);
    document.querySelector('input').focus();
  },
  '<input spellcheck="false" type="text" value="zz.">',
  'INPUT with spellcheck=false is not checked when spellcheck is enabled by default.');

spellcheck_test(
  '<input spellcheck="invalidValue" type="text" value="zz.">',
  document => {
    internals.settings.setSpellCheckEnabledByDefault(true);
    document.querySelector('input').focus();
  },
  '<input spellcheck="invalidValue" type="text" value="#zz#.">',
  'INPUT with invalid spellcheck attribute value is checked when spellcheck is enabled by default.');

spellcheck_test(
  '<input spellcheck type="text" value="zz.">',
  document => {
    internals.settings.setSpellCheckEnabledByDefault(true);
    document.querySelector('input').focus();
  },
  '<input spellcheck type="text" value="#zz#.">',
  'INPUT with empty spellcheck attribute is checked when spellcheck is enabled by default.');

// Tests with spellcheck disabled by default.

spellcheck_test(
  '<input type="text" value="zz.">',
  document => {
    internals.settings.setSpellCheckEnabledByDefault(false);
    document.querySelector('input').focus();
  },
  '<input type="text" value="zz.">',
  'INPUT without spellcheck attribute is not checked when spellcheck is disabled by default.');

spellcheck_test(
  '<input spellcheck="true" type="text" value="zz.">',
  document => {
    internals.settings.setSpellCheckEnabledByDefault(false);
    document.querySelector('input').focus();
  },
  '<input spellcheck="true" type="text" value="#zz#.">',
  'INPUT with spellcheck=true is checked when spellcheck is disabled by default.');

spellcheck_test(
  '<input spellcheck="false" type="text" value="zz.">',
  document => {
    internals.settings.setSpellCheckEnabledByDefault(false);
    document.querySelector('input').focus();
  },
  '<input spellcheck="false" type="text" value="zz.">',
  'INPUT with spellcheck=false is not checked when spellcheck is disabled by default.');

spellcheck_test(
  '<input spellcheck="invalidValue" type="text" value="zz.">',
  document => {
    internals.settings.setSpellCheckEnabledByDefault(false);
    document.querySelector('input').focus();
  },
  '<input spellcheck="invalidValue" type="text" value="zz.">',
  'INPUT with invalid spellcheck attribute value is not checked when spellcheck is disabled by default.');

spellcheck_test(
  '<input spellcheck type="text" value="zz.">',
  document => {
    internals.settings.setSpellCheckEnabledByDefault(false);
    document.querySelector('input').focus();
  },
  '<input spellcheck type="text" value="#zz#.">',
  'INPUT with empty spellcheck attribute is checked when spellcheck is disabled by default.');
</script>