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

Unified Diff: LayoutTests/editing/spelling/spellcheck-attribute.html

Issue 58953005: Refactoring spellcheck-attribute.html to use async path for spellcheck (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: Created 7 years, 1 month 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/spellcheck-attribute-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/editing/spelling/spellcheck-attribute.html
diff --git a/LayoutTests/editing/spelling/spellcheck-attribute.html b/LayoutTests/editing/spelling/spellcheck-attribute.html
index 6bbaa4c34465ba1e6a5402acc9631d631390ca2e..2218af0c0236bb079e204e99d1fce6c0e250df04 100644
--- a/LayoutTests/editing/spelling/spellcheck-attribute.html
+++ b/LayoutTests/editing/spelling/spellcheck-attribute.html
@@ -2,10 +2,11 @@
<head>
<title>Spellcheck Attribute Test</title>
<link rel="help" href="http://damowmow.com/playground/spellcheck.txt">
+<script src="../editing.js"></script>
+<script src="resources/util.js"></script>
<script src="../../resources/js-test.js"></script>
</head>
<body>
-<p>This tests if the "spellcheck" attribute is implemented as written in its specification. If this test succeeds, you can see forms filled with an invalid word 'zz '. Nevertheless, the 'zz ' is not marked as misspelled in all of them.
<div id="testRoot">
<div spellcheck="true">
@@ -43,60 +44,83 @@
</div>
</div>
-<pre id="console"></pre>
<script>
-function log(msg) {
- document.getElementById("console").innerHTML += (msg + "\n");
+description('This tests if the "spellcheck" attribute is implemented '
+ + 'as written in its specification. If this test succeeds, you can see '
+ + 'forms filled with an invalid word "zz". Nevertheless, the "zz" is not '
+ + 'marked as misspelled in all of them.');
+
+jsTestIsAsync = true;
+
+if (window.internals) {
+ internals.settings.setUnifiedTextCheckerEnabled(true);
+ internals.settings.setAsynchronousSpellCheckingEnabled(true);
}
-function testMarkerForMisspelledWord(id, shouldBeMarked) {
+// Type misspelling to all input elements.
+var inputs = document.getElementsByTagName('input');
+for (var i = 0; i < inputs.length; i++)
+ typeText(inputs[i], 'zz ');
+
+var shouldBeMarked;
+
+function testMarkerForMisspelledWord(id, isMisspelled) {
+ if (!window.internals)
+ return done();
+
var inputElement = document.getElementById(id);
+ // Spelling markers for input will appear if it's focused.
inputElement.focus();
- document.execCommand("InsertText", false, 'z');
- document.execCommand("InsertText", false, 'z');
- document.execCommand("InsertText", false, ' ');
- log("id=" + id + " type=" + inputElement.type + " spellcheck=" + inputElement.spellcheck
+ debug("id=" + id + " type=" + inputElement.type + " spellcheck=" + inputElement.spellcheck
+ " parent's spellcheck=" + inputElement.parentNode.spellcheck);
- shouldBe("internals.hasSpellingMarker(document, 0, 2)", shouldBeMarked ? "true" : "false")
+ shouldBeMarked = isMisspelled;
+ shouldBecomeEqual('internals.hasSpellingMarker(document, 0, 2)', 'shouldBeMarked', done);
}
-// For type="text".
-testMarkerForMisspelledWord('test1_1', true);
-testMarkerForMisspelledWord('test1_2', true);
-testMarkerForMisspelledWord('test1_3', false);
-testMarkerForMisspelledWord('test1_4', true);
-testMarkerForMisspelledWord('test1_5', true);
-testMarkerForMisspelledWord('test1_6', true);
-log("");
-testMarkerForMisspelledWord('test2_1', false);
-testMarkerForMisspelledWord('test2_2', true);
-testMarkerForMisspelledWord('test2_3', false);
-testMarkerForMisspelledWord('test2_4', false);
-testMarkerForMisspelledWord('test2_5', true);
-testMarkerForMisspelledWord('test2_6', false);
-log("");
+var tests = [
+ // For type="text".
+ function() { testMarkerForMisspelledWord('test1_1', true); },
+ function() { testMarkerForMisspelledWord('test1_2', true); },
+ function() { testMarkerForMisspelledWord('test1_3', false); },
+ function() { testMarkerForMisspelledWord('test1_4', true); },
+ function() { testMarkerForMisspelledWord('test1_5', true); },
+ function() { testMarkerForMisspelledWord('test1_6', true); },
+ function() { testMarkerForMisspelledWord('test2_1', false); },
+ function() { testMarkerForMisspelledWord('test2_2', true); },
+ function() { testMarkerForMisspelledWord('test2_3', false); },
+ function() { testMarkerForMisspelledWord('test2_4', false); },
+ function() { testMarkerForMisspelledWord('test2_5', true); },
+ function() { testMarkerForMisspelledWord('test2_6', false); },
+ // For type="search".
+ function() { testMarkerForMisspelledWord('test3_1', true); },
+ function() { testMarkerForMisspelledWord('test3_2', true); },
+ function() { testMarkerForMisspelledWord('test3_3', false); },
+ function() { testMarkerForMisspelledWord('test3_4', true); },
+ function() { testMarkerForMisspelledWord('test3_5', true); },
+ function() { testMarkerForMisspelledWord('test3_6', true); },
+ function() { testMarkerForMisspelledWord('test4_1', false); },
+ function() { testMarkerForMisspelledWord('test4_2', true); },
+ function() { testMarkerForMisspelledWord('test4_3', false); },
+ function() { testMarkerForMisspelledWord('test4_4', false); },
+ function() { testMarkerForMisspelledWord('test4_5', true); },
+ function() { testMarkerForMisspelledWord('test4_6', false); }
+];
-// For type="search".
-testMarkerForMisspelledWord('test3_1', true);
-testMarkerForMisspelledWord('test3_2', true);
-testMarkerForMisspelledWord('test3_3', false);
-testMarkerForMisspelledWord('test3_4', true);
-testMarkerForMisspelledWord('test3_5', true);
-testMarkerForMisspelledWord('test3_6', true);
-log("");
-testMarkerForMisspelledWord('test4_1', false);
-testMarkerForMisspelledWord('test4_2', true);
-testMarkerForMisspelledWord('test4_3', false);
-testMarkerForMisspelledWord('test4_4', false);
-testMarkerForMisspelledWord('test4_5', true);
-testMarkerForMisspelledWord('test4_6', false);
+function done()
+{
+ var next = tests.shift();
+ if (next)
+ return window.setTimeout(next, 0);
-if (window.testRunner) {
- // Cleaning up for expeation text if running on DRT.
- document.getElementById("testRoot").style.display = "none";
+ if (window.testRunner) {
+ // Cleaning up for expectation text if running on DRT.
+ document.getElementById("testRoot").style.display = "none";
+ }
+ finishJSTest();
}
+done();
</script>
</body>
</html>
« no previous file with comments | « no previous file | LayoutTests/editing/spelling/spellcheck-attribute-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698