OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../../resources/js-test.js"></script> | 4 <script src="../../resources/js-test.js"></script> |
5 <script src="resources/util.js"></script> | 5 <script src="resources/util.js"></script> |
6 </head> | 6 </head> |
7 <body> | 7 <body> |
8 <div id="container"> | 8 <div id="container"> |
9 <input type="text" id="destination"/> | 9 <input type="text" id="destination"/> |
10 </div> | 10 </div> |
11 | 11 |
12 <script> | 12 <script> |
13 | 13 |
14 description("Spell check selects the misspelled word on context click in an inpu
t field. " + | 14 description("Spell check selects the misspelled word on context click in an inpu
t field. " + |
15 "To test manually, type 'wellcome home.' and context-click on 'wellc
ome'. " + | 15 "To test manually, type 'wellcome home.' and context-click on 'wellc
ome'. " + |
16 "The test succeeds when 'wellcome' is selected after the context cli
ck."); | 16 "The test succeeds when 'wellcome' is selected after the context cli
ck."); |
17 | 17 |
18 initSpellTest("destination", "wellcome home.", function(textNode) { | 18 initSpellTest("destination", "wellcome home.", function(textNode) { |
19 var behaviors = ["win", "mac"]; | 19 var behaviors = ["win", "mac"]; |
20 for (var i = 0; i < behaviors.length; i++) { | 20 for (var i = 0; i < behaviors.length; i++) { |
21 internals.settings.setEditingBehavior(behaviors[i]); | 21 internals.settings.setEditingBehavior(behaviors[i]); |
22 | 22 |
23 // Context click on "wellcome" to show the context menu. | 23 // Context click on "wellcome" to show the context menu. |
24 var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 4
0; | 24 var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 4
0; |
25 var y = destination.offsetParent.offsetTop + destination.offsetTop + des
tination.offsetHeight / 2; | 25 var y = destination.offsetParent.offsetTop + destination.offsetTop + des
tination.offsetHeight / 2; |
26 eventSender.mouseMoveTo(x, y); | 26 eventSender.mouseMoveTo(x, y); |
27 eventSender.contextClick(); | 27 eventSender.contextClick(); |
28 // Esc key to hide the context menu. | 28 // Esc key to hide the context menu. |
29 eventSender.keyDown(String.fromCharCode(0x001B), null); | 29 eventSender.keyDown("escape", null); |
30 | 30 |
31 shouldBeEqualToString("window.getSelection().toString()", "wellcome"); | 31 shouldBeEqualToString("window.getSelection().toString()", "wellcome"); |
32 window.getSelection().removeAllRanges(); | 32 window.getSelection().removeAllRanges(); |
33 | 33 |
34 // Context click on "home" to show the context menu. | 34 // Context click on "home" to show the context menu. |
35 var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 8
0; | 35 var x = destination.offsetParent.offsetLeft + destination.offsetLeft + 8
0; |
36 var y = destination.offsetParent.offsetTop + destination.offsetTop + des
tination.offsetHeight / 2; | 36 var y = destination.offsetParent.offsetTop + destination.offsetTop + des
tination.offsetHeight / 2; |
37 eventSender.mouseMoveTo(x, y); | 37 eventSender.mouseMoveTo(x, y); |
38 eventSender.contextClick(); | 38 eventSender.contextClick(); |
39 // Esc key to hide the context menu. | 39 // Esc key to hide the context menu. |
40 eventSender.keyDown(String.fromCharCode(0x001B), null); | 40 eventSender.keyDown("escape", null); |
41 | 41 |
42 // Context click should select correctly spelled words only with "win" e
diting behavior. | 42 // Context click should select correctly spelled words only with "win" e
diting behavior. |
43 if (behaviors[i] == "mac") | 43 if (behaviors[i] == "mac") |
44 shouldBeEqualToString("window.getSelection().toString()", "home"); | 44 shouldBeEqualToString("window.getSelection().toString()", "home"); |
45 else | 45 else |
46 shouldBeEqualToString("window.getSelection().toString()", ""); | 46 shouldBeEqualToString("window.getSelection().toString()", ""); |
47 window.getSelection().removeAllRanges(); | 47 window.getSelection().removeAllRanges(); |
48 } | 48 } |
49 }); | 49 }); |
50 | 50 |
51 </script> | 51 </script> |
52 </body> | 52 </body> |
53 </html> | 53 </html> |
OLD | NEW |