Use asynchronous spellchecking in spelling-hasspellingmarker.js

Refactoring spelling-hasspellingmarker.js to use asynchronous spellchecking.
In addition, adds some bits for non-DumpRenderTree users.

It's based on WebKit changeset: http://trac.webkit.org/changeset/164100

BUG=295722

Review URL: https://codereview.chromium.org/204383002

git-svn-id: svn://svn.chromium.org/blink/trunk@169636 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 05918b38
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"); jsTestIsAsync = true;
document.body.appendChild(parent);
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; var contatiner = document.createElement("div");
document.getElementById('test').focus(); contatiner.innerHTML = markup;
document.execCommand("InsertText", false, 'z'); testRoot.appendChild(contatiner);
document.execCommand("InsertText", false, 'z');
document.execCommand("InsertText", false, ' '); 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>\");"); function verifySpellingMarkers(element)
shouldBeTrue("hasMarked(\"<input id='test' type='text'>\");"); {
shouldBeTrue("hasMarked(\"<div id='test' contenteditable='true'></div>\");"); var div = addContainer(element.containerMarkup);
shouldBeFalse("hasMarked(\"<div id='test' contentEditable='true' spellcheck='false'></div>\");"); typeMisspelling(div);
parent.innerHTML = "";
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; var successfullyParsed = true;
This tests internals.hasSpellingMarker works for differnt type of elements. 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.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS hasMarked("<textarea id='test' cols='80' rows='10'></textarea>"); is true PASS internals.hasSpellingMarker(document, 0, 2) became true
PASS hasMarked("<input id='test' type='text'>"); is true PASS internals.hasSpellingMarker(document, 0, 2) became true
PASS hasMarked("<div id='test' contenteditable='true'></div>"); is true PASS internals.hasSpellingMarker(document, 0, 2) became true
PASS hasMarked("<div id='test' contentEditable='true' spellcheck='false'></div>"); is false PASS internals.hasSpellingMarker(document, 0, 2) became false
PASS successfullyParsed is true PASS successfullyParsed is true
TEST COMPLETE TEST COMPLETE
......
...@@ -2,10 +2,9 @@ ...@@ -2,10 +2,9 @@
<html> <html>
<head> <head>
<script src="../../resources/js-test.js"></script> <script src="../../resources/js-test.js"></script>
<script src="../editing.js"></script>
</head> </head>
<body> <body>
<p id="description"></p>
<div id="console"></div>
<script src="script-tests/spelling-hasspellingmarker.js"></script> <script src="script-tests/spelling-hasspellingmarker.js"></script>
</body> </body>
</html> </html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment