4 <script src=
"../../resources/js-test.js"></script>
5 <script src=
"resources/util.js"></script>
9 <div id=
"destination" contentEditable
></div>
14 description("Spelling should work for double-clicked misspelled words with underscores. " +
15 "To test manually, type 'wellcome_ home.', double-click on 'wellcome_', and context-click on the selection. " +
16 "The test succeeds when the context menu shows spell check suggestions.");
18 initSpellTest("destination", "wellcome_ home.", function(textNode
) {
19 spellingMarkerRange
= internals
.markerRangeForNode(textNode
, "spelling", 0);
20 shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome");
21 shouldBeEqualToString("window.getSelection().toString()", "");
23 // Double-click the misspelled word without the trailing whitespace.
24 internals
.settings
.setSmartInsertDeleteEnabled(true);
25 internals
.settings
.setSelectTrailingWhitespaceEnabled(false);
26 var x
= destination
.offsetParent
.offsetLeft
+ destination
.offsetLeft
+ 40;
27 var y
= destination
.offsetParent
.offsetTop
+ destination
.offsetTop
+ destination
.offsetHeight
/ 2;
28 eventSender
.mouseMoveTo(x
, y
);
29 eventSender
.mouseDown();
30 eventSender
.mouseUp();
31 eventSender
.mouseDown();
32 eventSender
.mouseUp();
34 shouldBeEqualToString("window.getSelection().toString()", "wellcome_");
36 // Context click on "wellcome_" to show the context menu.
37 x
= destination
.offsetParent
.offsetLeft
+ destination
.offsetLeft
+ 40;
38 y
= destination
.offsetParent
.offsetTop
+ destination
.offsetTop
+ destination
.offsetHeight
/ 2;
39 eventSender
.mouseMoveTo(x
, y
);
40 contextMenuElements
= eventSender
.contextClick();
41 // Esc key to hide the context menu.
42 eventSender
.keyDown("escape", null);
44 spellingMarkerRange
= internals
.markerRangeForNode(textNode
, "spelling", 0);
45 shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome");
46 shouldBeEqualToString("window.getSelection().toString()", "wellcome_");
47 shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "welcome");
49 window
.getSelection().removeAllRanges();
50 shouldBeEqualToString("window.getSelection().toString()", "");
52 // Double-click the misspelled word with the trailing whitespace.
53 internals
.settings
.setSmartInsertDeleteEnabled(false);
54 internals
.settings
.setSelectTrailingWhitespaceEnabled(true);
55 var x
= destination
.offsetParent
.offsetLeft
+ destination
.offsetLeft
+ 40;
56 var y
= destination
.offsetParent
.offsetTop
+ destination
.offsetTop
+ destination
.offsetHeight
/ 2;
57 eventSender
.mouseMoveTo(x
, y
);
58 eventSender
.mouseDown();
59 eventSender
.mouseUp();
60 eventSender
.mouseDown();
61 eventSender
.mouseUp();
63 shouldBeEqualToString("window.getSelection().toString()", "wellcome_ ");
65 // Context click on "wellcome_ " to show the context menu.
66 x
= destination
.offsetParent
.offsetLeft
+ destination
.offsetLeft
+ 40;
67 y
= destination
.offsetParent
.offsetTop
+ destination
.offsetTop
+ destination
.offsetHeight
/ 2;
68 eventSender
.mouseMoveTo(x
, y
);
69 contextMenuElements
= eventSender
.contextClick();
70 // Esc key to hide the context menu.
71 eventSender
.keyDown("escape", null);
73 spellingMarkerRange
= internals
.markerRangeForNode(textNode
, "spelling", 0);
74 shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome");
75 shouldBeEqualToString("window.getSelection().toString()", "wellcome_ ");
76 shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "welcome");