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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../editing.js"></script> 4 <script src="../editing.js"></script>
5 <script src="resources/util.js"></script> 5 <script src="resources/util.js"></script>
6 <script src="../../resources/js-test.js"></script> 6 <script src="../../resources/js-test.js"></script>
7 </head> 7 </head>
8 <body onload="test();"> 8 <body onload="test();">
9 <pre id="console"></pre>
10 <div id="container"> 9 <div id="container">
11 <div id="test_editable" contentEditable>zz zz zz. </div> 10 <div id="test_editable" contentEditable>zz zz zz.</div>
12 <textarea id="test_textarea">zz zz zz.</textarea> 11 <textarea id="test_textarea">zz zz zz.</textarea>
13 <input type="text" id="test_textfield" value="zz zz zz."></input> 12 <input type="text" id="test_textfield" value="zz zz zz."></input>
14 </div> 13 </div>
15 <script> 14 <script>
16 description("Spell checking should be triggered on focus of an editable. " + 15 description("Spell checking should be triggered on focus of an editable. "
17 "To test manually type focus above editable and textarea. Misspellings in them " + 16 + "To test manually, set focus on above elements. The test succeed if "
18 "should be marked on focus."); 17 + "misspellings are marked.");
19 18
20 jsTestIsAsync = true; 19 jsTestIsAsync = true;
21 20
22 var testEditable = document.getElementById('test_editable'); 21 var testEditable = document.getElementById('test_editable');
23 var testTextArea = document.getElementById('test_textarea'); 22 var testTextArea = document.getElementById('test_textarea');
24 var testTextField = document.getElementById('test_textfield'); 23 var testTextField = document.getElementById('test_textfield');
25 24
26 function test() 25 function setFocusOnEditableElements() {
27 { 26 testEditable.focus();
28 if (!window.internals) 27 testTextArea.focus();
29 { 28 testTextField.focus();
30 log("Automatic testing impossible. Test manually."); 29 }
30
31 var expectedNumberOfMarkers;
32 var textNode;
33
34 function verifySpellingMarkers(expectation, doneCallback) {
35 expectedNumberOfMarkers = expectation;
36 textNode = findFirstTextNode(testEditable);
37 shouldBecomeEqual('internals.markerCountForNode(textNode, "spelling")', 'exp ectedNumberOfMarkers', function() {
38 shouldBecomeEqual('internals.markerCountForNode(textNode, "spelling")', 'expectedNumberOfMarkers', function() {
39 shouldBecomeEqual('internals.markerCountForNode(textNode, "spelling" )', 'expectedNumberOfMarkers', function() {
40 doneCallback();
41 // After focusing the editable elements, check whether they have spelling markers.
42 verifySpellingMarkers(3, finishJSTest);
43 });
44 });
45 });
46 }
47
48 function test() {
49 if (!window.internals) {
50 debug("Automatic testing impossible. Test manually.");
31 return; 51 return;
32 } 52 }
33 53
34 internals.settings.setUnifiedTextCheckerEnabled(true); 54 internals.settings.setUnifiedTextCheckerEnabled(true);
35 internals.settings.setAsynchronousSpellCheckingEnabled(true); 55 internals.settings.setAsynchronousSpellCheckingEnabled(true);
36 internals.setContinuousSpellCheckingEnabled(true);
37 56
38 function waitForMarkersToAppear(nretry) 57 // Check whether non-focused elements do not have spelling markers, then
39 { 58 // verify them when they get focused.
40 if (nretry > 0 59 verifySpellingMarkers(0, setFocusOnEditableElements);
41 && (!internals.markerCountForNode(findFirstTextNode(testEditable), " spelling")
42 || !internals.markerCountForNode(findFirstTextNode(testTextArea), "s pelling")
43 || !internals.markerCountForNode(findFirstTextNode(testTextField), " spelling"))) {
44 window.setTimeout(function() { waitForMarkersToAppear(nretry - 1); } , 5);
45 } else {
46 shouldBe('internals.markerCountForNode(findFirstTextNode(testTextAre a), "spelling")', '3');
47 shouldBe('internals.markerCountForNode(findFirstTextNode(testEditabl e), "spelling")', '3');
48 shouldBe('internals.markerCountForNode(findFirstTextNode(testTextFie ld), "spelling")', '3');
49 finishJSTest();
50 }
51 }
52
53 shouldBe('internals.markerCountForNode(findFirstTextNode(testEditable), "spe lling")', '0');
54 testEditable.focus();
55 shouldBe('internals.markerCountForNode(findFirstTextNode(testTextArea), "spe lling")', '0');
56 testTextArea.focus();
57 shouldBe('internals.markerCountForNode(findFirstTextNode(testTextField), "sp elling")', '0');
58 testTextField.focus();
59 waitForMarkersToAppear(10);
60 } 60 }
61 61
62 </script> 62 </script>
63 </body> 63 </body>
64 </html> 64 </html>
OLDNEW
« 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