4 <script src=
"../../resources/js-test.js"></script>
5 <script src=
"resources/util.js"></script>
9 <div id=
"destination" contentEditable
></div>
13 description("Spelling should work when the user selects a multi-word misspelling exactly. " +
14 "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." +
15 "The test succeeds when the context menu shows spelling suggestions.");
17 initSpellTest("destination", "It should be upper case.", function(textNode
) {
18 spellingMarkerRange
= internals
.markerRangeForNode(textNode
, "spelling", 0);
19 shouldBeEqualToString("spellingMarkerRange.toString()", "upper case");
20 shouldBeEqualToString("window.getSelection().toString()", "");
22 // Select the multi-word misspelling without surrounding whitespace or punctuation.
23 var wordRange
= document
.createRange();
24 wordRange
.setStart(textNode
, 13);
25 wordRange
.setEnd(textNode
, 23);
26 window
.getSelection().removeAllRanges();
27 window
.getSelection().addRange(wordRange
);
29 shouldBeEqualToString("window.getSelection().toString()", "upper case");
31 // Context click on "upper case" to show the context menu.
32 var x
= destination
.offsetParent
.offsetLeft
+ destination
.offsetLeft
+ 100;
33 var y
= destination
.offsetParent
.offsetTop
+ destination
.offsetTop
+ destination
.offsetHeight
/ 2;
34 eventSender
.mouseMoveTo(x
, y
);
35 contextMenuElements
= eventSender
.contextClick();
36 // Esc key to hide the context menu.
37 eventSender
.keyDown("escape", null);
39 spellingMarkerRange
= internals
.markerRangeForNode(textNode
, "spelling", 0);
40 shouldBeEqualToString("spellingMarkerRange.toString()", "upper case");
41 shouldBeEqualToString("window.getSelection().toString()", "upper case");
42 shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "uppercase");