blob: 557ef85cf14bb048ac93dccac093dab250b13699 [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("Spell 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.");
initSpellTest("destination", "wellcome home.", function(textNode) {
var behaviors = ["win", "mac"];
for (var i = 0; i < behaviors.length; i++) {
internals.settings.setEditingBehavior(behaviors[i]);
spellingMarkerRange = internals.markerRangeForNode(textNode, "spelling", 0);
shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome");
shouldBeEqualToString("window.getSelection().toString()", "");
// Context click on "wellcome" to show the context menu.
var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 40;
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()", "wellcome");
shouldBeEqualToString("window.getSelection().toString()", "wellcome");
shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "welcome");
window.getSelection().removeAllRanges();
shouldBeEqualToString("window.getSelection().toString()", "");
// Context click on "home" to show the context menu.
var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 80;
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);
// Context click should select correctly spelled words only with "win" editing behavior.
if (behaviors[i] == "mac")
shouldBeEqualToString("window.getSelection().toString()", "home");
else
shouldBeEqualToString("window.getSelection().toString()", "");
shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "<separator>");
window.getSelection().removeAllRanges();
}
});
</script>
</body>
</html>