LayoutTests/ChangeLog

 12013-01-28 Rouslan Solomakhin <rouslan@chromium.org>
 2
 3 Tests for spell checker behavior
 4 https://bugs.webkit.org/show_bug.cgi?id=106815
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Tests for the following spell check behavior:
 9 - Spellcheck selects the misspelled word on context click.
 10 - Spelling should work when the user selects the misspelled word exactly.
 11 - If the word is not misspelled, there should be no spelling options in the context menu.
 12 - Spellcheck should select multi-word misspellings on context click.
 13 - Spelling should work when the user selects a multi-word misspelling exactly.
 14 - Spelling should work for double-clicked misspellings.
 15 - Spelling should ignore whitespace.
 16 - Underscores should be treated as whitespace: spelling should ignore them.
 17 - Punctuation marks should be treated as whitespace: spelling should ignore them.
 18 - Spelling should be disabled when user selects a part of misspelling.
 19 - Spelling should be disabled when user selects multiple words that are not a single misspelling.
 20
 21 * editing/spelling/spelling-double-clicked-word-expected.txt: Added.
 22 * editing/spelling/spelling-double-clicked-word-with-underscores-expected.txt: Added.
 23 * editing/spelling/spelling-double-clicked-word-with-underscores.html: Added.
 24 * editing/spelling/spelling-double-clicked-word.html: Added.
 25 * editing/spelling/spelling-exactly-selected-multiple-words-expected.txt: Added.
 26 * editing/spelling/spelling-exactly-selected-multiple-words.html: Added.
 27 * editing/spelling/spelling-exactly-selected-word-expected.txt: Added.
 28 * editing/spelling/spelling-exactly-selected-word.html: Added.
 29 * editing/spelling/spelling-multiword-selection-expected.txt: Added.
 30 * editing/spelling/spelling-multiword-selection.html: Added.
 31 * editing/spelling/spelling-should-select-multiple-words-expected.txt: Added.
 32 * editing/spelling/spelling-should-select-multiple-words.html: Added.
 33 * editing/spelling/spelling-should-select-single-word-expected.txt: Added.
 34 * editing/spelling/spelling-should-select-single-word.html: Added.
 35 * editing/spelling/spelling-subword-selection-expected.txt: Added.
 36 * editing/spelling/spelling-subword-selection.html: Added.
 37 * editing/spelling/spelling-with-punctuation-selection-expected.txt: Added.
 38 * editing/spelling/spelling-with-punctuation-selection.html: Added.
 39 * editing/spelling/spelling-with-underscore-selection-expected.txt: Added.
 40 * editing/spelling/spelling-with-underscore-selection.html: Added.
 41 * editing/spelling/spelling-with-whitespace-selection-expected.txt: Added.
 42 * editing/spelling/spelling-with-whitespace-selection.html: Added.
 43
1442013-01-28 Zoltan Arvai <zarvai@inf.u-szeged.hu>
245
346 [Qt] Unreviewed gardening.

LayoutTests/editing/spelling/spelling-double-clicked-word-expected.txt

 1Spelling should work for double-clicked misspellings. To test manually, type 'wellcome home.', double-click on 'wellcome', and context-click on the selection. The test succeeds when the context menu shows spell check suggestions.
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6PASS spellingMarkerRange.toString() is "wellcome"
 7PASS window.getSelection().toString() is ""
 8PASS window.getSelection().toString() is "wellcome"
 9PASS spellingMarkerRange.toString() is "wellcome"
 10PASS window.getSelection().toString() is "wellcome"
 11PASS contextMenuElements[contextMenuElements.length - 1] is "welcome"
 12PASS window.getSelection().toString() is ""
 13PASS window.getSelection().toString() is "wellcome "
 14PASS spellingMarkerRange.toString() is "wellcome"
 15PASS window.getSelection().toString() is "wellcome "
 16PASS contextMenuElements[contextMenuElements.length - 1] is "welcome"
 17PASS successfullyParsed is true
 18
 19TEST COMPLETE
 20wellcome home.

LayoutTests/editing/spelling/spelling-double-clicked-word-with-underscores-expected.txt

 1Spelling should work for double-clicked misspelled words with underscores. To test manually, type 'wellcome_ home.', double-click on 'wellcome_', and context-click on the selection. The test succeeds when the context menu shows spell check suggestions.
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6PASS spellingMarkerRange.toString() is "wellcome"
 7PASS window.getSelection().toString() is ""
 8PASS window.getSelection().toString() is "wellcome_"
 9PASS spellingMarkerRange.toString() is "wellcome"
 10PASS window.getSelection().toString() is "wellcome_"
 11PASS contextMenuElements[contextMenuElements.length - 1] is "welcome"
 12PASS window.getSelection().toString() is ""
 13PASS window.getSelection().toString() is "wellcome_ "
 14PASS spellingMarkerRange.toString() is "wellcome"
 15PASS window.getSelection().toString() is "wellcome_ "
 16PASS contextMenuElements[contextMenuElements.length - 1] is "welcome"
 17PASS successfullyParsed is true
 18
 19TEST COMPLETE
 20wellcome_ home.

LayoutTests/editing/spelling/spelling-double-clicked-word-with-underscores.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4<script src="../../fast/js/resources/js-test-pre.js"></script>
 5</head>
 6<body>
 7<div id="container">
 8 <div id="destination" contentEditable></div>
 9</div>
 10
 11<script>
 12
 13function verify(nretry)
 14{
 15 if (!nretry) {
 16 finishJSTest();
 17 return;
 18 }
 19
 20 if (!internals.markerCountForNode(destination.childNodes[0], "spelling")) {
 21 window.setTimeout(function() { verify(nretry - 1); }, 0);
 22 return;
 23 }
 24
 25 spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0);
 26 shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome");
 27
 28 window.getSelection().removeAllRanges();
 29 shouldBeEqualToString("window.getSelection().toString()", "");
 30
 31 // Double-click the misspelled word without the trailing whitespace.
 32 testRunner.setSelectTrailingWhitespaceEnabled(false);
 33 var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 40;
 34 var y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2;
 35 eventSender.mouseMoveTo(x, y);
 36 eventSender.mouseDown();
 37 eventSender.mouseUp();
 38 eventSender.mouseDown();
 39 eventSender.mouseUp();
 40
 41 shouldBeEqualToString("window.getSelection().toString()", "wellcome_");
 42
 43 // Context click on "wellcome_" to show the context menu.
 44 x = destination.offsetParent.offsetLeft + destination.offsetLeft + 40;
 45 y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2;
 46 eventSender.mouseMoveTo(x, y);
 47 contextMenuElements = eventSender.contextClick();
 48 // Esc key to hide the context menu.
 49 eventSender.keyDown(String.fromCharCode(0x001B), null);
 50
 51 spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0);
 52 shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome");
 53 shouldBeEqualToString("window.getSelection().toString()", "wellcome_");
 54 shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "welcome");
 55
 56 window.getSelection().removeAllRanges();
 57 shouldBeEqualToString("window.getSelection().toString()", "");
 58
 59 // Double-click the misspelled word with the trailing whitespace.
 60 testRunner.setSelectTrailingWhitespaceEnabled(true);
 61 var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 40;
 62 var y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2;
 63 eventSender.mouseMoveTo(x, y);
 64 eventSender.mouseDown();
 65 eventSender.mouseUp();
 66 eventSender.mouseDown();
 67 eventSender.mouseUp();
 68
 69 shouldBeEqualToString("window.getSelection().toString()", "wellcome_ ");
 70
 71 // Context click on "wellcome_ " to show the context menu.
 72 x = destination.offsetParent.offsetLeft + destination.offsetLeft + 40;
 73 y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2;
 74 eventSender.mouseMoveTo(x, y);
 75 contextMenuElements = eventSender.contextClick();
 76 // Esc key to hide the context menu.
 77 eventSender.keyDown(String.fromCharCode(0x001B), null);
 78
 79 spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0);
 80 shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome");
 81 shouldBeEqualToString("window.getSelection().toString()", "wellcome_ ");
 82 shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "welcome");
 83
 84 finishJSTest();
 85}
 86
 87function test()
 88{
 89 jsTestIsAsync = true;
 90 internals.settings.setUnifiedTextCheckerEnabled(true);
 91 testRunner.setAsynchronousSpellCheckingEnabled(true);
 92 testRunner.setSmartInsertDeleteEnabled(true);
 93 var destination = document.getElementById("destination");
 94 destination.focus();
 95 document.execCommand("InsertText", false, "wellcome_ home.");
 96 window.setTimeout(function() { verify(10); }, 0);
 97}
 98
 99description("Spelling should work for double-clicked misspelled words with underscores. " +
 100 "To test manually, type 'wellcome_ home.', double-click on 'wellcome_', and context-click on the selection. " +
 101 "The test succeeds when the context menu shows spell check suggestions.");
 102if (window.internals)
 103 test();
 104
 105</script>
 106<script src="../../fast/js/resources/js-test-post.js"></script>
 107</body>
 108</html>

