4 <script src=
"../editing.js"></script>
5 <script src=
"resources/util.js"></script>
6 <script src=
"../../resources/js-test.js"></script>
8 <body onload=
"test();">
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>
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.");
21 var testEditable
= document
.getElementById('test_editable');
22 var testTextArea
= document
.getElementById('test_textarea');
23 var testTextField
= document
.getElementById('test_textfield');
25 function triggerSpellingForEditables() {
28 testTextField
.focus();
31 var expectedNumberOfMarkers
;
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() {
39 // After focusing the editable elements, check whether they have spelling markers.
40 verifySpellingMarkers(3, finishJSTest
);
47 if (!window
.internals
) {
48 debug("Automatic testing impossible. Test manually.");
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
);