OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../../resources/js-test.js"></script> | 4 <script src="../../resources/js-test.js"></script> |
5 </head> | 5 </head> |
6 <body onload="test(document.getElementById('destination'), document.getElementBy
Id('frame').contentWindow.document);"> | 6 <body onload="test(document.getElementById('destination'), document.getElementBy
Id('frame').contentWindow.document);"> |
7 <pre id="console"></pre> | |
8 <div id="container"> | 7 <div id="container"> |
9 <div id="destination" contentEditable></div> | 8 <div id="destination" contentEditable></div> |
10 <iframe id="frame" src="data:text/html,<body contenteditable></body>"></iframe
> | 9 <iframe id="frame" src="data:text/html,<body contenteditable></body>"></iframe
> |
11 </div> | 10 </div> |
12 | 11 |
13 <script> | 12 <script> |
14 description("Spell check markers should be removed from the whole page when disa
bling spell checker but " + | 13 description("Spell check markers should be removed from the whole page when disa
bling spell checker " |
15 "they should be restored in the focused editable if spell checker gets enabled.
" + | 14 + "but they should be restored in the focused editable if spell checker gets
enabled. " |
16 "To test manually type something with mispellings in the above editable element
and iframe and turn " + | 15 + "To test manually, turn spell checker off - misspelling markers should dis
appear. " |
17 "spell checker off - misspelling markers should disappear. Having the editable f
ocused " + | 16 + "Having the editable focused, turn spell checker on. Misspellings in the e
ditable should be marked."); |
18 "turn spell checker on again. Misspellings in the editable should be marked agai
n."); | |
19 | 17 |
20 jsTestIsAsync = true; | 18 jsTestIsAsync = true; |
21 | 19 |
22 var destination_elm = null; | 20 function hasSpellingMarkerOnSetting(element, enableSpellChecking) |
23 var destination_elm_in_frame = null; | 21 { |
| 22 internals.setContinuousSpellCheckingEnabled(enableSpellChecking); |
| 23 return !!internals.markerCountForNode(element.firstChild, "spelling"); |
| 24 } |
24 | 25 |
25 function test(destination, frame_doc) | 26 var editableDiv = null; |
| 27 var editableBodyInFrame = null; |
| 28 |
| 29 function test(div, frameDocument) |
26 { | 30 { |
27 if (!window.internals) | 31 editableDiv = div; |
28 { | 32 editableBodyInFrame = frameDocument.body; |
29 document.getElementById("console").innerHTML = "Automatic testing imposs
ible. Test manually.\n"; | 33 |
| 34 // Type misspellings to trigger spellchecking on editable fields. |
| 35 editableDiv.focus(); |
| 36 document.execCommand("InsertText", false, "zz."); |
| 37 editableBodyInFrame.focus(); |
| 38 frameDocument.execCommand("InsertText", false, "zz."); |
| 39 |
| 40 if (!window.internals) { |
| 41 debug("Automatic testing impossible. Test manually."); |
30 return; | 42 return; |
31 } | 43 } |
32 | 44 |
33 internals.settings.setAsynchronousSpellCheckingEnabled(false); | 45 internals.settings.setAsynchronousSpellCheckingEnabled(true); |
34 internals.settings.setUnifiedTextCheckerEnabled(true); | 46 internals.settings.setUnifiedTextCheckerEnabled(true); |
35 | 47 |
36 destination_elm = destination; | 48 shouldBecomeEqual('hasSpellingMarkerOnSetting(editableDiv, true)', 'true', f
unction() { |
37 destination_elm_in_frame = frame_doc.body; | 49 shouldBecomeEqual('hasSpellingMarkerOnSetting(editableBodyInFrame, true)
', 'true', function() { |
38 destination_elm.focus(); | 50 // Turn off spellchecking, all misspellings should disappear. |
39 document.execCommand("InsertText", false, "zz."); | 51 shouldBecomeEqual('hasSpellingMarkerOnSetting(editableDiv, false)',
'false', function() { |
40 shouldBe('internals.markerCountForNode(destination_elm.childNodes[0], "spell
ing")', '1'); | 52 shouldBecomeEqual('hasSpellingMarkerOnSetting(editableBodyInFram
e, false)', 'false', function() { |
41 destination_elm_in_frame.focus(); | 53 // Focus element and turn on spellchecking. |
42 frame_doc.execCommand("InsertText", false, "zz."); | 54 // Only misspellings of the focused element should be restor
ed. |
43 shouldBe('internals.markerCountForNode(destination_elm_in_frame.childNodes[0
], "spelling")', '1'); | 55 editableDiv.focus(); |
44 internals.setContinuousSpellCheckingEnabled(false); | 56 shouldBecomeEqual('hasSpellingMarkerOnSetting(editableDiv, t
rue)', 'true', function() { |
45 shouldBe('internals.markerCountForNode(destination_elm.childNodes[0], "spell
ing")', '0'); | 57 shouldBecomeEqual('hasSpellingMarkerOnSetting(editableBo
dyInFrame, true)', 'false', finishJSTest); |
46 shouldBe('internals.markerCountForNode(destination_elm_in_frame.childNodes[0
], "spelling")', '0'); | 58 }); |
47 destination_elm.focus(); | 59 }); |
48 internals.setContinuousSpellCheckingEnabled(true); | 60 }); |
49 shouldBe('internals.markerCountForNode(destination_elm.childNodes[0], "spell
ing")', '1'); | 61 }); |
50 | 62 }); |
51 finishJSTest(); | |
52 } | 63 } |
53 | 64 |
54 </script> | 65 </script> |
55 </body> | 66 </body> |
56 </html> | 67 </html> |
OLD | NEW |