LayoutTests/editing/spelling/spelling-double-clicked-word.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4<script src="../../fast/js/resources/js-test-pre.js"></script>
 5</head>
 6<body>
 7<div id="container">
 8 <div id="destination" contentEditable></div>
 9</div>
 10
 11<script>
 12
 13function verify(nretry)
 14{
 15 if (!nretry) {
 16 finishJSTest()
 17 return;
 18 }
 19
 20 if (!internals.markerCountForNode(destination.childNodes[0], "spelling")) {
 21 window.setTimeout(function() { verify(nretry - 1); }, 0);
 22 return;
 23 }
 24
 25 spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0);
 26 shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome");
 27
 28 window.getSelection().removeAllRanges();
 29 shouldBeEqualToString("window.getSelection().toString()", "");
 30
 31 // Double-click the misspelled word without trailing whitespace.
 32 testRunner.setSelectTrailingWhitespaceEnabled(false);
 33 var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 40;
 34 var y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2;
 35 eventSender.mouseMoveTo(x, y);
 36 eventSender.mouseDown();
 37 eventSender.mouseUp();
 38 eventSender.mouseDown();
 39 eventSender.mouseUp();
 40 shouldBeEqualToString("window.getSelection().toString()", "wellcome");
 41
 42 // Context click on "wellcome" to show the context menu.
 43 x = destination.offsetParent.offsetLeft + destination.offsetLeft + 40;
 44 y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2;
 45 eventSender.mouseMoveTo(x, y);
 46 contextMenuElements = eventSender.contextClick();
 47 // Esc key to hide the context menu.
 48 eventSender.keyDown(String.fromCharCode(0x001B), null);
 49
 50 spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0);
 51 shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome");
 52 shouldBeEqualToString("window.getSelection().toString()", "wellcome");
 53 shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "welcome");
 54
 55 window.getSelection().removeAllRanges();
 56 shouldBeEqualToString("window.getSelection().toString()", "");
 57
 58 // Double-click the misspelled word with trailing whitespace.
 59 testRunner.setSelectTrailingWhitespaceEnabled(true);
 60 var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 40;
 61 var y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2;
 62 eventSender.mouseMoveTo(x, y);
 63 eventSender.mouseDown();
 64 eventSender.mouseUp();
 65 eventSender.mouseDown();
 66 eventSender.mouseUp();
 67 shouldBeEqualToString("window.getSelection().toString()", "wellcome ");
 68
 69 // Context click on "wellcome " to show the context menu.
 70 x = destination.offsetParent.offsetLeft + destination.offsetLeft + 40;
 71 y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2;
 72 eventSender.mouseMoveTo(x, y);
 73 contextMenuElements = eventSender.contextClick();
 74 // Esc key to hide the context menu.
 75 eventSender.keyDown(String.fromCharCode(0x001B), null);
 76
 77 spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0);
 78 shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome");
 79 shouldBeEqualToString("window.getSelection().toString()", "wellcome ");
 80 shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "welcome");
 81
 82 finishJSTest()
 83}
 84
 85function test()
 86{
 87 jsTestIsAsync = true;
 88 internals.settings.setUnifiedTextCheckerEnabled(true);
 89 testRunner.setAsynchronousSpellCheckingEnabled(true);
 90 testRunner.setSmartInsertDeleteEnabled(true);
 91 var destination = document.getElementById("destination");
 92 destination.focus();
 93 document.execCommand("InsertText", false, "wellcome home.");
 94 window.setTimeout(function() { verify(10); }, 0);
 95}
 96
 97description("Spelling should work for double-clicked misspellings. " +
 98 "To test manually, type 'wellcome home.', double-click on 'wellcome', and context-click on the selection. " +
 99 "The test succeeds when the context menu shows spell check suggestions.");
 100if (window.internals)
 101 test();
 102
 103</script>
 104<script src="../../fast/js/resources/js-test-post.js"></script>
 105</body>
 106</html>

LayoutTests/editing/spelling/spelling-exactly-selected-multiple-words-expected.txt

 1Spelling should work when the user selects a multi-word misspelling exactly. To test manually, enable 'Ask Google for Suggestions' in Chrome, type 'It should be upper case.', select 'upper case', and context-click on the selection.The test succeeds when the context menu shows spelling suggestions.
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6PASS spellingMarkerRange.toString() is "upper case"
 7PASS window.getSelection().toString() is ""
 8PASS window.getSelection().toString() is "upper case"
 9PASS spellingMarkerRange.toString() is "upper case"
 10PASS window.getSelection().toString() is "upper case"
 11PASS successfullyParsed is true
 12
 13TEST COMPLETE
 14It should be upper case.

