blob: 37f574289a94a3c6cf915664546da8ca8b7adff9 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test.js"></script>
<script src="resources/util.js"></script>
</head>
<body>
<div id="container">
<div id="destination" contentEditable></div>
</div>
<script>
description("Spelling 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.");
initSpellTest("destination", "It should be upper case.", function(textNode) {
spellingMarkerRange = internals.markerRangeForNode(textNode, "spelling", 0);
shouldBeEqualToString("spellingMarkerRange.toString()", "upper case");
shouldBeEqualToString("window.getSelection().toString()", "");
// Select the multi-word misspelling without surrounding whitespace or punctuation.
var wordRange = document.createRange();
wordRange.setStart(textNode, 13);
wordRange.setEnd(textNode, 23);
window.getSelection().removeAllRanges();
window.getSelection().addRange(wordRange);
shouldBeEqualToString("window.getSelection().toString()", "upper case");
// Context click on "upper case" to show the context menu.
var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 100;
var y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2;
eventSender.mouseMoveTo(x, y);
contextMenuElements = eventSender.contextClick();
// Esc key to hide the context menu.
eventSender.keyDown("escape", null);
spellingMarkerRange = internals.markerRangeForNode(textNode, "spelling", 0);
shouldBeEqualToString("spellingMarkerRange.toString()", "upper case");
shouldBeEqualToString("window.getSelection().toString()", "upper case");
shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "uppercase");
});
</script>
</body>
</html>