Index: LayoutTests/editing/spelling/inline-spelling-markers-hidpi-composited.html |
diff --git a/LayoutTests/editing/spelling/inline-spelling-markers-hidpi-composited.html b/LayoutTests/editing/spelling/inline-spelling-markers-hidpi-composited.html |
index 2d782f297105a847282e229a7e78db20815b03ed..f36e582ddc0e917cb36d78c47ac9e2c2ad64f7fa 100644 |
--- a/LayoutTests/editing/spelling/inline-spelling-markers-hidpi-composited.html |
+++ b/LayoutTests/editing/spelling/inline-spelling-markers-hidpi-composited.html |
@@ -1,5 +1,7 @@ |
<html> |
<head> |
+<script src="../../resources/js-test.js"></script> |
+<script src="../../editing/editing.js"></script> |
<style> |
.testDiv { |
width: 200px; |
@@ -20,63 +22,92 @@ |
} |
</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."); |
+ |
+jsTestIsAsync = true; |
+ |
+if (window.internals) { |
+ internals.settings.setUnifiedTextCheckerEnabled(true); |
+ internals.settings.setAsynchronousSpellCheckingEnabled(true); |
} |
-function startTest() { |
- if (!window.testRunner) |
- return; |
+if (window.testRunner) { |
testRunner.dumpAsTextWithPixelResults(); |
- testRunner.waitUntilDone(); |
testRunner.setBackingScaleFactor(2, function () { |
- moveCursorOverAllWords('testLTR'); |
- moveCursorOverAllWords('testRTL'); |
- moveCursorOverAllWords('testLTREllipses'); |
- moveCursorOverAllWords('testRTLEllipses'); |
- testRunner.notifyDone(); |
+ done(); |
}); |
} |
+ |
</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> |
+ |
+RTL (text-overflow:ellipses) |
+<div id="testRTLEllipses" class="testDiv forcertl ellipses" contenteditable="true">the the adlj adaasj sdklj. there there</div> |
+ |
+<script> |
+function moveCursorOverAllWords(id) |
+{ |
+ div = document.getElementById(id); |
+ div.focus(); |
+ |
+ debug(id + ":"); |
+ // Move cursor over all words so inline spellchecking is activated for all. |
+ for (var i = 0; i < div.innerHTML.length; i++) |
+ moveSelectionForwardByWordCommand(); |
+ verifyMarkers(); |
+} |
-LTR (text-overflow:ellipses): |
-<div id="testLTREllipses" class="testDiv ellipses" contenteditable="true"> |
-the the adlj adaasj sdklj. there there |
-</div> |
+function verifyMarkers() |
+{ |
+ if (!window.internals) |
+ return done(); |
-RTL (text-overflow:ellipses): |
-<div id="testRTLEllipses" class="testDiv forcertl ellipses" contenteditable="true"> |
-the the adlj adaasj sdklj. there there |
-</div> |
+ // 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, 33, 5)', 'true', function() { // Verifies second 'there'. |
+ // Markers of next element can not be found after modification selection without blur event. |
+ div.blur(); |
+ done(); |
+ }) |
+ }); |
+ } |
+} |
+ |
+var tests = [ function() { moveCursorOverAllWords('testLTR'); }, |
+ function() { moveCursorOverAllWords('testRTL'); }, |
+ function() { moveCursorOverAllWords('testLTREllipses'); }, |
+ function() { moveCursorOverAllWords('testRTLEllipses'); } ]; |
+ |
+function done() |
+{ |
+ var next = tests.shift(); |
+ if (next) |
+ return window.setTimeout(next, 0); |
+ |
+ finishJSTest(); |
+} |
+</script> |
</body> |
</html> |