LayoutTests/editing/spelling/spelling-exactly-selected-multiple-words.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4<script src="../../fast/js/resources/js-test-pre.js"></script>
 5</head>
 6<body>
 7<div id="container">
 8 <div id="destination" contentEditable></div>
 9</div>
 10<script>
 11
 12function verify(nretry)
 13{
 14 if (!nretry) {
 15 finishJSTest()
 16 return;
 17 }
 18
 19 if (!internals.markerCountForNode(destination.childNodes[0], "spelling")) {
 20 window.setTimeout(function() { verify(nretry - 1); }, 0);
 21 return;
 22 }
 23
 24 spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0);
 25 shouldBeEqualToString("spellingMarkerRange.toString()", "upper case");
 26 shouldBeEqualToString("window.getSelection().toString()", "");
 27
 28 // Select the multi-word misspelling without surrounding whitespace or punctuation.
 29 window.getSelection().removeAllRanges();
 30 var wordRange = document.createRange();
 31 wordRange.setStart(destination.childNodes[0], 13);
 32 wordRange.setEnd(destination.childNodes[0], 23);
 33 window.getSelection().addRange(wordRange);
 34
 35 shouldBeEqualToString("window.getSelection().toString()", "upper case");
 36
 37 // Context click on "upper case" to show the context menu.
 38 var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 100;
 39 var y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2;
 40 eventSender.mouseMoveTo(x, y);
 41 contextMenuElements = eventSender.contextClick();
 42 // Esc key to hide the context menu.
 43 eventSender.keyDown(String.fromCharCode(0x001B), null);
 44
 45 spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0);
 46 shouldBeEqualToString("spellingMarkerRange.toString()", "upper case");
 47 shouldBeEqualToString("window.getSelection().toString()", "upper case");
 48
 49 finishJSTest()
 50}
 51
 52function test()
 53{
 54 jsTestIsAsync = true;
 55 internals.settings.setUnifiedTextCheckerEnabled(true);
 56 testRunner.setAsynchronousSpellCheckingEnabled(true);
 57 testRunner.setSmartInsertDeleteEnabled(true);
 58 testRunner.setSelectTrailingWhitespaceEnabled(false);
 59 var destination = document.getElementById("destination");
 60 destination.focus();
 61 document.execCommand("InsertText", false, "It should be upper case.");
 62 window.setTimeout(function() { verify(10); }, 0);
 63}
 64
 65description("Spelling should work when the user selects a multi-word misspelling exactly. " +
 66 "To test manually, enable 'Ask Google for Suggestions' in Chrome, type 'It should be upper case.', select 'upper case', and context-click on the selection." +
 67 "The test succeeds when the context menu shows spelling suggestions.");
 68if (window.internals)
 69 test();
 70
 71</script>
 72<script src="../../fast/js/resources/js-test-post.js"></script>
 73</body>
 74</html>

LayoutTests/editing/spelling/spelling-exactly-selected-word-expected.txt

 1Spelling should work when the user selects the misspelled word exactly. To test manually, type 'wellcome home.', select 'wellcome', and context-click on the selection. The test succeeds when the context menu shows spelling suggestions.
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6PASS spellingMarkerRange.toString() is "wellcome"
 7PASS window.getSelection().toString() is "wellcome"
 8PASS spellingMarkerRange.toString() is "wellcome"
 9PASS window.getSelection().toString() is "wellcome"
 10PASS contextMenuElements[contextMenuElements.length - 1] is "welcome"
 11PASS window.getSelection().toString() is "home"
 12PASS window.getSelection().toString() is "home"
 13PASS contextMenuElements[contextMenuElements.length - 1] is "<separator>"
 14PASS successfullyParsed is true
 15
 16TEST COMPLETE
 17wellcome home.

LayoutTests/editing/spelling/spelling-exactly-selected-word.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4<script src="../../fast/js/resources/js-test-pre.js"></script>
 5</head>
 6<body>
 7<div id="container">
 8 <div id="destination" contentEditable></div>
 9</div>
 10
 11<script>
 12
 13function verify(nretry)
 14{
 15 if (!nretry) {
 16 finishJSTest()
 17 return;
 18 }
 19
 20 if (!internals.markerCountForNode(destination.childNodes[0], "spelling")) {
 21 window.setTimeout(function() { verify(nretry - 1); }, 0);
 22 return;
 23 }
 24
 25 // Select the misspelled word without surrounding whitespace or punctuation.
 26 window.getSelection().removeAllRanges();
 27 var wordRange = document.createRange();
 28 wordRange.setStart(destination.childNodes[0], 0);
 29 wordRange.setEnd(destination.childNodes[0], 8);
 30 window.getSelection().addRange(wordRange);
 31
 32 spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0);
 33 shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome");
 34 shouldBeEqualToString("window.getSelection().toString()", "wellcome");
 35
 36 // Context click on "wellcome" to show the context menu.
 37 var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 40;
 38 var y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2;
 39 eventSender.mouseMoveTo(x, y);
 40 contextMenuElements = eventSender.contextClick();
 41 // Esc key to hide the context menu.
 42 eventSender.keyDown(String.fromCharCode(0x001B), null);
 43
 44 spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0);
 45 shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome");
 46 shouldBeEqualToString("window.getSelection().toString()", "wellcome");
 47 shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "welcome");
 48
 49 window.getSelection().removeAllRanges();
 50 wordRange.setStart(destination.childNodes[0], 9);
 51 wordRange.setEnd(destination.childNodes[0], 13);
 52 window.getSelection().addRange(wordRange);
 53 shouldBeEqualToString("window.getSelection().toString()", "home");
 54
 55 // Context click on "home" to show the context menu.
 56 var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 80;
 57 var y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2;
 58 eventSender.mouseMoveTo(x, y);
 59 contextMenuElements = eventSender.contextClick();
 60 // Esc key to hide the context menu.
 61 eventSender.keyDown(String.fromCharCode(0x001B), null);
 62
 63 shouldBeEqualToString("window.getSelection().toString()", "home");
 64 shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "<separator>");
 65
 66 finishJSTest()
 67}
 68
 69function test()
 70{
 71 jsTestIsAsync = true;
 72 internals.settings.setUnifiedTextCheckerEnabled(true);
 73 testRunner.setAsynchronousSpellCheckingEnabled(true);
 74 testRunner.setSmartInsertDeleteEnabled(true);
 75 testRunner.setSelectTrailingWhitespaceEnabled(false);
 76 var destination = document.getElementById("destination");
 77 destination.focus();
 78 document.execCommand("InsertText", false, "wellcome home.");
 79 window.setTimeout(function() { verify(10); }, 0);
 80}
 81
 82description("Spelling should work when the user selects the misspelled word exactly. " +
 83 "To test manually, type 'wellcome home.', select 'wellcome', and context-click on the selection. " +
 84 "The test succeeds when the context menu shows spelling suggestions.");
 85if (window.internals)
 86 test();
 87
 88</script>
 89<script src="../../fast/js/resources/js-test-post.js"></script>
 90</body>
 91</html>

LayoutTests/editing/spelling/spelling-multiword-selection-expected.txt

 1Spelling should be disabled when user selects multiple words that are not a single misspelling. To test manually, type 'wellcome home.', select 'wellcome home', and context-click on the selection. The test suceeds when the context menu has no spell check suggestions.
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6PASS spellingMarkerRange.toString() is "wellcome"
 7PASS window.getSelection().toString() is ""
 8PASS window.getSelection().toString() is "wellcome home"
 9PASS spellingMarkerRange.toString() is "wellcome"
 10PASS window.getSelection().toString() is "wellcome home"
 11PASS contextMenuElements[contextMenuElements.length - 1] is "<separator>"
 12PASS successfullyParsed is true
 13
 14TEST COMPLETE
 15wellcome home.

