4 <script src=
"../../resources/js-test.js"></script>
5 <script src=
"resources/util.js"></script>
9 <div id=
"destination" contentEditable
></div>
14 description("Underscores should be treated as whitespace: spelling should ignore them. " +
15 "To test manually, type 'Hi, _wellcome_ home.', select '_wellcome_', and context-click on the selection. " +
16 "The test succeeds when the context menu has spell check suggestions.");
18 initSpellTest("destination", "Hi, _wellcome_ home.", function(textNode
) {
19 spellingMarkerRange
= internals
.markerRangeForNode(textNode
, "spelling", 0);
20 shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome");
21 shouldBeEqualToString("window.getSelection().toString()", "");
23 // Select the text "_wellcome_".
24 var rangeWithUnderscores
= document
.createRange();
25 rangeWithUnderscores
.setStart(textNode
, 4);
26 rangeWithUnderscores
.setEnd(textNode
, 14);
27 window
.getSelection().removeAllRanges();
28 window
.getSelection().addRange(rangeWithUnderscores
);
30 shouldBeEqualToString("window.getSelection().toString()", "_wellcome_");
32 // Context click on "_wellcome_" to show the context menu.
33 var x
= destination
.offsetParent
.offsetLeft
+ destination
.offsetLeft
+ 80;
34 var y
= destination
.offsetParent
.offsetTop
+ destination
.offsetTop
+ destination
.offsetHeight
/ 2;
35 eventSender
.mouseMoveTo(x
, y
);
36 contextMenuElements
= eventSender
.contextClick();
37 // Esc key to hide the context menu.
38 eventSender
.keyDown("escape", null);
40 spellingMarkerRange
= internals
.markerRangeForNode(textNode
, "spelling", 0);
41 shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome");
42 shouldBeEqualToString("window.getSelection().toString()", "_wellcome_");
43 shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "welcome");