Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <html> | |
| 2 <head> | |
| 3 <script src="resources/util.js"></script> | |
| 4 <script src="../editing.js"></script> | |
| 5 <title>Editing multiple words with markers test</title> | |
| 6 </head> | |
| 7 <body> | |
| 8 <textarea id="testElement"></textarea> | |
| 9 <script src="../../resources/js-test.js"></script> | |
| 10 <script> | |
| 11 description('The test verifies if the spelling markers disappear when ' | |
| 12 + 'the multiple misspelled words are concatenated by delete command. ' | |
| 13 + 'To test manually, type "it\'s a meagesga meagesga ", then ' | |
| 14 + 'select and delete "esga meag". The test succeeds ' | |
| 15 + 'if the remaining text does not have any underline.'); | |
| 16 | |
| 17 jsTestIsAsync = true; | |
| 18 | |
| 19 if (window.internals) { | |
| 20 internals.settings.setUnifiedTextCheckerEnabled(true); | |
| 21 internals.settings.setAsynchronousSpellCheckingEnabled(true); | |
| 22 } | |
| 23 | |
| 24 function resetText() { | |
| 25 var textArea = document.getElementById('testElement'); | |
| 26 textArea.value = ""; | |
| 27 typeText(textArea, "it's a meagesga meagesga "); | |
|
please use gerrit instead
2015/02/10 22:55:42
This test will be flaky if you don't wait for spel
grzegorz
2015/02/11 10:54:23
Done.
grzegorz
2015/02/11 11:53:28
The problem here is a little complicated. Waiting
| |
| 28 } | |
| 29 | |
| 30 /** | |
| 31 * Those test cases verify if spelling markes disappear when | |
|
please use gerrit instead
2015/02/10 22:55:42
s/markes/markers/
grzegorz
2015/02/11 10:54:23
Done.
| |
| 32 * the multiple misspelled words are concatenated by delete command. | |
| 33 * | |
| 34 * '+' means the position where marker is expected. | |
| 35 * '-' means the position where marker is _not_ expected. | |
| 36 */ | |
| 37 var testCases = [ | |
| 38 | |
| 39 { selectionRange: null, spellingMarker1: [ 0, 4, 'false' ], spellingMa rker2: [ 7, 8, 'true' ] | |
| 40 // it's a meagesga meagesga | |
| 41 // ---- ++++++++ | |
| 42 }, | |
| 43 { selectionRange: [ 11, 20 ], spellingMarker1: [ 7, 4, 'false' ], spellingMa rker2: [ 11, 4, 'false' ] | |
| 44 // it's a meagesga | |
| 45 // -------- | |
| 46 }, | |
| 47 { selectionRange: [ 11, 16 ], spellingMarker1: [ 7, 4, 'false' ], spellingMa rker2: [ 11, 8, 'false' ] | |
| 48 // it's a meagmeagesga | |
| 49 // ------------ | |
| 50 }, | |
| 51 { selectionRange: [ 15, 20 ], spellingMarker1: [ 7, 8, 'false' ], spellingMa rker2: [ 15, 4, 'false' ] | |
| 52 // it's a meagesgaesga | |
| 53 // ------------ | |
| 54 } | |
| 55 ]; | |
| 56 | |
| 57 var marker1, marker2; | |
| 58 | |
| 59 function checkSpellingMarkerAfterDeleteingSelection(selectionRange, spellingMark er1, spellingMarker2) { | |
| 60 resetText(); | |
| 61 var testElement = document.getElementById('testElement'); | |
| 62 | |
| 63 if (selectionRange) { | |
| 64 testElement.setSelectionRange(selectionRange[0], selectionRange[1]); | |
| 65 execDeleteCommand(); | |
| 66 } | |
| 67 | |
| 68 if (!window.internals) | |
| 69 return done(); | |
|
please use gerrit instead
2015/02/10 22:55:42
If window.internals is not defined, this statement
grzegorz
2015/02/11 10:54:23
Done.
| |
| 70 | |
| 71 debug(testElement.value); | |
|
please use gerrit instead
2015/02/10 22:55:42
Is debugging necessary here?
grzegorz
2015/02/11 10:54:23
It adds empty line in the output.
| |
| 72 | |
| 73 marker1 = spellingMarker1; | |
| 74 marker2 = spellingMarker2; | |
| 75 | |
| 76 shouldBecomeEqual('internals.hasSpellingMarker(document, marker1[0], marker1 [1])', marker1[2], function() { | |
| 77 shouldBecomeEqual('internals.hasSpellingMarker(document, marker2[0], mar ker2[1])', marker2[2], function() { | |
| 78 debug(""); | |
|
please use gerrit instead
2015/02/10 22:55:42
Is debugging necessary here?
grzegorz
2015/02/11 10:54:22
Ditto.
| |
| 79 done(); | |
| 80 }); | |
| 81 }); | |
| 82 } | |
| 83 | |
| 84 function done() { | |
| 85 var nextTestCase = testCases.shift(); | |
| 86 if (nextTestCase) | |
|
please use gerrit instead
2015/02/10 22:55:42
I would feel better if you put curly braces around
grzegorz
2015/02/11 10:54:23
Done.
| |
| 87 return setTimeout(checkSpellingMarkerAfterDeleteingSelection, 0, | |
|
please use gerrit instead
2015/02/10 22:55:42
Why setTimeout(func, 0, args) instead of simply fu
grzegorz
2015/02/11 10:54:23
I can change it if you like.
| |
| 88 nextTestCase.selectionRange, | |
| 89 nextTestCase.spellingMarker1, | |
| 90 nextTestCase.spellingMarker2); | |
| 91 | |
| 92 finishJSTest(); | |
| 93 } | |
| 94 done(); | |
| 95 </script> | |
| 96 </body> | |
| 97 </html> | |
| OLD | NEW |