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

Unified Diff: LayoutTests/editing/spelling/inline_spelling_markers.html

Issue 49613006: Refactoring inline_spelling_markers.html to use async path for spellcheck (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: Created 7 years, 2 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/inline_spelling_markers.html
diff --git a/LayoutTests/editing/spelling/inline_spelling_markers.html b/LayoutTests/editing/spelling/inline_spelling_markers.html
index 3669155faa7fa8d440302c404eb0fc3a8b7ea77f..187c65b7ad6ad22f22cdc50f683278977b2dd7c5 100644
--- a/LayoutTests/editing/spelling/inline_spelling_markers.html
+++ b/LayoutTests/editing/spelling/inline_spelling_markers.html
@@ -1,5 +1,6 @@
<html>
<head>
+<script src="../../fast/js/resources/js-test-pre.js"></script>
<style>
.testDiv {
width: 200px;
@@ -20,56 +21,97 @@
</style>
+</head>
+<body>
<script>
-function moveCursorOverAllWords(divName, numWords) {
- div = document.getElementById(divName);
- div.focus();
- var selection = window.getSelection();
- // Move to start of text
- selection.modify("move", "backward", "line");
- // Move cursor over all words so inline spellchecking is activated for all
- for (var i = 0; i < 100; i++ ) {
- selection.modify("move", "forward", "word");
- }
- // Remove focus from the element, since the word under the cursor won't have a misspelling marker.
- div.blur();
-}
+description("This tests the correct placement of inline spelling and grammar "
+ + "markers in text. Spelling markers should line up exactly under misspelled "
+ + "words in all cases.");
-function startTest() {
- moveCursorOverAllWords('testLTR');
- moveCursorOverAllWords('testRTL');
- moveCursorOverAllWords('testLTREllipses');
- moveCursorOverAllWords('testRTLEllipses');
+jsTestIsAsync = true;
+if (window.internals) {
+ internals.settings.setUnifiedTextCheckerEnabled(true);
+ internals.settings.setAsynchronousSpellCheckingEnabled(true);
}
+
+if (window.testRunner)
+ testRunner.dumpAsTextWithPixelResults();
+
</script>
-</head>
-<body onload="startTest()">
-<p id="explanation">
-This tests the correct placement of inline spelling and grammar markers in text.<br>
-Spelling markers should line up exactly under misspelled words in all cases.
-</p>
LTR
-<div id="testLTR" class="testDiv" contenteditable="true">
-the the adlj adaasj sdklj. there there
-</div>
+<div id="testLTR" class="testDiv" contenteditable="true">the the adlj adaasj sdklj. there there</div>
RTL
-<div id="testRTL" class="testDiv forcertl" contenteditable="true">
-the the adlj adaasj sdklj. there there
-</div>
-
+<div id="testRTL" class="testDiv forcertl" contenteditable="true">the the adlj adaasj sdklj. there there</div>
LTR (text-overflow:ellipses):
-<div id="testLTREllipses" class="testDiv ellipses" contenteditable="true">
-the the adlj adaasj sdklj. there there
-</div>
+<div id="testLTREllipses" class="testDiv ellipses" contenteditable="true">the the adlj adaasj sdklj. there there</div>
RTL (text-overflow:ellipses):
-<div id="testRTLEllipses" class="testDiv forcertl ellipses" contenteditable="true">
-the the adlj adaasj sdklj. there there
-</div>
+<div id="testRTLEllipses" class="testDiv forcertl ellipses" contenteditable="true">the the adlj adaasj sdklj. there there</div>
+
+<script>
+
+function moveCursorOverAllCharacters(id)
+{
+ if (!window.internals)
+ return;
+
+ div = document.getElementById(id);
+ div.focus();
+
+ debug(id + ":");
+
+ var selection = window.getSelection();
+ // Move to start of text.
+ selection.modify("move", "backward", "line");
+ /* Move cursor over all characters so underline for misspellings is drawn.
+ This is only needed to show misspelling in pixel tests. */
+ for (var i = 0; i < div.innerHTML.length; i++ )
groby-ooo-7-16 2013/10/29 17:19:05 Moving over words should be enough - does the test
grzegorz 2013/10/30 15:47:47 You're right. Moving over the words is enough. I'l
+ selection.modify("move", "forward", "character");
+
+ verifyMarkers();
+}
+
+function verifyMarkers()
+{
+ // Take care of spelling markers first.
+ shouldBecomeEqual('internals.hasSpellingMarker(document, 8, 4)', 'true', function() { // Verifies 'adlj'.
+ shouldBecomeEqual('internals.hasSpellingMarker(document, 13, 6)', 'true', function() { // Verifies 'adaasj'.
+ shouldBecomeEqual('internals.hasSpellingMarker(document, 20, 5)', 'true', verifyGrammarMarkers) // Verifies 'sdklj'.
+ })
+ });
+
+ function verifyGrammarMarkers() {
+ shouldBecomeEqual('internals.hasGrammarMarker(document, 4, 3)', 'true', function() { // Verifies second 'the'.
+ shouldBecomeEqual('internals.hasGrammarMarker(document, 32, 5)', 'true', function() { // Verifies second 'there'.
+ div.blur();
groby-ooo-7-16 2013/10/29 17:19:05 Is the blur still needed?
grzegorz 2013/10/30 15:47:47 Good point, hasGrammarMarker/hasSpellingMarker fai
+ done();
+ })
+ });
+ }
+}
+
+var tests = [ function() { moveCursorOverAllCharacters('testLTR'); },
+ function() { moveCursorOverAllCharacters('testRTL'); },
+ function() { moveCursorOverAllCharacters('testLTREllipses'); },
+ function() { moveCursorOverAllCharacters('testRTLEllipses'); } ];
+
+function done()
+{
+ var next = tests.shift();
+ if (next)
+ return window.setTimeout(next, 0);
+
+ finishJSTest();
+}
+
+done();
+
+</script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
</body>
</html>

Powered by Google App Engine
This is Rietveld 408576698