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 behaves correctly when child has own ' |
| 2 + 'spellcheck attribute.'); |
| 3 |
| 4 jsTestIsAsync = true; |
| 5 |
| 6 if (window.internals) { |
| 7 internals.settings.setUnifiedTextCheckerEnabled(true); |
| 8 internals.settings.setAsynchronousSpellCheckingEnabled(true); |
| 9 } |
2 | 10 |
3 var root = document.createElement("div"); | 11 var root = document.createElement("div"); |
4 document.body.appendChild(root); | 12 document.body.appendChild(root); |
5 | 13 |
6 function childHasSpellingMarker(markup) | 14 function verifyChildSpellingMarker(element) |
7 { | 15 { |
8 root.innerHTML = markup; | 16 var testElement = document.createElement("div"); |
9 var text = document.getElementById("child").firstChild; | 17 testElement.innerHTML = element.markup; |
10 document.getSelection().setPosition(text, 1); | 18 root.appendChild(testElement); |
| 19 |
| 20 var childText = testElement.firstChild.childNodes[1].firstChild; |
| 21 document.getSelection().setPosition(childText, 1); |
11 document.execCommand("InsertText", false, 'z'); | 22 document.execCommand("InsertText", false, 'z'); |
12 document.execCommand("InsertText", false, 'z'); | 23 document.execCommand("InsertText", false, 'z'); |
13 document.execCommand("InsertText", false, ' '); | 24 document.execCommand("InsertText", false, ' '); |
14 var marked = internals.hasSpellingMarker(document, 1, 2); | 25 |
15 root.innerHTML = ""; | 26 if (window.internals) { |
16 return marked; | 27 debug(escapeHTML(testElement.innerHTML)); |
| 28 |
| 29 shouldBecomeEqual("internals.hasSpellingMarker(document, 1, 2)", element
.shouldBeMisspelled ? "true" : "false", function() { |
| 30 debug(""); |
| 31 done(); |
| 32 }); |
| 33 } else |
| 34 done(); |
17 } | 35 } |
18 | 36 |
19 shouldBeFalse("childHasSpellingMarker(\"<div contentEditable>Foo <span spellchec
k='false' id='child'>[]</span> Baz</div>\")"); | 37 var testCases = [ |
20 shouldBeTrue("childHasSpellingMarker(\"<div contentEditable>Foo <span id='child'
>[]</span> Baz</div>\")"); | 38 { markup: "<div contentEditable>Foo <span spellcheck='false' id='child'>[]</
span> Baz</div>", shouldBeMisspelled: false }, |
21 shouldBeTrue("childHasSpellingMarker(\"<div contentEditable>Foo <span spellcheck
='true' id='child'>[]</span> Baz</div>\")"); | 39 { markup: "<div contentEditable>Foo <span id='child'>[]</span> Baz</div>", s
houldBeMisspelled: true }, |
22 shouldBeFalse("childHasSpellingMarker(\"<div spellcheck='false' contentEditable>
Foo <span spellcheck='false' id='child'>[]</span> Baz</div>\")"); | 40 { markup: "<div contentEditable>Foo <span spellcheck='true' id='child'>[]</s
pan> Baz</div>", shouldBeMisspelled: true }, |
23 shouldBeFalse("childHasSpellingMarker(\"<div spellcheck='false' contentEditable>
Foo <span id='child'>[]</span> Baz</div>\")"); | 41 { markup: "<div spellcheck='false' contentEditable>Foo <span spellcheck='fal
se' id='child'>[]</span> Baz</div>", shouldBeMisspelled: false }, |
24 shouldBeTrue("childHasSpellingMarker(\"<div spellcheck='false' contentEditable>F
oo <span spellcheck='true' id='child'>[]</span> Baz</div>\")"); | 42 { markup: "<div spellcheck='false' contentEditable>Foo <span id='child'>[]</
span> Baz</div>", shouldBeMisspelled: false }, |
25 shouldBeFalse("childHasSpellingMarker(\"<div spellcheck='true' contentEditable>F
oo <span spellcheck='false' id='child'>[]</span> Baz</div>\")"); | 43 { markup: "<div spellcheck='false' contentEditable>Foo <span spellcheck='tru
e' id='child'>[]</span> Baz</div>", shouldBeMisspelled: true }, |
26 shouldBeTrue("childHasSpellingMarker(\"<div spellcheck='true' contentEditable>Fo
o <span id='child'>[]</span> Baz</div>\")"); | 44 { markup: "<div spellcheck='true' contentEditable>Foo <span spellcheck='fals
e' id='child'>[]</span> Baz</div>", shouldBeMisspelled: false }, |
27 shouldBeTrue("childHasSpellingMarker(\"<div spellcheck='true' contentEditable>Fo
o <span spellcheck='true' id='child'>[]</span> Baz</div>\")"); | 45 { markup: "<div spellcheck='true' contentEditable>Foo <span id='child'>[]</s
pan> Baz</div>", shouldBeMisspelled: true }, |
| 46 { markup: "<div spellcheck='true' contentEditable>Foo <span spellcheck='true
' id='child'>[]</span> Baz</div>", shouldBeMisspelled: true } |
| 47 ]; |
| 48 |
| 49 function done() |
| 50 { |
| 51 var nextTestCase = testCases.shift(); |
| 52 if (nextTestCase) |
| 53 return setTimeout(verifyChildSpellingMarker(nextTestCase), 0); |
| 54 |
| 55 finishJSTest(); |
| 56 } |
| 57 done(); |
28 | 58 |
29 var successfullyParsed = true; | 59 var successfullyParsed = true; |
OLD | NEW |