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

Side by Side Diff: LayoutTests/editing/spelling/spellcheck-disable-enable.html

Issue 70073005: Refactoring spellcheck-disable-enable.html to use async path for spellcheck (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: 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-disable-enable-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="../../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').contentDocument.body);">
7 <pre id="console"></pre>
8 <div id="container"> 7 <div id="container">
9 <div id="destination" contentEditable></div> 8 <div id="destination" contentEditable>zz.</div>
10 <iframe id="frame" src="data:text/html,<body contenteditable></body>"></iframe > 9 <iframe id="frame" src="data:text/html,<body contenteditable>zz.</body>"></ifr ame>
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 internals.setContinuousSpellCheckingEnabled(enableSpellChecking);
22 return internals.markerCountForNode(element.firstChild, "spelling") ? true : false;
tony 2013/11/13 17:30:34 Nit: return !!internals.markerCountForNode(element
grzegorz 2013/11/14 08:44:22 Thanks. Done.
23 }
24 24
25 function test(destination, frame_doc) 25 var editableDiv = null;
26 { 26 var editableBodyInFrame = null;
27 if (!window.internals) 27
28 { 28 function test(div, frameBody) {
29 document.getElementById("console").innerHTML = "Automatic testing imposs ible. Test manually.\n"; 29
30 if (!window.internals) {
31 debug("Automatic testing impossible. Test manually.");
30 return; 32 return;
31 } 33 }
32 34
33 internals.settings.setAsynchronousSpellCheckingEnabled(false); 35 internals.settings.setAsynchronousSpellCheckingEnabled(true);
34 internals.settings.setUnifiedTextCheckerEnabled(true); 36 internals.settings.setUnifiedTextCheckerEnabled(true);
35 37
36 destination_elm = destination; 38 editableDiv = div;
37 destination_elm_in_frame = frame_doc.body; 39 editableBodyInFrame = frameBody;
38 destination_elm.focus();
39 document.execCommand("InsertText", false, "zz.");
40 shouldBe('internals.markerCountForNode(destination_elm.childNodes[0], "spell ing")', '1');
41 destination_elm_in_frame.focus();
42 frame_doc.execCommand("InsertText", false, "zz.");
43 shouldBe('internals.markerCountForNode(destination_elm_in_frame.childNodes[0 ], "spelling")', '1');
44 internals.setContinuousSpellCheckingEnabled(false);
45 shouldBe('internals.markerCountForNode(destination_elm.childNodes[0], "spell ing")', '0');
46 shouldBe('internals.markerCountForNode(destination_elm_in_frame.childNodes[0 ], "spelling")', '0');
47 destination_elm.focus();
48 internals.setContinuousSpellCheckingEnabled(true);
49 shouldBe('internals.markerCountForNode(destination_elm.childNodes[0], "spell ing")', '1');
50 40
51 finishJSTest(); 41 // Trigger spellchecking on editable fields.
42 editableDiv.focus();
43 editableBodyInFrame.focus();
44 // Without blur, this element doesn't have misspelling. However, Chrome does n't need it.
45 editableBodyInFrame.blur();
46
47 shouldBecomeEqual('hasSpellingMarkerOnSetting(editableDiv, true)', 'true', f unction() {
48 shouldBecomeEqual('hasSpellingMarkerOnSetting(editableBodyInFrame, true) ', 'true', function() {
49 // Turn off spellchecking, all misspellings should disappear.
50 shouldBecomeEqual('hasSpellingMarkerOnSetting(editableDiv, false)', 'false', function() {
51 shouldBecomeEqual('hasSpellingMarkerOnSetting(editableBodyInFram e, false)', 'false', function() {
52 // Focus element and turn on spellchecking.
53 // Only misspellings of the focused element should be restor ed.
54 editableDiv.focus();
55 shouldBecomeEqual('hasSpellingMarkerOnSetting(editableDiv, t rue)', 'true', function() {
56 shouldBecomeEqual('hasSpellingMarkerOnSetting(editableBo dyInFrame, true)', 'false', finishJSTest);
57 });
58 });
59 });
60 });
61 });
52 } 62 }
53 63
54 </script> 64 </script>
55 </body> 65 </body>
56 </html> 66 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/editing/spelling/spellcheck-disable-enable-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698