4 <script src=
"../../resources/js-test.js"></script>
5 <script src=
"resources/util.js"></script>
9 <div id=
"destination" contentEditable
></div>
14 description("Spell check selects the misspelled word on context click. " +
15 "To test manually, type 'wellcome home.' and context-click on 'wellcome'. " +
16 "The test succeeds when 'wellcome' is selected after the context click.");
18 initSpellTest("destination", "wellcome home.", function(textNode
) {
19 var behaviors
= ["win", "mac"];
20 for (var i
= 0; i
< behaviors
.length
; i
++) {
21 internals
.settings
.setEditingBehavior(behaviors
[i
]);
23 spellingMarkerRange
= internals
.markerRangeForNode(textNode
, "spelling", 0);
24 shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome");
25 shouldBeEqualToString("window.getSelection().toString()", "");
27 // Context click on "wellcome" to show the context menu.
28 var x
= destination
.offsetParent
.offsetLeft
+ destination
.offsetLeft
+ 40;
29 var y
= destination
.offsetParent
.offsetTop
+ destination
.offsetTop
+ destination
.offsetHeight
/ 2;
30 eventSender
.mouseMoveTo(x
, y
);
31 contextMenuElements
= eventSender
.contextClick();
32 // Esc key to hide the context menu.
33 eventSender
.keyDown("escape", null);
35 spellingMarkerRange
= internals
.markerRangeForNode(textNode
, "spelling", 0);
36 shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome");
37 shouldBeEqualToString("window.getSelection().toString()", "wellcome");
38 shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "welcome");
40 window
.getSelection().removeAllRanges();
41 shouldBeEqualToString("window.getSelection().toString()", "");
43 // Context click on "home" to show the context menu.
44 var x
= destination
.offsetParent
.offsetLeft
+ destination
.offsetLeft
+ 80;
45 var 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("escape", null);
51 // Context click should select correctly spelled words only with "win" editing behavior.
52 if (behaviors
[i
] == "mac")
53 shouldBeEqualToString("window.getSelection().toString()", "home");
55 shouldBeEqualToString("window.getSelection().toString()", "");
56 shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "<separator>");
58 window
.getSelection().removeAllRanges();