| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!doctype html> |
| 2 <html> | 2 <script src="../../resources/testharness.js"></script> |
| 3 <head> | 3 <script src="../../resources/testharnessreport.js"></script> |
| 4 <title>Spellcheck Attribute Settings Default Test</title> | 4 <script src="../assert_selection.js"></script> |
| 5 <script src="../editing.js"></script> | 5 <script src="spellcheck_test.js"></script> |
| 6 <script src="resources/util.js"></script> | 6 |
| 7 <script src="../../resources/js-test.js"></script> | |
| 8 </head> | |
| 9 <body> | |
| 10 <div id="testRoot"> | |
| 11 <label>1.1.</label><input id="test1_1" type="text"></input><br/> | |
| 12 <label>1.2.</label><input id="test1_2" type="text" spellcheck="true"></input><br
/> | |
| 13 <label>1.3.</label><input id="test1_3" type="text" spellcheck="false"></input><b
r/> | |
| 14 <label>1.4.</label><input id="test1_4" type="text" spellcheck="InvalidValue"></i
nput><br/> | |
| 15 <label>1.5.</label><input id="test1_5" type="text" spellcheck></input><br/> | |
| 16 </div> | |
| 17 <script> | 7 <script> |
| 18 description('This tests that the spellcheck default value is as specified in ' | 8 // Tests with spellcheck enabled by default. |
| 19 + 'internal blink settings. This allows embedders to specify spellchecking ' | |
| 20 + 'behavior when the spellcheck attribute is not explicitly set.'); | |
| 21 | 9 |
| 22 jsTestIsAsync = true; | 10 spellcheck_test( |
| 23 if (window.testRunner) | 11 '<input type="text" value="zz.">', |
| 24 testRunner.setMockSpellCheckerEnabled(true); | 12 document => { |
| 13 internals.settings.setSpellCheckEnabledByDefault(true); |
| 14 document.querySelector('input').focus(); |
| 15 }, |
| 16 '<input type="text" value="#zz#.">', |
| 17 'INPUT without spellcheck attribute is checked when spellcheck is enabled by d
efault.'); |
| 25 | 18 |
| 26 // Type misspelling to all input elements. | 19 spellcheck_test( |
| 27 var inputs = document.getElementsByTagName('input'); | 20 '<input spellcheck="true" type="text" value="zz.">', |
| 28 for (var i = 0; i < inputs.length; i++) | 21 document => { |
| 29 typeText(inputs[i], 'zz '); | 22 internals.settings.setSpellCheckEnabledByDefault(true); |
| 23 document.querySelector('input').focus(); |
| 24 }, |
| 25 '<input spellcheck="true" type="text" value="#zz#.">', |
| 26 'INPUT with spellcheck=true is checked when spellcheck is enabled by default.'
); |
| 30 | 27 |
| 31 var shouldBeMarked; | 28 spellcheck_test( |
| 29 '<input spellcheck="false" type="text" value="zz.">', |
| 30 document => { |
| 31 internals.settings.setSpellCheckEnabledByDefault(true); |
| 32 document.querySelector('input').focus(); |
| 33 }, |
| 34 '<input spellcheck="false" type="text" value="zz.">', |
| 35 'INPUT with spellcheck=false is not checked when spellcheck is enabled by defa
ult.'); |
| 32 | 36 |
| 33 function testMarkerForMisspelledWord(id, isMisspelled, enabled_by_default) { | 37 spellcheck_test( |
| 34 if (!window.internals) | 38 '<input spellcheck="invalidValue" type="text" value="zz.">', |
| 35 return done(); | 39 document => { |
| 40 internals.settings.setSpellCheckEnabledByDefault(true); |
| 41 document.querySelector('input').focus(); |
| 42 }, |
| 43 '<input spellcheck="invalidValue" type="text" value="#zz#.">', |
| 44 'INPUT with invalid spellcheck attribute value is checked when spellcheck is e
nabled by default.'); |
| 36 | 45 |
| 37 internals.settings.setSpellCheckEnabledByDefault(enabled_by_default); | 46 spellcheck_test( |
| 47 '<input spellcheck type="text" value="zz.">', |
| 48 document => { |
| 49 internals.settings.setSpellCheckEnabledByDefault(true); |
| 50 document.querySelector('input').focus(); |
| 51 }, |
| 52 '<input spellcheck type="text" value="#zz#.">', |
| 53 'INPUT with empty spellcheck attribute is checked when spellcheck is enabled b
y default.'); |
| 38 | 54 |
| 39 var inputElement = document.getElementById(id); | 55 // Tests with spellcheck disabled by default. |
| 40 // Spelling markers for input will appear if it's focused. | |
| 41 inputElement.focus(); | |
| 42 | 56 |
| 43 debug("id=" + id + " type=" + inputElement.type + " spellcheck=" + inputElem
ent.spellcheck + " enabled_by_default=" + enabled_by_default); | 57 spellcheck_test( |
| 58 '<input type="text" value="zz.">', |
| 59 document => { |
| 60 internals.settings.setSpellCheckEnabledByDefault(false); |
| 61 document.querySelector('input').focus(); |
| 62 }, |
| 63 '<input type="text" value="zz.">', |
| 64 'INPUT without spellcheck attribute is not checked when spellcheck is disabled
by default.'); |
| 44 | 65 |
| 45 shouldBeMarked = isMisspelled; | 66 spellcheck_test( |
| 46 shouldBecomeEqual('internals.hasSpellingMarker(document, 0, 2)', 'shouldBeMa
rked', done); | 67 '<input spellcheck="true" type="text" value="zz.">', |
| 47 } | 68 document => { |
| 69 internals.settings.setSpellCheckEnabledByDefault(false); |
| 70 document.querySelector('input').focus(); |
| 71 }, |
| 72 '<input spellcheck="true" type="text" value="#zz#.">', |
| 73 'INPUT with spellcheck=true is checked when spellcheck is disabled by default.
'); |
| 48 | 74 |
| 49 var tests = [ | 75 spellcheck_test( |
| 50 // spellcheck enabled by default | 76 '<input spellcheck="false" type="text" value="zz.">', |
| 51 function() { testMarkerForMisspelledWord('test1_1', true, true); }, | 77 document => { |
| 52 function() { testMarkerForMisspelledWord('test1_2', true, true); }, | 78 internals.settings.setSpellCheckEnabledByDefault(false); |
| 53 function() { testMarkerForMisspelledWord('test1_3', false, true); }, | 79 document.querySelector('input').focus(); |
| 54 function() { testMarkerForMisspelledWord('test1_4', true, true); }, | 80 }, |
| 55 function() { testMarkerForMisspelledWord('test1_5', true, true); }, | 81 '<input spellcheck="false" type="text" value="zz.">', |
| 56 // spellcheck disabled by default | 82 'INPUT with spellcheck=false is not checked when spellcheck is disabled by def
ault.'); |
| 57 function() { testMarkerForMisspelledWord('test1_1', false, false); }, | |
| 58 function() { testMarkerForMisspelledWord('test1_2', true, false); }, | |
| 59 function() { testMarkerForMisspelledWord('test1_3', false, false); }, | |
| 60 function() { testMarkerForMisspelledWord('test1_4', false, false); }, | |
| 61 function() { testMarkerForMisspelledWord('test1_5', false, false); }, | |
| 62 ]; | |
| 63 | 83 |
| 64 function done() | 84 spellcheck_test( |
| 65 { | 85 '<input spellcheck="invalidValue" type="text" value="zz.">', |
| 66 var next = tests.shift(); | 86 document => { |
| 67 if (next) | 87 internals.settings.setSpellCheckEnabledByDefault(false); |
| 68 return window.setTimeout(next, 0); | 88 document.querySelector('input').focus(); |
| 89 }, |
| 90 '<input spellcheck="invalidValue" type="text" value="zz.">', |
| 91 'INPUT with invalid spellcheck attribute value is not checked when spellcheck
is disabled by default.'); |
| 69 | 92 |
| 70 if (window.testRunner) { | 93 spellcheck_test( |
| 71 // Cleaning up for expectation text if running on DRT. | 94 '<input spellcheck type="text" value="zz.">', |
| 72 document.getElementById("testRoot").style.display = "none"; | 95 document => { |
| 73 } | 96 internals.settings.setSpellCheckEnabledByDefault(false); |
| 74 finishJSTest(); | 97 document.querySelector('input').focus(); |
| 75 } | 98 }, |
| 76 done(); | 99 '<input spellcheck type="text" value="#zz#.">', |
| 77 | 100 'INPUT with empty spellcheck attribute is checked when spellcheck is disabled
by default.'); |
| 78 </script> | 101 </script> |
| 79 </body> | |
| 80 </html> | |
| OLD | NEW |