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

Unified Diff: LayoutTests/editing/spelling/spellcheck-disable-enable.html

Issue 70073005: Refactoring spellcheck-disable-enable.html to use async path for spellcheck (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: type misspellings via execCommand as it spellcheks better than just focus 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-disable-enable-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/editing/spelling/spellcheck-disable-enable.html
diff --git a/LayoutTests/editing/spelling/spellcheck-disable-enable.html b/LayoutTests/editing/spelling/spellcheck-disable-enable.html
index d2f94b7451ff276ef9897cc824e2122826e96154..ebf4243eb48c87265dbc253af6d6a7f975c423b8 100644
--- a/LayoutTests/editing/spelling/spellcheck-disable-enable.html
+++ b/LayoutTests/editing/spelling/spellcheck-disable-enable.html
@@ -4,51 +4,62 @@
<script src="../../resources/js-test.js"></script>
</head>
<body onload="test(document.getElementById('destination'), document.getElementById('frame').contentWindow.document);">
-<pre id="console"></pre>
<div id="container">
<div id="destination" contentEditable></div>
<iframe id="frame" src="data:text/html,<body contenteditable></body>"></iframe>
</div>
<script>
-description("Spell check markers should be removed from the whole page when disabling spell checker but " +
-"they should be restored in the focused editable if spell checker gets enabled. " +
-"To test manually type something with mispellings in the above editable element and iframe and turn " +
-"spell checker off - misspelling markers should disappear. Having the editable focused " +
-"turn spell checker on again. Misspellings in the editable should be marked again.");
+description("Spell check markers should be removed from the whole page when disabling spell checker "
+ + "but they should be restored in the focused editable if spell checker gets enabled. "
+ + "To test manually, turn spell checker off - misspelling markers should disappear. "
+ + "Having the editable focused, turn spell checker on. Misspellings in the editable should be marked.");
jsTestIsAsync = true;
-var destination_elm = null;
-var destination_elm_in_frame = null;
+function hasSpellingMarkerOnSetting(element, enableSpellChecking)
+{
+ internals.setContinuousSpellCheckingEnabled(enableSpellChecking);
+ return !!internals.markerCountForNode(element.firstChild, "spelling");
+}
-function test(destination, frame_doc)
+var editableDiv = null;
+var editableBodyInFrame = null;
+
+function test(div, frameDocument)
{
- if (!window.internals)
- {
- document.getElementById("console").innerHTML = "Automatic testing impossible. Test manually.\n";
+ editableDiv = div;
+ editableBodyInFrame = frameDocument.body;
+
+ // Type misspellings to trigger spellchecking on editable fields.
+ editableDiv.focus();
+ document.execCommand("InsertText", false, "zz.");
+ editableBodyInFrame.focus();
+ frameDocument.execCommand("InsertText", false, "zz.");
+
+ if (!window.internals) {
+ debug("Automatic testing impossible. Test manually.");
return;
}
- internals.settings.setAsynchronousSpellCheckingEnabled(false);
+ internals.settings.setAsynchronousSpellCheckingEnabled(true);
internals.settings.setUnifiedTextCheckerEnabled(true);
- destination_elm = destination;
- destination_elm_in_frame = frame_doc.body;
- destination_elm.focus();
- document.execCommand("InsertText", false, "zz.");
- shouldBe('internals.markerCountForNode(destination_elm.childNodes[0], "spelling")', '1');
- destination_elm_in_frame.focus();
- frame_doc.execCommand("InsertText", false, "zz.");
- shouldBe('internals.markerCountForNode(destination_elm_in_frame.childNodes[0], "spelling")', '1');
- internals.setContinuousSpellCheckingEnabled(false);
- shouldBe('internals.markerCountForNode(destination_elm.childNodes[0], "spelling")', '0');
- shouldBe('internals.markerCountForNode(destination_elm_in_frame.childNodes[0], "spelling")', '0');
- destination_elm.focus();
- internals.setContinuousSpellCheckingEnabled(true);
- shouldBe('internals.markerCountForNode(destination_elm.childNodes[0], "spelling")', '1');
-
- finishJSTest();
+ shouldBecomeEqual('hasSpellingMarkerOnSetting(editableDiv, true)', 'true', function() {
+ shouldBecomeEqual('hasSpellingMarkerOnSetting(editableBodyInFrame, true)', 'true', function() {
+ // Turn off spellchecking, all misspellings should disappear.
+ shouldBecomeEqual('hasSpellingMarkerOnSetting(editableDiv, false)', 'false', function() {
+ shouldBecomeEqual('hasSpellingMarkerOnSetting(editableBodyInFrame, false)', 'false', function() {
+ // Focus element and turn on spellchecking.
+ // Only misspellings of the focused element should be restored.
+ editableDiv.focus();
+ shouldBecomeEqual('hasSpellingMarkerOnSetting(editableDiv, true)', 'true', function() {
+ shouldBecomeEqual('hasSpellingMarkerOnSetting(editableBodyInFrame, true)', 'false', finishJSTest);
+ });
+ });
+ });
+ });
+ });
}
</script>
« no previous file with comments | « no previous file | LayoutTests/editing/spelling/spellcheck-disable-enable-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698