| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="../editing.js"></script> | 4 <script src="../editing.js"></script> |
| 5 <script src="resources/util.js"></script> | 5 <script src="resources/util.js"></script> |
| 6 <script src="../../resources/js-test.js"></script> | 6 <script src="../../resources/js-test.js"></script> |
| 7 </head> | 7 </head> |
| 8 <body onload="test();"> | 8 <body onload="test();"> |
| 9 <pre id="console"></pre> | |
| 10 <div id="container"> | 9 <div id="container"> |
| 11 <div id="test_editable" contentEditable>zz zz zz. </div> | 10 <div id="test_editable" contentEditable>zz zz zz.</div> |
| 12 <textarea id="test_textarea">zz zz zz.</textarea> | 11 <textarea id="test_textarea">zz zz zz.</textarea> |
| 13 <input type="text" id="test_textfield" value="zz zz zz."></input> | 12 <input type="text" id="test_textfield" value="zz zz zz."></input> |
| 14 </div> | 13 </div> |
| 15 <script> | 14 <script> |
| 16 description("Spell checking should be triggered on focus of an editable. " + | 15 description("Spell checking should be triggered on focus of an editable. " |
| 17 "To test manually type focus above editable and textarea. Misspellings in them "
+ | 16 + "To test manually, set focus on above elements. The test succeed if " |
| 18 "should be marked on focus."); | 17 + "misspellings are marked."); |
| 19 | 18 |
| 20 jsTestIsAsync = true; | 19 jsTestIsAsync = true; |
| 21 | 20 |
| 22 var testEditable = document.getElementById('test_editable'); | 21 var testEditable = document.getElementById('test_editable'); |
| 23 var testTextArea = document.getElementById('test_textarea'); | 22 var testTextArea = document.getElementById('test_textarea'); |
| 24 var testTextField = document.getElementById('test_textfield'); | 23 var testTextField = document.getElementById('test_textfield'); |
| 25 | 24 |
| 26 function test() | 25 function setFocusOnEditableElements() { |
| 27 { | 26 testEditable.focus(); |
| 28 if (!window.internals) | 27 testTextArea.focus(); |
| 29 { | 28 testTextField.focus(); |
| 30 log("Automatic testing impossible. Test manually."); | 29 } |
| 30 |
| 31 var expectedNumberOfMarkers; |
| 32 var textNode; |
| 33 |
| 34 function verifySpellingMarkers(expectation, doneCallback) { |
| 35 expectedNumberOfMarkers = expectation; |
| 36 textNode = findFirstTextNode(testEditable); |
| 37 shouldBecomeEqual('internals.markerCountForNode(textNode, "spelling")', 'exp
ectedNumberOfMarkers', function() { |
| 38 shouldBecomeEqual('internals.markerCountForNode(textNode, "spelling")',
'expectedNumberOfMarkers', function() { |
| 39 shouldBecomeEqual('internals.markerCountForNode(textNode, "spelling"
)', 'expectedNumberOfMarkers', function() { |
| 40 doneCallback(); |
| 41 // After focusing the editable elements, check whether they have
spelling markers. |
| 42 verifySpellingMarkers(3, finishJSTest); |
| 43 }); |
| 44 }); |
| 45 }); |
| 46 } |
| 47 |
| 48 function test() { |
| 49 if (!window.internals) { |
| 50 debug("Automatic testing impossible. Test manually."); |
| 31 return; | 51 return; |
| 32 } | 52 } |
| 33 | 53 |
| 34 internals.settings.setUnifiedTextCheckerEnabled(true); | 54 internals.settings.setUnifiedTextCheckerEnabled(true); |
| 35 internals.settings.setAsynchronousSpellCheckingEnabled(true); | 55 internals.settings.setAsynchronousSpellCheckingEnabled(true); |
| 36 internals.setContinuousSpellCheckingEnabled(true); | |
| 37 | 56 |
| 38 function waitForMarkersToAppear(nretry) | 57 // Check whether non-focused elements do not have spelling markers, then |
| 39 { | 58 // verify them when they get focused. |
| 40 if (nretry > 0 | 59 verifySpellingMarkers(0, setFocusOnEditableElements); |
| 41 && (!internals.markerCountForNode(findFirstTextNode(testEditable), "
spelling") | |
| 42 || !internals.markerCountForNode(findFirstTextNode(testTextArea), "s
pelling") | |
| 43 || !internals.markerCountForNode(findFirstTextNode(testTextField), "
spelling"))) { | |
| 44 window.setTimeout(function() { waitForMarkersToAppear(nretry - 1); }
, 5); | |
| 45 } else { | |
| 46 shouldBe('internals.markerCountForNode(findFirstTextNode(testTextAre
a), "spelling")', '3'); | |
| 47 shouldBe('internals.markerCountForNode(findFirstTextNode(testEditabl
e), "spelling")', '3'); | |
| 48 shouldBe('internals.markerCountForNode(findFirstTextNode(testTextFie
ld), "spelling")', '3'); | |
| 49 finishJSTest(); | |
| 50 } | |
| 51 } | |
| 52 | |
| 53 shouldBe('internals.markerCountForNode(findFirstTextNode(testEditable), "spe
lling")', '0'); | |
| 54 testEditable.focus(); | |
| 55 shouldBe('internals.markerCountForNode(findFirstTextNode(testTextArea), "spe
lling")', '0'); | |
| 56 testTextArea.focus(); | |
| 57 shouldBe('internals.markerCountForNode(findFirstTextNode(testTextField), "sp
elling")', '0'); | |
| 58 testTextField.focus(); | |
| 59 waitForMarkersToAppear(10); | |
| 60 } | 60 } |
| 61 | 61 |
| 62 </script> | 62 </script> |
| 63 </body> | 63 </body> |
| 64 </html> | 64 </html> |
| OLD | NEW |