Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / spelling / spellcheck-editable-on-focus.html
blobba72d8366ab55e7d88f0ed729145c458fc7e64a2
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../editing.js"></script>
5 <script src="resources/util.js"></script>
6 <script src="../../resources/js-test.js"></script>
7 </head>
8 <body onload="test();">
9 <div id="container">
10 <div id="test_editable" contentEditable>zz zz zz.</div>
11 <textarea id="test_textarea">zz zz zz.</textarea>
12 <input type="text" id="test_textfield" value="zz zz zz."></input>
13 </div>
14 <script>
15 description("Spell checking should be triggered on focus of an editable. "
16 + "To test manually, set focus on above elements. The test succeed if "
17 + "misspellings are marked.");
19 jsTestIsAsync = true;
21 var testEditable = document.getElementById('test_editable');
22 var testTextArea = document.getElementById('test_textarea');
23 var testTextField = document.getElementById('test_textfield');
25 function triggerSpellingForEditables() {
26 testEditable.focus();
27 testTextArea.focus();
28 testTextField.focus();
31 var expectedNumberOfMarkers;
32 var textNode;
33 function verifySpellingMarkers(expectation, doneCallback) {
34 expectedNumberOfMarkers = expectation;
35 shouldBecomeEqual('internals.markerCountForNode(findFirstTextNode(testEditable), "spelling")', 'expectedNumberOfMarkers', function() {
36 shouldBecomeEqual('internals.markerCountForNode(findFirstTextNode(testTextArea), "spelling")', 'expectedNumberOfMarkers', function() {
37 shouldBecomeEqual('internals.markerCountForNode(findFirstTextNode(testTextField), "spelling")', 'expectedNumberOfMarkers', function() {
38 doneCallback();
39 // After focusing the editable elements, check whether they have spelling markers.
40 verifySpellingMarkers(3, finishJSTest);
41 });
42 });
43 });
46 function test() {
47 if (!window.internals) {
48 debug("Automatic testing impossible. Test manually.");
49 return;
52 internals.settings.setUnifiedTextCheckerEnabled(true);
53 internals.settings.setAsynchronousSpellCheckingEnabled(true);
55 // Check whether non-focused elements do not have spelling markers, then
56 // verify them when they get focused.
57 verifySpellingMarkers(0, triggerSpellingForEditables);
60 </script>
61 </body>
62 </html>