chromium/third_party/blink/web_tests/editing/spelling/spellcheck-attribute.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>
// This test verifies if the "spellcheck" attribute is implemented as written in
// its specification.

spellcheck_test(
  '<div spellcheck="true"><input type="text" value="zz."></div>',
  document => document.querySelector('input').focus(),
  '<div spellcheck="true"><input type="text" value="#zz#."></div>',
  'INPUT type=text is checked when it does not have spellcheck attribute and its parent has spellcheck=true.');

spellcheck_test(
  '<div spellcheck="true"><input type="text" spellcheck="true" value="zz."></div>',
  document => document.querySelector('input').focus(),
  '<div spellcheck="true"><input spellcheck="true" type="text" value="#zz#."></div>',
  'INPUT type=text is checked when it has spellcheck=true and its parent has spellcheck=true.');

spellcheck_test(
  '<div spellcheck="true"><input type="text" spellcheck="false" value="zz."></div>',
  document => document.querySelector('input').focus(),
  '<div spellcheck="true"><input spellcheck="false" type="text" value="zz."></div>',
  'INPUT type=text is not checked when it has spellcheck=false and its parent has spellcheck=true.');

spellcheck_test(
  '<div spellcheck="true"><input type="text" spellcheck="invalidValue" value="zz."></div>',
  document => document.querySelector('input').focus(),
  '<div spellcheck="true"><input spellcheck="invalidValue" type="text" value="#zz#."></div>',
  'INPUT type=text is checked when it has spellcheck attribute with invalid value and its parent has spellcheck=true.');

spellcheck_test(
  '<div spellcheck="true"><input type="text" spellcheck value="zz."></div>',
  document => document.querySelector('input').focus(),
  '<div spellcheck="true"><input spellcheck type="text" value="#zz#."></div>',
  'INPUT type=text is checked when it has spellcheck attribute with empty value and its parent has spellcheck=true.');

spellcheck_test(
  '<div spellcheck="true"><input type="search" value="zz."></div>',
  document => document.querySelector('input').focus(),
  '<div spellcheck="true"><input type="search" value="#zz#."></div>',
  'INPUT type=search is checked when it does not have spellcheck attribute and its parent has spellcheck=true.');

spellcheck_test(
  '<div spellcheck="true"><input type="search" spellcheck="true" value="zz."></div>',
  document => document.querySelector('input').focus(),
  '<div spellcheck="true"><input spellcheck="true" type="search" value="#zz#."></div>',
  'INPUT type=search is checked when it has spellcheck=true and its parent has spellcheck=true.');

spellcheck_test(
  '<div spellcheck="true"><input type="search" spellcheck="false" value="zz."></div>',
  document => document.querySelector('input').focus(),
  '<div spellcheck="true"><input spellcheck="false" type="search" value="zz."></div>',
  'INPUT type=search is not checked when it has spellcheck=false and its parent has spellcheck=true.');

spellcheck_test(
  '<div spellcheck="true"><input type="search" spellcheck="invalidValue" value="zz."></div>',
  document => document.querySelector('input').focus(),
  '<div spellcheck="true"><input spellcheck="invalidValue" type="search" value="#zz#."></div>',
  'INPUT type=search is checked when it has spellcheck attribute with invalid value and its parent has spellcheck=true.');

spellcheck_test(
  '<div spellcheck="true"><input type="search" spellcheck value="zz."></div>',
  document => document.querySelector('input').focus(),
  '<div spellcheck="true"><input spellcheck type="search" value="#zz#."></div>',
  'INPUT type=search is checked when it has spellcheck attribute with empty value and its parent has spellcheck=true.');

spellcheck_test(
  '<div spellcheck="false"><input type="text" value="zz."></div>',
  document => document.querySelector('input').focus(),
  '<div spellcheck="false"><input type="text" value="zz."></div>',
  'INPUT type=text is not checked when it does not have spellcheck attribute and its parent has spellcheck=false.');

spellcheck_test(
  '<div spellcheck="false"><input type="text" spellcheck="true" value="zz."></div>',
  document => document.querySelector('input').focus(),
  '<div spellcheck="false"><input spellcheck="true" type="text" value="#zz#."></div>',
  'INPUT type=text is checked when it has spellcheck=true and its parent has spellcheck=false.');

spellcheck_test(
  '<div spellcheck="false"><input type="text" spellcheck="false" value="zz."></div>',
  document => document.querySelector('input').focus(),
  '<div spellcheck="false"><input spellcheck="false" type="text" value="zz."></div>',
  'INPUT type=text is not checked when it has spellcheck=false and its parent has spellcheck=false.');

spellcheck_test(
  '<div spellcheck="false"><input type="text" spellcheck="invalidValue" value="zz."></div>',
  document => document.querySelector('input').focus(),
  '<div spellcheck="false"><input spellcheck="invalidValue" type="text" value="zz."></div>',
  'INPUT type=text is not checked when it has spellcheck attribute with invalid value and its parent has spellcheck=false.');

spellcheck_test(
  '<div spellcheck="false"><input type="text" spellcheck value="zz."></div>',
  document => document.querySelector('input').focus(),
  '<div spellcheck="false"><input spellcheck type="text" value="#zz#."></div>',
  'INPUT type=text is checked when it has spellcheck attribute with empty value and its parent has spellcheck=false.');

spellcheck_test(
  '<div spellcheck="false"><input type="search" value="zz."></div>',
  document => document.querySelector('input').focus(),
  '<div spellcheck="false"><input type="search" value="zz."></div>',
  'INPUT type=search is not checked when it does not have spellcheck attribute and its parent has spellcheck=false.');

spellcheck_test(
  '<div spellcheck="false"><input type="search" spellcheck="true" value="zz."></div>',
  document => document.querySelector('input').focus(),
  '<div spellcheck="false"><input spellcheck="true" type="search" value="#zz#."></div>',
  'INPUT type=search is checked when it has spellcheck=true and its parent has spellcheck=false.');

spellcheck_test(
  '<div spellcheck="false"><input type="search" spellcheck="false" value="zz."></div>',
  document => document.querySelector('input').focus(),
  '<div spellcheck="false"><input spellcheck="false" type="search" value="zz."></div>',
  'INPUT type=search is not checked when it has spellcheck=false and its parent has spellcheck=false.');

spellcheck_test(
  '<div spellcheck="false"><input type="search" spellcheck="invalidValue" value="zz."></div>',
  document => document.querySelector('input').focus(),
  '<div spellcheck="false"><input spellcheck="invalidValue" type="search" value="zz."></div>',
  'INPUT type=search is not checked when it has spellcheck attribute with invalid value and its parent has spellcheck=false.');

spellcheck_test(
  '<div spellcheck="false"><input type="search" spellcheck value="zz."></div>',
  document => document.querySelector('input').focus(),
  '<div spellcheck="false"><input spellcheck type="search" value="#zz#."></div>',
  'INPUT type=search is checked when it has spellcheck attribute with empty value and its parent has spellcheck=false.');
</script>