Upstream version 5.34.92.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / editing / spelling / spelling-should-select-single-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("Spell check selects the misspelled word on context click. " +
15             "To test manually, type 'wellcome home.' and context-click on 'wellcome'. " +
16             "The test succeeds when 'wellcome' is selected after the context click.");
17
18 initSpellTest("destination", "wellcome home.", function(textNode) {
19     var behaviors = ["win", "mac"];
20     for (var i = 0; i < behaviors.length; i++) {
21         internals.settings.setEditingBehavior(behaviors[i]);
22
23         spellingMarkerRange = internals.markerRangeForNode(textNode, "spelling", 0);
24         shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome");
25         shouldBeEqualToString("window.getSelection().toString()", "");
26
27         // Context click on "wellcome" to show the context menu.
28         var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 40;
29         var y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2;
30         eventSender.mouseMoveTo(x, y);
31         contextMenuElements = eventSender.contextClick();
32         // Esc key to hide the context menu.
33         eventSender.keyDown(String.fromCharCode(0x001B), null);
34
35         spellingMarkerRange = internals.markerRangeForNode(textNode, "spelling", 0);
36         shouldBeEqualToString("spellingMarkerRange.toString()", "wellcome");
37         shouldBeEqualToString("window.getSelection().toString()", "wellcome");
38         shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "welcome");
39
40         window.getSelection().removeAllRanges();
41         shouldBeEqualToString("window.getSelection().toString()", "");
42
43         // Context click on "home" to show the context menu.
44         var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 80;
45         var y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2;
46         eventSender.mouseMoveTo(x, y);
47         contextMenuElements = eventSender.contextClick();
48         // Esc key to hide the context menu.
49         eventSender.keyDown(String.fromCharCode(0x001B), null);
50
51         // Context click should select correctly spelled words only with "win" editing behavior.
52         if (behaviors[i] == "mac")
53             shouldBeEqualToString("window.getSelection().toString()", "home");
54         else
55             shouldBeEqualToString("window.getSelection().toString()", "");
56         shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "<separator>");
57
58         window.getSelection().removeAllRanges();
59     }
60 });
61
62 </script>
63 </body>
64 </html>