Index: LayoutTests/editing/spelling/script-tests/spelling-attribute-at-child.js |
diff --git a/LayoutTests/editing/spelling/script-tests/spelling-attribute-at-child.js b/LayoutTests/editing/spelling/script-tests/spelling-attribute-at-child.js |
index 1810c2897f53e956c422caf56936cb3f6f4ba499..23b9d473ddf00585f27e5388f58bfc1271c2be00 100644 |
--- a/LayoutTests/editing/spelling/script-tests/spelling-attribute-at-child.js |
+++ b/LayoutTests/editing/spelling/script-tests/spelling-attribute-at-child.js |
@@ -1,29 +1,58 @@ |
description('Tests if the spellchecker behavior change after the spellcheck attribute changed by the script.'); |
+jsTestIsAsync = true; |
+ |
+if (window.internals) { |
+ internals.settings.setUnifiedTextCheckerEnabled(true); |
+ internals.settings.setAsynchronousSpellCheckingEnabled(true); |
+} |
+ |
var root = document.createElement("div"); |
document.body.appendChild(root); |
-function childHasSpellingMarker(markup) |
+function verifyChildSpellingMarker(markup, expectation) |
{ |
- root.innerHTML = markup; |
- var text = document.getElementById("child").firstChild; |
- document.getSelection().setPosition(text, 1); |
+ var testElement = document.createElement("div"); |
+ testElement.innerHTML = markup; |
+ root.appendChild(testElement); |
+ |
+ var childText = testElement.firstChild.childNodes[1].firstChild; |
+ 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
|
document.execCommand("InsertText", false, 'z'); |
document.execCommand("InsertText", false, 'z'); |
document.execCommand("InsertText", false, ' '); |
- var marked = internals.hasSpellingMarker(document, 1, 2); |
- root.innerHTML = ""; |
- return marked; |
+ |
+ if (window.testRunner) { |
+ debug(escapeHTML(testElement.innerHTML)); |
+ |
+ shouldBecomeEqual('internals.hasSpellingMarker(document, 1, 2)', expectation ? "true" : "false", function() { |
+ debug(""); |
+ done(); |
+ }); |
+ } else |
+ done(); |
} |
-shouldBeFalse("childHasSpellingMarker(\"<div contentEditable>Foo <span spellcheck='false' id='child'>[]</span> Baz</div>\")"); |
-shouldBeTrue("childHasSpellingMarker(\"<div contentEditable>Foo <span id='child'>[]</span> Baz</div>\")"); |
-shouldBeTrue("childHasSpellingMarker(\"<div contentEditable>Foo <span spellcheck='true' id='child'>[]</span> Baz</div>\")"); |
-shouldBeFalse("childHasSpellingMarker(\"<div spellcheck='false' contentEditable>Foo <span spellcheck='false' id='child'>[]</span> Baz</div>\")"); |
-shouldBeFalse("childHasSpellingMarker(\"<div spellcheck='false' contentEditable>Foo <span id='child'>[]</span> Baz</div>\")"); |
-shouldBeTrue("childHasSpellingMarker(\"<div spellcheck='false' contentEditable>Foo <span spellcheck='true' id='child'>[]</span> Baz</div>\")"); |
-shouldBeFalse("childHasSpellingMarker(\"<div spellcheck='true' contentEditable>Foo <span spellcheck='false' id='child'>[]</span> Baz</div>\")"); |
-shouldBeTrue("childHasSpellingMarker(\"<div spellcheck='true' contentEditable>Foo <span id='child'>[]</span> Baz</div>\")"); |
-shouldBeTrue("childHasSpellingMarker(\"<div spellcheck='true' contentEditable>Foo <span spellcheck='true' id='child'>[]</span> Baz</div>\")"); |
+var tests = [ |
+ function() { verifyChildSpellingMarker("<div contentEditable>Foo <span spellcheck='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
|
+ function() { verifyChildSpellingMarker("<div contentEditable>Foo <span id='child'>[]</span> Baz</div>", true); }, |
+ function() { verifyChildSpellingMarker("<div contentEditable>Foo <span spellcheck='true' id='child'>[]</span> Baz</div>", true); }, |
+ function() { verifyChildSpellingMarker("<div spellcheck='false' contentEditable>Foo <span spellcheck='false' id='child'>[]</span> Baz</div>", false); }, |
+ function() { verifyChildSpellingMarker("<div spellcheck='false' contentEditable>Foo <span id='child'>[]</span> Baz</div>", false); }, |
+ function() { verifyChildSpellingMarker("<div spellcheck='false' contentEditable>Foo <span spellcheck='true' id='child'>[]</span> Baz</div>", true); }, |
+ function() { verifyChildSpellingMarker("<div spellcheck='true' contentEditable>Foo <span spellcheck='false' id='child'>[]</span> Baz</div>", false); }, |
+ function() { verifyChildSpellingMarker("<div spellcheck='true' contentEditable>Foo <span id='child'>[]</span> Baz</div>", true); }, |
+ function() { verifyChildSpellingMarker("<div spellcheck='true' contentEditable>Foo <span spellcheck='true' id='child'>[]</span> Baz</div>", true); } |
+]; |
+ |
+function done() |
+{ |
+ var next = tests.shift(); |
+ if (next) |
+ return setTimeout(next, 0); |
+ |
+ finishJSTest(); |
+} |
+done(); |
var successfullyParsed = true; |