LayoutTests/editing/spelling/spelling-multiword-selection.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4<script src="../../fast/js/resources/js-test-pre.js"></script>
 5</head>
 6<body>
 7<div id="container">
 8 <div id="destination" contentEditable></div>
 9</div>
 10
 11<script>
 12
 13function verify(nretry)
 14{
 15 if (!nretry) {
 16 finishJSTest()
 17 return;
 18 }
 19
 20 if (!internals.markerCountForNode(destination.childNodes[0], "spelling")) {
 21 window.setTimeout(function() { verify(nretry - 1); }, 0);
 22 return;
 23 }
 24
 25 spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0);
 26 shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome");
 27 shouldBeEqualToString("window.getSelection().toString()", "");
 28
 29 window.getSelection().removeAllRanges();
 30 var multiWordRange = document.createRange();
 31 multiWordRange.setStart(destination.childNodes[0], 0);
 32 multiWordRange.setEnd(destination.childNodes[0], 13);
 33 window.getSelection().addRange(multiWordRange);
 34
 35 shouldBeEqualToString("window.getSelection().toString()", "wellcome home");
 36
 37 // Context click to show the context menu.
 38 var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 40;
 39 var y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2;
 40 eventSender.mouseMoveTo(x, y);
 41 contextMenuElements = eventSender.contextClick();
 42 // Esc key to hide the context menu.
 43 eventSender.keyDown(String.fromCharCode(0x001B), null);
 44
 45 spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0);
 46 shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome");
 47 shouldBeEqualToString("window.getSelection().toString()", "wellcome home");
 48 shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "<separator>");
 49
 50 finishJSTest()
 51}
 52
 53function test()
 54{
 55 jsTestIsAsync = true;
 56 internals.settings.setUnifiedTextCheckerEnabled(true);
 57 testRunner.setAsynchronousSpellCheckingEnabled(true);
 58 testRunner.setSmartInsertDeleteEnabled(true);
 59 testRunner.setSelectTrailingWhitespaceEnabled(false);
 60 var destination = document.getElementById("destination");
 61 destination.focus();
 62 document.execCommand("InsertText", false, "wellcome home.");
 63 window.setTimeout(function() { verify(10); }, 0);
 64}
 65
 66description("Spelling should be disabled when user selects multiple words that are not a single misspelling. " +
 67 "To test manually, type 'wellcome home.', select 'wellcome home', and context-click on the selection. " +
 68 "The test suceeds when the context menu has no spell check suggestions.");
 69if (window.internals)
 70 test();
 71
 72</script>
 73<script src="../../fast/js/resources/js-test-post.js"></script>
 74</body>
 75</html>

LayoutTests/editing/spelling/spelling-should-select-multiple-words-expected.txt

 1Spell check should select multi-word misspellings on context click. To test manually, enable 'Ask Google for Suggestions' in Chrome, type 'It should be upper case.', and context-click on the word 'upper'. The test succeeds when 'upper case' was selected after context click.
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6PASS spellingMarkerRange.toString() is "upper case"
 7PASS window.getSelection().toString() is ""
 8PASS spellingMarkerRange.toString() is "upper case"
 9PASS window.getSelection().toString() is "upper case"
 10PASS successfullyParsed is true
 11
 12TEST COMPLETE
 13It should be upper case.

LayoutTests/editing/spelling/spelling-should-select-multiple-words.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4<script src="../../fast/js/resources/js-test-pre.js"></script>
 5</head>
 6<body>
 7<div id="container">
 8 <div id="destination" contentEditable></div>
 9</div>
 10<script>
 11
 12function verify(nretry)
 13{
 14 if (!nretry) {
 15 finishJSTest()
 16 return;
 17 }
 18
 19 if (!internals.markerCountForNode(destination.childNodes[0], "spelling")) {
 20 window.setTimeout(function() { verify(nretry - 1); }, 0);
 21 return;
 22 }
 23
 24 spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0);
 25 shouldBeEqualToString("spellingMarkerRange.toString()", "upper case");
 26 shouldBeEqualToString("window.getSelection().toString()", "");
 27
 28 // Context click on "upper case" to show the context menu.
 29 var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 100;
 30 var y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2;
 31 eventSender.mouseMoveTo(x, y);
 32 contextMenuElements = eventSender.contextClick();
 33 // Esc key to hide the context menu.
 34 eventSender.keyDown(String.fromCharCode(0x001B), null);
 35
 36 spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0);
 37 shouldBeEqualToString("spellingMarkerRange.toString()", "upper case");
 38 shouldBeEqualToString("window.getSelection().toString()", "upper case");
 39
 40 finishJSTest()
 41}
 42
 43function test()
 44{
 45 jsTestIsAsync = true;
 46 internals.settings.setUnifiedTextCheckerEnabled(true);
 47 testRunner.setAsynchronousSpellCheckingEnabled(true);
 48 testRunner.setSmartInsertDeleteEnabled(true);
 49 testRunner.setSelectTrailingWhitespaceEnabled(false);
 50 var destination = document.getElementById("destination");
 51 destination.focus();
 52 document.execCommand("InsertText", false, "It should be upper case.");
 53 window.setTimeout(function() { verify(10); }, 0);
 54}
 55
 56description("Spell check should select multi-word misspellings on context click. "+
 57 "To test manually, enable 'Ask Google for Suggestions' in Chrome, type 'It should be upper case.', and context-click on the word 'upper'. " +
 58 "The test succeeds when 'upper case' was selected after context click.");
 59if (window.internals)
 60 test();
 61
 62</script>
 63<script src="../../fast/js/resources/js-test-post.js"></script>
 64</body>
 65</html>

LayoutTests/editing/spelling/spelling-should-select-single-word-expected.txt

 1Spell check selects the misspelled word on context click. To test manually, type 'wellcome home.' and context-click on 'wellcome'. The test succeeds when 'wellcome' is selected after the context click.
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6PASS spellingMarkerRange.toString() is "wellcome"
 7PASS window.getSelection().toString() is ""
 8PASS spellingMarkerRange.toString() is "wellcome"
 9PASS window.getSelection().toString() is "wellcome"
 10PASS contextMenuElements[contextMenuElements.length - 1] is "welcome"
 11PASS window.getSelection().toString() is ""
 12PASS window.getSelection().toString() is ""
 13PASS contextMenuElements[contextMenuElements.length - 1] is "<separator>"
 14PASS successfullyParsed is true
 15
 16TEST COMPLETE
 17wellcome home.

