Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(758)

Unified Diff: LayoutTests/editing/spelling/script-tests/spelling-attribute-at-child.js

Issue 190663014: Verify spellcheck attribute asynchronously (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;

Powered by Google App Engine
This is Rietveld 408576698