4 <script src=
"../../resources/js-test.js"></script>
6 <body onload=
"test(document.getElementById('destination'), document.getElementById('frame').contentWindow.document);">
8 <div id=
"destination" contentEditable
></div>
9 <iframe id=
"frame" src=
"data:text/html,<body contenteditable></body>"></iframe>
13 description("Spell check markers should be removed from the whole page when disabling spell checker "
14 + "but they should be restored in the focused editable if spell checker gets enabled. "
15 + "To test manually, turn spell checker off - misspelling markers should disappear. "
16 + "Having the editable focused, turn spell checker on. Misspellings in the editable should be marked.");
20 function hasSpellingMarkerOnSetting(element
, enableSpellChecking
)
22 internals
.setContinuousSpellCheckingEnabled(enableSpellChecking
);
23 return !!internals
.markerCountForNode(element
.firstChild
, "spelling");
26 var editableDiv
= null;
27 var editableBodyInFrame
= null;
29 function test(div
, frameDocument
)
32 editableBodyInFrame
= frameDocument
.body
;
34 // Type misspellings to trigger spellchecking on editable fields.
36 document
.execCommand("InsertText", false, "zz.");
37 editableBodyInFrame
.focus();
38 frameDocument
.execCommand("InsertText", false, "zz.");
40 if (!window
.internals
) {
41 debug("Automatic testing impossible. Test manually.");
45 internals
.settings
.setAsynchronousSpellCheckingEnabled(true);
46 internals
.settings
.setUnifiedTextCheckerEnabled(true);
48 shouldBecomeEqual('hasSpellingMarkerOnSetting(editableDiv, true)', 'true', function() {
49 shouldBecomeEqual('hasSpellingMarkerOnSetting(editableBodyInFrame, true)', 'true', function() {
50 // Turn off spellchecking, all misspellings should disappear.
51 shouldBecomeEqual('hasSpellingMarkerOnSetting(editableDiv, false)', 'false', function() {
52 shouldBecomeEqual('hasSpellingMarkerOnSetting(editableBodyInFrame, false)', 'false', function() {
53 // Focus element and turn on spellchecking.
54 // Only misspellings of the focused element should be restored.
56 shouldBecomeEqual('hasSpellingMarkerOnSetting(editableDiv, true)', 'true', function() {
57 shouldBecomeEqual('hasSpellingMarkerOnSetting(editableBodyInFrame, true)', 'false', finishJSTest
);