LayoutTests/editing/spelling/spelling-should-select-single-word.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4<script src="../../fast/js/resources/js-test-pre.js"></script>
 5</head>
 6<body>
 7<div id="container">
 8 <div id="destination" contentEditable></div>
 9</div>
 10
 11<script>
 12
 13function verify(nretry)
 14{
 15 if (!nretry) {
 16 finishJSTest()
 17 return;
 18 }
 19
 20 if (!internals.markerCountForNode(destination.childNodes[0], "spelling")) {
 21 window.setTimeout(function() { verify(nretry - 1); }, 0);
 22 return;
 23 }
 24
 25 spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0);
 26 shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome");
 27 shouldBeEqualToString("window.getSelection().toString()", "");
 28
 29 // Context click on "wellcome" to show the context menu.
 30 var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 40;
 31 var y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2;
 32 eventSender.mouseMoveTo(x, y);
 33 contextMenuElements = eventSender.contextClick();
 34 // Esc key to hide the context menu.
 35 eventSender.keyDown(String.fromCharCode(0x001B), null);
 36
 37 spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0);
 38 shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome");
 39 shouldBeEqualToString("window.getSelection().toString()", "wellcome");
 40 shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "welcome");
 41
 42 window.getSelection().removeAllRanges();
 43 shouldBeEqualToString("window.getSelection().toString()", "");
 44
 45 // Context click on "home" to show the context menu.
 46 var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 80;
 47 var y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2;
 48 eventSender.mouseMoveTo(x, y);
 49 contextMenuElements = eventSender.contextClick();
 50 // Esc key to hide the context menu.
 51 eventSender.keyDown(String.fromCharCode(0x001B), null);
 52
 53 shouldBeEqualToString("window.getSelection().toString()", "");
 54 shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "<separator>");
 55
 56 finishJSTest()
 57}
 58
 59function test()
 60{
 61 jsTestIsAsync = true;
 62 internals.settings.setUnifiedTextCheckerEnabled(true);
 63 testRunner.setAsynchronousSpellCheckingEnabled(true);
 64 testRunner.setSmartInsertDeleteEnabled(true);
 65 testRunner.setSelectTrailingWhitespaceEnabled(false);
 66 var destination = document.getElementById("destination");
 67 destination.focus();
 68 document.execCommand("InsertText", false, "wellcome home.");
 69 window.setTimeout(function() { verify(10); }, 0);
 70}
 71
 72description("Spell check selects the misspelled word on context click. " +
 73 "To test manually, type 'wellcome home.' and context-click on 'wellcome'. " +
 74 "The test succeeds when 'wellcome' is selected after the context click.");
 75if (window.internals)
 76 test();
 77
 78</script>
 79<script src="../../fast/js/resources/js-test-post.js"></script>
 80</body>
 81</html>

LayoutTests/editing/spelling/spelling-subword-selection-expected.txt

 1Spelling should be disabled when user selects a part of misspelling. To test manually, type 'wellcome home.' select 'llco', and context-click on the selection. The test suceeds when the context menu has no spell check suggestions.
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6PASS spellingMarkerRange.toString() is "wellcome"
 7PASS window.getSelection().toString() is ""
 8PASS window.getSelection().toString() is "llco"
 9PASS spellingMarkerRange.toString() is "wellcome"
 10PASS window.getSelection().toString() is "llco"
 11PASS contextMenuElements[contextMenuElements.length - 1] is "<separator>"
 12PASS successfullyParsed is true
 13
 14TEST COMPLETE
 15wellcome home.

LayoutTests/editing/spelling/spelling-subword-selection.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4<script src="../../fast/js/resources/js-test-pre.js"></script>
 5</head>
 6<body>
 7<div id="container">
 8 <div id="destination" contentEditable></div>
 9</div>
 10
 11<script>
 12
 13function verify(nretry)
 14{
 15 if (!nretry) {
 16 finishJSTest()
 17 return;
 18 }
 19
 20 if (!internals.markerCountForNode(destination.childNodes[0], "spelling")) {
 21 window.setTimeout(function() { verify(nretry - 1); }, 0);
 22 return;
 23 }
 24
 25 spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0);
 26 shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome");
 27 shouldBeEqualToString("window.getSelection().toString()", "");
 28
 29 window.getSelection().removeAllRanges();
 30 var subWordRange = document.createRange();
 31 subWordRange.setStart(destination.childNodes[0], 2);
 32 subWordRange.setEnd(destination.childNodes[0], 6);
 33 window.getSelection().addRange(subWordRange);
 34 shouldBeEqualToString("window.getSelection().toString()", "llco");
 35
 36 // Context click to show the context menu.
 37 var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 40;
 38 var y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2;
 39 eventSender.mouseMoveTo(x, y);
 40 contextMenuElements = eventSender.contextClick();
 41 // Esc key to hide the context menu.
 42 eventSender.keyDown(String.fromCharCode(0x001B), null);
 43
 44 spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0);
 45 shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome");
 46 shouldBeEqualToString("window.getSelection().toString()", "llco");
 47 shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "<separator>");
 48
 49 finishJSTest()
 50}
 51
 52function test()
 53{
 54 jsTestIsAsync = true;
 55 internals.settings.setUnifiedTextCheckerEnabled(true);
 56 testRunner.setAsynchronousSpellCheckingEnabled(true);
 57 testRunner.setSmartInsertDeleteEnabled(true);
 58 testRunner.setSelectTrailingWhitespaceEnabled(false);
 59 var destination = document.getElementById("destination");
 60 destination.focus();
 61 document.execCommand("InsertText", false, "wellcome home.");
 62 window.setTimeout(function() { verify(10); }, 0);
 63}
 64
 65description("Spelling should be disabled when user selects a part of misspelling. " +
 66 "To test manually, type 'wellcome home.' select 'llco', and context-click on the selection. " +
 67 "The test suceeds when the context menu has no spell check suggestions.");
 68if (window.internals)
 69 test();
 70
 71</script>
 72<script src="../../fast/js/resources/js-test-post.js"></script>
 73</body>
 74</html>

LayoutTests/editing/spelling/spelling-with-punctuation-selection-expected.txt

 1Punctuation marks should be treated as whitespace: spelling should ignore them. To test manually, type 'wellcome!', select 'wellcome!', and context-click on the selection. The test succeeds when the context menu has spell check suggestions.
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6PASS spellingMarkerRange.toString() is "wellcome"
 7PASS window.getSelection().toString() is ""
 8PASS window.getSelection().toString() is "wellcome!"
 9PASS spellingMarkerRange.toString() is "wellcome"
 10PASS window.getSelection().toString() is "wellcome!"
 11PASS contextMenuElements[contextMenuElements.length - 1] is "welcome"
 12PASS successfullyParsed is true
 13
 14TEST COMPLETE
 15wellcome!

