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 misspellings. " +
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 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 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();
62 shouldBeEqualToString("window.getSelection().toString()", "wellcome ");
64 // Context click on "wellcome " to show the context menu.
65 x
= destination
.offsetParent
.offsetLeft
+ destination
.offsetLeft
+ 40;
66 y
= destination
.offsetParent
.offsetTop
+ destination
.offsetTop
+ destination
.offsetHeight
/ 2;
67 eventSender
.mouseMoveTo(x
, y
);
68 contextMenuElements
= eventSender
.contextClick();
69 // Esc key to hide the context menu.
70 eventSender
.keyDown("escape", null);
72 spellingMarkerRange
= internals
.markerRangeForNode(textNode
, "spelling", 0);
73 shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome");
74 shouldBeEqualToString("window.getSelection().toString()", "wellcome ");
75 shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "welcome");