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

Unified Diff: LayoutTests/editing/spelling/script-tests/spelling-hasspellingmarker.js

Issue 204383002: Use asynchronous spellchecking in spelling-hasspellingmarker.js (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
« no previous file with comments | « no previous file | LayoutTests/editing/spelling/spelling-hasspellingmarker.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « no previous file | LayoutTests/editing/spelling/spelling-hasspellingmarker.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698