LayoutTests/editing/spelling/spelling-with-punctuation-selection.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4<script src="../../fast/js/resources/js-test-pre.js"></script>
 5</head>
 6<body>
 7<div id="container">
 8 <div id="destination" contentEditable></div>
 9</div>
 10
 11<script>
 12
 13function verify(nretry)
 14{
 15 if (!nretry) {
 16 finishJSTest()
 17 return;
 18 }
 19
 20 if (!internals.markerCountForNode(destination.childNodes[0], "spelling")) {
 21 window.setTimeout(function() { verify(nretry - 1); }, 0);
 22 return;
 23 }
 24
 25 spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0);
 26 shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome");
 27 shouldBeEqualToString("window.getSelection().toString()", "");
 28
 29 var range = document.createRange();
 30 range.setStart(destination.childNodes[0], 0);
 31 range.setEnd(destination.childNodes[0], 9);
 32 window.getSelection().addRange(range);
 33 shouldBeEqualToString("window.getSelection().toString()", "wellcome!");
 34
 35 // Context click to show the context menu.
 36 var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 40;
 37 var y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2;
 38 eventSender.mouseMoveTo(x, y);
 39 contextMenuElements = eventSender.contextClick();
 40 // Esc key to hide the context menu.
 41 eventSender.keyDown(String.fromCharCode(0x001B), null);
 42
 43 spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0);
 44 shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome");
 45 shouldBeEqualToString("window.getSelection().toString()", "wellcome!");
 46 shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "welcome");
 47
 48 finishJSTest()
 49}
 50
 51function test()
 52{
 53 jsTestIsAsync = true;
 54 internals.settings.setUnifiedTextCheckerEnabled(true);
 55 testRunner.setAsynchronousSpellCheckingEnabled(true);
 56 testRunner.setSmartInsertDeleteEnabled(true);
 57 testRunner.setSelectTrailingWhitespaceEnabled(false);
 58 var destination = document.getElementById("destination");
 59 destination.focus();
 60 document.execCommand("InsertText", false, "wellcome!");
 61 window.setTimeout(function() { verify(10); }, 0);
 62}
 63
 64description("Punctuation marks should be treated as whitespace: spelling should ignore them. " +
 65 "To test manually, type 'wellcome!', select 'wellcome!', and context-click on the selection. " +
 66 "The test succeeds when the context menu has spell check suggestions.");
 67if (window.internals)
 68 test();
 69
 70</script>
 71<script src="../../fast/js/resources/js-test-post.js"></script>
 72</body>
 73</html>

LayoutTests/editing/spelling/spelling-with-underscore-selection-expected.txt

 1Underscores should be treated as whitespace: spelling should ignore them. To test manually, type 'Hi, _wellcome_ home.', select '_wellcome_', and context-click on the selection. The test succeeds when the context menu has spell check suggestions.
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6PASS spellingMarkerRange.toString() is "wellcome"
 7PASS window.getSelection().toString() is ""
 8PASS window.getSelection().toString() is "_wellcome_"
 9PASS spellingMarkerRange.toString() is "wellcome"
 10PASS window.getSelection().toString() is "_wellcome_"
 11PASS contextMenuElements[contextMenuElements.length - 1] is "welcome"
 12PASS successfullyParsed is true
 13
 14TEST COMPLETE
 15Hi, _wellcome_ home.

LayoutTests/editing/spelling/spelling-with-underscore-selection.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4<script src="../../fast/js/resources/js-test-pre.js"></script>
 5</head>
 6<body>
 7<div id="container">
 8 <div id="destination" contentEditable></div>
 9</div>
 10
 11<script>
 12
 13function verify(nretry)
 14{
 15 if (!nretry) {
 16 finishJSTest()
 17 return;
 18 }
 19
 20 if (!internals.markerCountForNode(destination.childNodes[0], "spelling")) {
 21 window.setTimeout(function() { verify(nretry - 1); }, 0);
 22 return;
 23 }
 24
 25 spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0);
 26 shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome");
 27 shouldBeEqualToString("window.getSelection().toString()", "");
 28
 29 // Select the text "_wellcome_".
 30 window.getSelection().removeAllRanges();
 31 var rangeWithUnderscores = document.createRange();
 32 rangeWithUnderscores.setStart(destination.childNodes[0], 4);
 33 rangeWithUnderscores.setEnd(destination.childNodes[0], 14);
 34 window.getSelection().addRange(rangeWithUnderscores);
 35 shouldBeEqualToString("window.getSelection().toString()", "_wellcome_");
 36
 37 // Context click on "_wellcome_" to show the context menu.
 38 var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 80;
 39 var y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2;
 40 eventSender.mouseMoveTo(x, y);
 41 contextMenuElements = eventSender.contextClick();
 42 // Esc key to hide the context menu.
 43 eventSender.keyDown(String.fromCharCode(0x001B), null);
 44
 45 spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0);
 46 shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome");
 47 shouldBeEqualToString("window.getSelection().toString()", "_wellcome_");
 48 shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "welcome");
 49
 50 finishJSTest()
 51}
 52
 53function test()
 54{
 55 jsTestIsAsync = true;
 56 internals.settings.setUnifiedTextCheckerEnabled(true);
 57 testRunner.setAsynchronousSpellCheckingEnabled(true);
 58 testRunner.setSmartInsertDeleteEnabled(true);
 59 testRunner.setSelectTrailingWhitespaceEnabled(false);
 60 var destination = document.getElementById("destination");
 61 destination.focus();
 62 document.execCommand("InsertText", false, "Hi, _wellcome_ home.");
 63 window.setTimeout(function() { verify(10); }, 0);
 64}
 65
 66description("Underscores should be treated as whitespace: spelling should ignore them. " +
 67 "To test manually, type 'Hi, _wellcome_ home.', select '_wellcome_', and context-click on the selection. " +
 68 "The test succeeds when the context menu has spell check suggestions.");
 69if (window.internals)
 70 test();
 71
 72</script>
 73<script src="../../fast/js/resources/js-test-post.js"></script>
 74</body>
 75</html>

LayoutTests/editing/spelling/spelling-with-whitespace-selection-expected.txt

 1Spelling should ignore whitespace. To test manually, type 'hello, wellcome home.', select ' wellcome ', and context-click on the selection. The test succeeds when the context menu has spell check suggestions.
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6PASS spellingMarkerRange.toString() is "wellcome"
 7PASS window.getSelection().toString() is " wellcome "
 8PASS spellingMarkerRange.toString() is "wellcome"
 9PASS window.getSelection().toString() is " wellcome "
 10PASS contextMenuElements[contextMenuElements.length - 1] is "welcome"
 11PASS successfullyParsed is true
 12
 13TEST COMPLETE
 14hello, wellcome home.

LayoutTests/editing/spelling/spelling-with-whitespace-selection.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4<script src="../../fast/js/resources/js-test-pre.js"></script>
 5</head>
 6<body>
 7<div id="container">
 8 <div id="destination" contentEditable></div>
 9</div>
 10
 11<script>
 12
 13function verify(nretry)
 14{
 15 if (!nretry) {
 16 finishJSTest()
 17 return;
 18 }
 19
 20 if (!internals.markerCountForNode(destination.childNodes[0], "spelling")) {
 21 window.setTimeout(function() { verify(nretry - 1); }, 0);
 22 return;
 23 }
 24
 25 spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0);
 26 shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome");
 27
 28 window.getSelection().removeAllRanges();
 29 var rangeWithWhitespace = document.createRange();
 30 rangeWithWhitespace.setStart(destination.childNodes[0], 6);
 31 rangeWithWhitespace.setEnd(destination.childNodes[0], 16);
 32 window.getSelection().addRange(rangeWithWhitespace);
 33 shouldBeEqualToString("window.getSelection().toString()", " wellcome ");
 34
 35 var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 80;
 36 var y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2;
 37 eventSender.mouseMoveTo(x, y);
 38 contextMenuElements = eventSender.contextClick();
 39 // esc key to kill the context menu
 40 eventSender.keyDown(String.fromCharCode(0x001B), null);
 41
 42 spellingMarkerRange = internals.markerRangeForNode(destination.childNodes[0], "spelling", 0);
 43 shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome");
 44 shouldBeEqualToString("window.getSelection().toString()", " wellcome ");
 45 shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "welcome");
 46
 47 finishJSTest()
 48}
 49
 50function test()
 51{
 52 jsTestIsAsync = true;
 53 internals.settings.setUnifiedTextCheckerEnabled(true);
 54 testRunner.setAsynchronousSpellCheckingEnabled(true);
 55 testRunner.setSmartInsertDeleteEnabled(true);
 56 testRunner.setSelectTrailingWhitespaceEnabled(false);
 57 var destination = document.getElementById("destination");
 58 destination.focus();
 59 document.execCommand("InsertText", false, "hello, wellcome home.");
 60 window.setTimeout(function() { verify(10); }, 0);
 61}
 62
 63description("Spelling should ignore whitespace. " +
 64 "To test manually, type 'hello, wellcome home.', select ' wellcome ', and context-click on the selection. " +
 65 "The test succeeds when the context menu has spell check suggestions.");
 66if (window.internals)
 67 test();
 68
 69</script>
 70<script src="../../fast/js/resources/js-test-post.js"></script>
 71</body>
 72</html>

