Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / editing / spelling / spelling-double-clicked-word.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../resources/js-test.js"></script>
5 <script src="resources/util.js"></script>
6 </head>
7 <body>
8 <div id="container">
9   <div id="destination" contentEditable></div>
10 </div>
11
12 <script>
13
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.");
17
18 initSpellTest("destination", "wellcome home.", function(textNode) {
19     spellingMarkerRange = internals.markerRangeForNode(textNode, "spelling", 0);
20     shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome");
21     shouldBeEqualToString("window.getSelection().toString()", "");
22
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();
33
34     shouldBeEqualToString("window.getSelection().toString()", "wellcome");
35
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);
43
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");
48
49     window.getSelection().removeAllRanges();
50     shouldBeEqualToString("window.getSelection().toString()", "");
51
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 ");
63
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);
71
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");
76 });
77
78 </script>
79 </body>
80 </html>