Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 description('Tests if the spellchecker behavior change after the spellcheck attr ibute changed by the script.'); | 1 description('Tests if the spellchecker behavior change after the spellcheck attr ibute changed by the script.'); |
| 2 | 2 |
| 3 jsTestIsAsync = true; | |
| 4 | |
| 5 if (window.internals) { | |
| 6 internals.settings.setUnifiedTextCheckerEnabled(true); | |
| 7 internals.settings.setAsynchronousSpellCheckingEnabled(true); | |
| 8 } | |
| 9 | |
| 3 var root = document.createElement("div"); | 10 var root = document.createElement("div"); |
| 4 document.body.appendChild(root); | 11 document.body.appendChild(root); |
| 5 | 12 |
| 6 function childHasSpellingMarker(markup) | 13 function verifyChildSpellingMarker(markup, expectation) |
| 7 { | 14 { |
| 8 root.innerHTML = markup; | 15 var testElement = document.createElement("div"); |
| 9 var text = document.getElementById("child").firstChild; | 16 testElement.innerHTML = markup; |
| 10 document.getSelection().setPosition(text, 1); | 17 root.appendChild(testElement); |
| 18 | |
| 19 var childText = testElement.firstChild.childNodes[1].firstChild; | |
| 20 document.getSelection().setPosition(childText, 1); // [^] | |
|
tony
2014/03/10 17:07:56
I don't understand the comment. Either write out a
grzegorz
2014/03/11 13:24:32
My intention here was to show caret position at th
| |
| 11 document.execCommand("InsertText", false, 'z'); | 21 document.execCommand("InsertText", false, 'z'); |
| 12 document.execCommand("InsertText", false, 'z'); | 22 document.execCommand("InsertText", false, 'z'); |
| 13 document.execCommand("InsertText", false, ' '); | 23 document.execCommand("InsertText", false, ' '); |
| 14 var marked = internals.hasSpellingMarker(document, 1, 2); | 24 |
| 15 root.innerHTML = ""; | 25 if (window.testRunner) { |
| 16 return marked; | 26 debug(escapeHTML(testElement.innerHTML)); |
| 27 | |
| 28 shouldBecomeEqual('internals.hasSpellingMarker(document, 1, 2)', expecta tion ? "true" : "false", function() { | |
| 29 debug(""); | |
| 30 done(); | |
| 31 }); | |
| 32 } else | |
| 33 done(); | |
| 17 } | 34 } |
| 18 | 35 |
| 19 shouldBeFalse("childHasSpellingMarker(\"<div contentEditable>Foo <span spellchec k='false' id='child'>[]</span> Baz</div>\")"); | 36 var tests = [ |
| 20 shouldBeTrue("childHasSpellingMarker(\"<div contentEditable>Foo <span id='child' >[]</span> Baz</div>\")"); | 37 function() { verifyChildSpellingMarker("<div contentEditable>Foo <span spell check='false' id='child'>[]</span> Baz</div>", false); }, |
|
tony
2014/03/10 17:07:56
This is fine, but it might be easier to refactor o
grzegorz
2014/03/11 13:24:32
Thanks. I am not sure if I understood it correctly
| |
| 21 shouldBeTrue("childHasSpellingMarker(\"<div contentEditable>Foo <span spellcheck ='true' id='child'>[]</span> Baz</div>\")"); | 38 function() { verifyChildSpellingMarker("<div contentEditable>Foo <span id='c hild'>[]</span> Baz</div>", true); }, |
| 22 shouldBeFalse("childHasSpellingMarker(\"<div spellcheck='false' contentEditable> Foo <span spellcheck='false' id='child'>[]</span> Baz</div>\")"); | 39 function() { verifyChildSpellingMarker("<div contentEditable>Foo <span spell check='true' id='child'>[]</span> Baz</div>", true); }, |
| 23 shouldBeFalse("childHasSpellingMarker(\"<div spellcheck='false' contentEditable> Foo <span id='child'>[]</span> Baz</div>\")"); | 40 function() { verifyChildSpellingMarker("<div spellcheck='false' contentEdita ble>Foo <span spellcheck='false' id='child'>[]</span> Baz</div>", false); }, |
| 24 shouldBeTrue("childHasSpellingMarker(\"<div spellcheck='false' contentEditable>F oo <span spellcheck='true' id='child'>[]</span> Baz</div>\")"); | 41 function() { verifyChildSpellingMarker("<div spellcheck='false' contentEdita ble>Foo <span id='child'>[]</span> Baz</div>", false); }, |
| 25 shouldBeFalse("childHasSpellingMarker(\"<div spellcheck='true' contentEditable>F oo <span spellcheck='false' id='child'>[]</span> Baz</div>\")"); | 42 function() { verifyChildSpellingMarker("<div spellcheck='false' contentEdita ble>Foo <span spellcheck='true' id='child'>[]</span> Baz</div>", true); }, |
| 26 shouldBeTrue("childHasSpellingMarker(\"<div spellcheck='true' contentEditable>Fo o <span id='child'>[]</span> Baz</div>\")"); | 43 function() { verifyChildSpellingMarker("<div spellcheck='true' contentEditab le>Foo <span spellcheck='false' id='child'>[]</span> Baz</div>", false); }, |
| 27 shouldBeTrue("childHasSpellingMarker(\"<div spellcheck='true' contentEditable>Fo o <span spellcheck='true' id='child'>[]</span> Baz</div>\")"); | 44 function() { verifyChildSpellingMarker("<div spellcheck='true' contentEditab le>Foo <span id='child'>[]</span> Baz</div>", true); }, |
| 45 function() { verifyChildSpellingMarker("<div spellcheck='true' contentEditab le>Foo <span spellcheck='true' id='child'>[]</span> Baz</div>", true); } | |
| 46 ]; | |
| 47 | |
| 48 function done() | |
| 49 { | |
| 50 var next = tests.shift(); | |
| 51 if (next) | |
| 52 return setTimeout(next, 0); | |
| 53 | |
| 54 finishJSTest(); | |
| 55 } | |
| 56 done(); | |
| 28 | 57 |
| 29 var successfullyParsed = true; | 58 var successfullyParsed = true; |
| OLD | NEW |