Source/WebKit/chromium/ChangeLog

 12013-01-28 Rouslan Solomakhin <rouslan@chromium.org>
 2
 3 Chromium spell check should work with whitespace, punctuation, and multi-word misspellings
 4 https://bugs.webkit.org/show_bug.cgi?id=106815
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Fix Chromium spell checker to behave as follows:
 9 - Chromium selects the misspelled word on context click.
 10 - Spelling should work when the user selects the misspelled word exactly.
 11 - If the word is not misspelled, there should be no spelling options in the context menu.
 12 - Chrome should select multi-word misspellings on context click.
 13 - Spelling should work when the user selects a multi-word misspelling exactly.
 14 - Spelling should work for double-clicked misspellings.
 15 - Spelling should ignore whitespace.
 16 - Underscores should be treated as whitespace: spelling should ignore them.
 17 - Punctuation marks should be treated as whitespace: spelling should ignore them.
 18 - Spelling should be disabled when user selects a part of misspelling.
 19 - Spelling should be disabled when user selects multiple words that are not a single misspelling.
 20
 21 Tests: editing/spelling/spelling-double-clicked-word-with-underscores.html
 22 editing/spelling/spelling-double-clicked-word.html
 23 editing/spelling/spelling-exactly-selected-multiple-words.html
 24 editing/spelling/spelling-exactly-selected-word.html
 25 editing/spelling/spelling-multiword-selection.html
 26 editing/spelling/spelling-should-select-multiple-words.html
 27 editing/spelling/spelling-should-select-single-word.html
 28 editing/spelling/spelling-subword-selection.html
 29 editing/spelling/spelling-with-punctuation-selection.html
 30 editing/spelling/spelling-with-underscore-selection.html
 31 editing/spelling/spelling-with-whitespace-selection.html
 32
 33 * src/ContextMenuClientImpl.cpp:
 34 (WebKit):
 35 (WebKit::IsWhiteSpaceOrPunctuation): New utility function for detecting whitespace and punctuation in selected text.
 36 (WebKit::ContextMenuClientImpl::getCustomMenuFromDefaultItems): Modified to work with whitespace, punctuation, and multi-word misspellings.
 37 * src/WebFrameImpl.cpp:
 38 (WebKit::WebFrameImpl::replaceMisspelledRange): Fixed incorrect range replacement. Chromium will use this method instead of replaceRange.
 39
1402013-01-28 James Craig <james@cookiecrook.com>
241
342 HTML5 promotes DL from specific 'definition list' to superset 'description list'; accessibility strings and accessors should be updated to match.

Source/WebKit/chromium/src/ContextMenuClientImpl.cpp

4040#include "DocumentMarkerController.h"
4141#include "Editor.h"
4242#include "EventHandler.h"
 43#include "ExceptionCodePlaceholder.h"
4344#include "FrameLoader.h"
4445#include "FrameView.h"
4546#include "HTMLFormElement.h"

@@using namespace WebCore;
7879
7980namespace WebKit {
8081
 82// Returns true for whitespace and punctuation characters. Returns false for every other type of character.
 83static bool IsWhiteSpaceOrPunctuation(UChar c)
 84{
 85 return WTF::Unicode::isSeparatorSpace(c) || WTF::Unicode::isPunct(c);
 86}
 87
8188// Figure out the URL of a page or subframe. Returns |page_type| as the type,
8289// which indicates page or subframe, or ContextNodeType::NONE if the URL could not
8390// be determined for some reason.

@@static bool isASingleWord(const String& text)
102109}
103110
104111// Helper function to get misspelled word on which context menu
105 // is to be evolked. This function also sets the word on which context menu
106 // has been evoked to be the selected word, as required. This function changes
 112// is to be invoked. This function also sets the word on which context menu
 113// has been invoked to be the selected word, as required. This function changes
