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

Unified Diff: LayoutTests/editing/spelling/spellcheck-editable-on-focus.html

Issue 25507002: Layout Test editing/spelling/spellcheck-editable-on-focus.html is flaky (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: Rebase a patch and add minor improvements 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-editable-on-focus-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/editing/spelling/spellcheck-editable-on-focus.html
diff --git a/LayoutTests/editing/spelling/spellcheck-editable-on-focus.html b/LayoutTests/editing/spelling/spellcheck-editable-on-focus.html
index 1a3232a4c541bd7263f87ade7c9a718665d95d11..00177acb8d2fc931997946f787ef67c863c315f3 100644
--- a/LayoutTests/editing/spelling/spellcheck-editable-on-focus.html
+++ b/LayoutTests/editing/spelling/spellcheck-editable-on-focus.html
@@ -6,16 +6,15 @@
<script src="../../resources/js-test.js"></script>
</head>
<body onload="test();">
-<pre id="console"></pre>
<div id="container">
- <div id="test_editable" contentEditable>zz zz zz. </div>
+ <div id="test_editable" contentEditable>zz zz zz.</div>
<textarea id="test_textarea">zz zz zz.</textarea>
<input type="text" id="test_textfield" value="zz zz zz."></input>
</div>
<script>
-description("Spell checking should be triggered on focus of an editable. " +
-"To test manually type focus above editable and textarea. Misspellings in them " +
-"should be marked on focus.");
+description("Spell checking should be triggered on focus of an editable. "
+ + "To test manually, set focus on above elements. The test succeed if "
+ + "misspellings are marked.");
jsTestIsAsync = true;
@@ -23,40 +22,41 @@ var testEditable = document.getElementById('test_editable');
var testTextArea = document.getElementById('test_textarea');
var testTextField = document.getElementById('test_textfield');
-function test()
-{
- if (!window.internals)
- {
- log("Automatic testing impossible. Test manually.");
+function setFocusOnEditableElements() {
+ testEditable.focus();
+ testTextArea.focus();
+ testTextField.focus();
+}
+
+var expectedNumberOfMarkers;
+var textNode;
+
+function verifySpellingMarkers(expectation, doneCallback) {
+ expectedNumberOfMarkers = expectation;
+ textNode = findFirstTextNode(testEditable);
+ shouldBecomeEqual('internals.markerCountForNode(textNode, "spelling")', 'expectedNumberOfMarkers', function() {
+ shouldBecomeEqual('internals.markerCountForNode(textNode, "spelling")', 'expectedNumberOfMarkers', function() {
+ shouldBecomeEqual('internals.markerCountForNode(textNode, "spelling")', 'expectedNumberOfMarkers', function() {
+ doneCallback();
+ // After focusing the editable elements, check whether they have spelling markers.
+ verifySpellingMarkers(3, finishJSTest);
+ });
+ });
+ });
+}
+
+function test() {
+ if (!window.internals) {
+ debug("Automatic testing impossible. Test manually.");
return;
}
internals.settings.setUnifiedTextCheckerEnabled(true);
internals.settings.setAsynchronousSpellCheckingEnabled(true);
- internals.setContinuousSpellCheckingEnabled(true);
-
- function waitForMarkersToAppear(nretry)
- {
- if (nretry > 0
- && (!internals.markerCountForNode(findFirstTextNode(testEditable), "spelling")
- || !internals.markerCountForNode(findFirstTextNode(testTextArea), "spelling")
- || !internals.markerCountForNode(findFirstTextNode(testTextField), "spelling"))) {
- window.setTimeout(function() { waitForMarkersToAppear(nretry - 1); }, 5);
- } else {
- shouldBe('internals.markerCountForNode(findFirstTextNode(testTextArea), "spelling")', '3');
- shouldBe('internals.markerCountForNode(findFirstTextNode(testEditable), "spelling")', '3');
- shouldBe('internals.markerCountForNode(findFirstTextNode(testTextField), "spelling")', '3');
- finishJSTest();
- }
- }
- shouldBe('internals.markerCountForNode(findFirstTextNode(testEditable), "spelling")', '0');
- testEditable.focus();
- shouldBe('internals.markerCountForNode(findFirstTextNode(testTextArea), "spelling")', '0');
- testTextArea.focus();
- shouldBe('internals.markerCountForNode(findFirstTextNode(testTextField), "spelling")', '0');
- testTextField.focus();
- waitForMarkersToAppear(10);
+ // Check whether non-focused elements do not have spelling markers, then
+ // verify them when they get focused.
+ verifySpellingMarkers(0, setFocusOnEditableElements);
}
</script>
« no previous file with comments | « no previous file | LayoutTests/editing/spelling/spellcheck-editable-on-focus-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698