Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / editing / spelling / input-type-text.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   <input type="text" id="destination"/>
10 </div>
11
12 <script>
13
14 description("Spell check selects the misspelled word on context click in an input field. " +
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         // Context click on "wellcome" to show the context menu.
24         var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 40;
25         var y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2;
26         eventSender.mouseMoveTo(x, y);
27         eventSender.contextClick();
28         // Esc key to hide the context menu.
29         eventSender.keyDown("escape", null);
30
31         shouldBeEqualToString("window.getSelection().toString()", "wellcome");
32         window.getSelection().removeAllRanges();
33
34         // Context click on "home" to show the context menu.
35         var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 80;
36         var y = destination.offsetParent.offsetTop + destination.offsetTop + destination.offsetHeight / 2;
37         eventSender.mouseMoveTo(x, y);
38         eventSender.contextClick();
39         // Esc key to hide the context menu.
40         eventSender.keyDown("escape", null);
41
42         // Context click should select correctly spelled words only with "win" editing behavior.
43         if (behaviors[i] == "mac")
44             shouldBeEqualToString("window.getSelection().toString()", "home");
45         else
46             shouldBeEqualToString("window.getSelection().toString()", "");
47         window.getSelection().removeAllRanges();
48     }
49 });
50
51 </script>
52 </body>
53 </html>