107114// the selection only when there were no selected characters on OS X.
108115static String selectMisspelledWord(const ContextMenu* defaultMenu, Frame* selectedFrame)
109116{

@@PlatformMenuDescription ContextMenuClientImpl::getCustomMenuFromDefaultItems(
274281#endif
275282 // When Chrome enables asynchronous spellchecking, its spellchecker adds spelling markers to misspelled
276283 // words and attaches suggestions to these markers in the background. Therefore, when a user right-clicks
277  // a mouse on a word, Chrome just needs to find a spelling marker on the word instread of spellchecking it.
 284 // a mouse on a word, Chrome just needs to find a spelling marker on the word instead of spellchecking it.
278285 if (selectedFrame->settings() && selectedFrame->settings()->asynchronousSpellCheckingEnabled()) {
279286 VisibleSelection selection = selectedFrame->selection()->selection();
280  bool shouldUpdateSelection = false;
281287 if (selection.isCaretOrRange()) {
282  if (selection.isCaret()) {
283  selection.expandUsingGranularity(WordGranularity);
284  shouldUpdateSelection = true;
285  }
286  RefPtr<Range> range = selection.toNormalizedRange();
287  Vector<DocumentMarker*> markers = selectedFrame->document()->markers()->markersInRange(range.get(), DocumentMarker::Spelling | DocumentMarker::Grammar);
 288 // Caret and range selections always return valid normalized ranges.
 289 RefPtr<Range> selectionRange = selection.toNormalizedRange();
 290 // Cloning a range fails only for invalid ranges.
 291 RefPtr<Range> markerRange = selectionRange->cloneRange(ASSERT_NO_EXCEPTION);
 292 Vector<DocumentMarker*> markers = selectedFrame->document()->markers()->markersInRange(selectionRange.get(), DocumentMarker::Spelling | DocumentMarker::Grammar);
288293 if (markers.size() == 1) {
289  if (markers[0]->startOffset() != static_cast<unsigned>(range->startOffset()) || markers[0]->endOffset() != static_cast<unsigned>(range->endOffset()))
290  markers.clear();
291  }
292  if (markers.size() == 1) {
293  range->setStart(range->startContainer(), markers[0]->startOffset());
294  range->setEnd(range->endContainer(), markers[0]->endOffset());
295  data.misspelledWord = range->text();
296  if (markers[0]->description().length()) {
297  Vector<String> suggestions;
298  markers[0]->description().split('\n', suggestions);
299  data.dictionarySuggestions = suggestions;
300  } else if (m_webView->spellCheckClient()) {
301  int misspelledOffset, misspelledLength;
302  m_webView->spellCheckClient()->spellCheck(data.misspelledWord, misspelledOffset, misspelledLength, &data.dictionarySuggestions);
303  }
304  selection = VisibleSelection(range.get());
305  if (shouldUpdateSelection && selectedFrame->selection()->shouldChangeSelection(selection))
 294 markerRange->setStart(markerRange->startContainer(), markers[0]->startOffset());
 295 markerRange->setEnd(markerRange->endContainer(), markers[0]->endOffset());
 296 // If there is no selection, then select the misspelling.
 297 if (selection.isCaret()) {
 298 selection = VisibleSelection(markerRange.get());
306299 selectedFrame->selection()->setSelection(selection, WordGranularity);
 300 selectionRange.clear();
 301 selectionRange = selection.toNormalizedRange();
 302 }
 303 if (selectionRange->text().stripWhiteSpace(&IsWhiteSpaceOrPunctuation) == markerRange->text().stripWhiteSpace(&IsWhiteSpaceOrPunctuation)) {
 304 data.misspelledWord = markerRange->text();
 305 if (markers[0]->description().length()) {
 306 Vector<String> suggestions;
 307 markers[0]->description().split('\n', suggestions);
 308 data.dictionarySuggestions = suggestions;
 309 } else if (m_webView->spellCheckClient()) {
 310 int misspelledOffset, misspelledLength;
 311 m_webView->spellCheckClient()->spellCheck(data.misspelledWord, misspelledOffset, misspelledLength, &data.dictionarySuggestions);
 312 }
 313 }
307314 }
308315 }
309316 } else {

Source/WebKit/chromium/src/WebFrameImpl.cpp

@@void WebFrameImpl::replaceMisspelledRange(const WebString& text)
12991299 Vector<DocumentMarker*> markers = frame()->document()->markers()->markersInRange(caretRange.get(), DocumentMarker::Spelling | DocumentMarker::Grammar);
13001300 if (markers.size() < 1 || markers[0]->startOffset() >= markers[0]->endOffset())
13011301 return;
1302  RefPtr<Range> markerRange = TextIterator::rangeFromLocationAndLength(frame()->selection()->rootEditableElementOrDocumentElement(), markers[0]->startOffset(), markers[0]->endOffset() - markers[0]->startOffset());
1303  if (!markerRange.get() || !frame()->selection()->shouldChangeSelection(markerRange.get()))
 1302 ExceptionCode exceptionCode;
 1303 RefPtr<Range> markerRange = caretRange->cloneRange(exceptionCode);
 1304 if (!exceptionCode)
 1305 return;
 1306 markerRange->setStart(markerRange->startContainer(), markers[0]->startOffset());
 1307 markerRange->setEnd(markerRange->endContainer(), markers[0]->endOffset());
 1308 if (!frame()->selection()->shouldChangeSelection(markerRange.get()))
13041309 return;
13051310 frame()->selection()->setSelection(markerRange.get(), CharacterGranularity);
1306  frame()->editor()->replaceSelectionWithText(text, false, true);
 1311 frame()->editor()->replaceSelectionWithText(text, false, false);
13071312}
13081313
13091314bool WebFrameImpl::hasSelection() const

Tools/DumpRenderTree/chromium/TestRunner/src/MockSpellCheck.cpp

@@bool MockSpellCheck::spellCheckWord(const WebString& text, int* misspelledOffset
6969 // (This is a simple version of our SpellCheckWordIterator class.)
7070 // If the given string doesn't include any ASCII characters, we can treat the
7171 // string as valid one.
72  // Unfortunately, This implementation splits a contraction, i.e. "isn't" is
73  // split into two pieces "isn" and "t". This is OK because webkit tests
74  // don't have misspelled contractions.
7572 int wordOffset = stringText.find(isASCIIAlpha);
7673 if (wordOffset == -1)
7774 return true;
78  int wordEnd = stringText.find(isNotASCIIAlpha, wordOffset);
79  int wordLength = wordEnd == -1 ? static_cast<int>(stringText.length()) - wordOffset : wordEnd - wordOffset;
 75 int maxWordLength = stringText.length() - wordOffset;
 76 int wordLength;
 77 WTF::String word;
8078
8179 // Look up our misspelled-word table to check if the extracted word is a
8280 // known misspelled word, and return the offset and the length of the
8381 // extracted word if this word is a known misspelled word.
8482 // (See the comment in MockSpellCheck::initializeIfNeeded() why we use a
8583 // misspelled-word table.)
86  WTF::String word = stringText.substring(wordOffset, wordLength);
87  if (m_misspelledWords.contains(word)) {
88  *misspelledOffset = wordOffset + skippedLength;
89  *misspelledLength = wordLength;
90  break;
 84 for (int i = 0; i < m_misspelledWords.size(); ++i) {
 85 wordLength = m_misspelledWords.at(i).length() > maxWordLength ? maxWordLength : m_misspelledWords.at(i).length();
 86 word = stringText.substring(wordOffset, wordLength);
 87 if (word == m_misspelledWords.at(i) && (stringText.length() == wordOffset + wordLength || isNotASCIIAlpha(stringText[wordOffset + wordLength]))) {
 88 *misspelledOffset = wordOffset + skippedLength;
 89 *misspelledLength = wordLength;
 90 break;
 91 }
9192 }
9293
 94 if (*misspelledLength > 0)
 95 break;
 96
 97 int wordEnd = stringText.find(isNotASCIIAlpha, wordOffset);
 98 wordLength = wordEnd == -1 ? static_cast<int>(stringText.length()) - wordOffset : wordEnd - wordOffset;
 99
93100 ASSERT(0 < wordOffset + wordLength);
94101 stringText = stringText.substring(wordOffset + wordLength);
95102 skippedLength += wordOffset + wordLength;

@@bool MockSpellCheck::initializeIfNeeded()
151158 "ifmmp",
152159 "qwertyuiopasd",
153160 "qwertyuiopasdf",
 161 "upper case",
154162 "wellcome"
155163 };
156164
157165 m_misspelledWords.clear();
158166 for (size_t i = 0; i < arraysize(misspelledWords); ++i)
159  m_misspelledWords.add(WTF::String::fromUTF8(misspelledWords[i]), false);
 167 m_misspelledWords.append(WTF::String::fromUTF8(misspelledWords[i]));
160168
161169 // Mark as initialized to prevent this object from being initialized twice
162170 // or more.

Tools/DumpRenderTree/chromium/TestRunner/src/MockSpellCheck.h

3333
3434#include "Platform/chromium/public/WebString.h"
3535#include "Platform/chromium/public/WebVector.h"
36 #include <wtf/HashMap.h>
37 #include <wtf/text/StringHash.h>
 36#include <wtf/Vector.h>
3837#include <wtf/text/WTFString.h>
3938
4039// A mock implementation of a spell-checker used for WebKit tests.

@@private:
7170 bool initializeIfNeeded();
7271
7372 // A table that consists of misspelled words.
74  HashMap<WTF::String, bool> m_misspelledWords;
 73 Vector<WTF::String> m_misspelledWords;
7574
7675 // A flag representing whether or not this object is initialized.
7776 bool m_initialized;