Index: LayoutTests/editing/spelling/script-tests/spelling-hasspellingmarker.js |
diff --git a/LayoutTests/editing/spelling/script-tests/spelling-hasspellingmarker.js b/LayoutTests/editing/spelling/script-tests/spelling-hasspellingmarker.js |
index c107ff8bede9c367079337c3c28cf2be3d7ea661..f483dc1fc1b4b223b5f6ba1ac745f6aed401e7c2 100644 |
--- a/LayoutTests/editing/spelling/script-tests/spelling-hasspellingmarker.js |
+++ b/LayoutTests/editing/spelling/script-tests/spelling-hasspellingmarker.js |
@@ -1,23 +1,63 @@ |
-description('This tests internals.hasSpellingMarker works for differnt type of elements.'); |
+description('This tests if internals.hasSpellingMarker works for differnt type of elements. ' |
+ + 'This test succeds when there are four elements having "zz ". ' |
+ + 'However, only the last one should not contatin spelling marker.'); |
-var parent = document.createElement("div"); |
-document.body.appendChild(parent); |
+jsTestIsAsync = true; |
-function hasMarked(markup) |
+if (window.internals) { |
+ internals.settings.setUnifiedTextCheckerEnabled(true); |
+ internals.settings.setAsynchronousSpellCheckingEnabled(true); |
+} |
+ |
+var testRoot = document.createElement("div"); |
+document.body.insertBefore(testRoot, document.body.firstChild); |
+ |
+function addContainer(markup) |
{ |
- parent.innerHTML = markup; |
- document.getElementById('test').focus(); |
- document.execCommand("InsertText", false, 'z'); |
- document.execCommand("InsertText", false, 'z'); |
- document.execCommand("InsertText", false, ' '); |
+ var contatiner = document.createElement("div"); |
+ contatiner.innerHTML = markup; |
+ testRoot.appendChild(contatiner); |
+ |
+ return contatiner; |
+} |
- return internals.hasSpellingMarker(document, 0, 2); |
+function typeMisspelling(contatiner) |
+{ |
+ contatiner.firstChild.focus(); |
+ typeCharacterCommand('z'); |
+ typeCharacterCommand('z'); |
+ typeCharacterCommand(' '); |
} |
-shouldBeTrue("hasMarked(\"<textarea id='test' cols='80' rows='10'></textarea>\");"); |
-shouldBeTrue("hasMarked(\"<input id='test' type='text'>\");"); |
-shouldBeTrue("hasMarked(\"<div id='test' contenteditable='true'></div>\");"); |
-shouldBeFalse("hasMarked(\"<div id='test' contentEditable='true' spellcheck='false'></div>\");"); |
-parent.innerHTML = ""; |
+function verifySpellingMarkers(element) |
+{ |
+ var div = addContainer(element.containerMarkup); |
+ typeMisspelling(div); |
+ |
+ if (window.internals) |
+ shouldBecomeEqual("internals.hasSpellingMarker(document, 0, 2)", element.isMisspelled ? "true" : "false", done); |
+ else |
+ done(); |
+} |
+ |
+var testCases = [ |
+ { containerMarkup: "<textarea></textarea>", isMisspelled: true }, |
+ { containerMarkup: "<input type='text'></input>", isMisspelled: true }, |
+ { containerMarkup: "<div contenteditable='true'></div>", isMisspelled: true }, |
+ { containerMarkup: "<div contentEditable='true' spellcheck='false'></div>", isMisspelled: false } |
+]; |
+ |
+function done() |
+{ |
+ var nextTestCase = testCases.shift(); |
+ if (nextTestCase) |
+ return setTimeout(verifySpellingMarkers(nextTestCase), 0); |
+ |
+ if (window.internals) |
+ testRoot.style.display = "none"; |
+ |
+ finishJSTest(); |
+} |
+done(); |
var successfullyParsed = true; |