4 <meta charset='utf-
8'
/>
5 <title>Native Key Bindings for Cocoa Test
</title>
6 <!-- Any copyright is dedicated to the Public Domain.
7 http://creativecommons.org/publicdomain/zero/1.0/ -->
8 <script type=
"text/javascript"
9 src=
"chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
10 <script type=
"text/javascript"
11 src=
"chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
12 <script type=
"text/javascript"
13 src=
"chrome://mochikit/content/tests/SimpleTest/NativeKeyCodes.js"></script>
16 <div id=
"editable" contenteditable
>
17 <p>Stretching attack nullam stuck in a tree zzz, suspendisse cras nec
18 suspendisse lick suscipit. Nunc egestas amet litter box, nullam climb the
19 curtains biting I don't like that food tristique biting sleep on your
20 keyboard non. Lay down in your way cras nec tempus chase the red dot cras
21 nec, pharetra pharetra eat the grass leap run orci turpis attack.
22 Consectetur sleep in the sink eat I don't like that food, knock over the
23 lamp catnip in viverra tail flick zzz meow etiam enim. Ac ac hiss shed
24 everywhere kittens rhoncus, attack your ankles zzz iaculis kittens. Nullam
25 pellentesque rip the couch iaculis rhoncus nibh, give me fish orci turpis
26 purr sleep on your face quis nunc bibendum.
</p>
28 <p>Neque jump on the table bat iaculis, adipiscing sleep on your keyboard
29 jump vel justo shed everywhere suspendisse lick. Zzz enim faucibus
30 hairball faucibus, pharetra sunbathe biting bat leap rip the couch attack.
31 Tortor nibh in viverra quis hairball nam, vulputate adipiscing sleep on
32 your keyboard purr knock over the lamp orci turpis. Vestibulum I don't
33 like that food et chase the red dot, adipiscing neque bibendum rutrum
34 accumsan quis rhoncus claw. Leap accumsan vehicula enim biting sleep on
35 your face, pharetra nam accumsan egestas kittens sunbathe. Pharetra chase
36 the red dot sniff non eat the grass, vulputate fluffy fur aliquam puking
39 <p>Claw purr sollicitudin sollicitudin lay down in your way consectetur,
40 pellentesque vehicula zzz orci turpis consectetur. I don't like that food
41 rhoncus pellentesque sniff attack, rhoncus tortor attack your ankles
42 iaculis scratched hiss vel. Tortor zzz tortor nullam rip the couch rutrum,
43 bat enim ut leap hairball iaculis. Bibendum sunbathe elit suspendisse
44 nibh, puking adipiscing sleep on your face sleep on your face zzz catnip.
45 Judging you rutrum bat sunbathe sleep on your face, jump on the table leap
46 tincidunt a faucibus sleep in the sink. Stuck in a tree tristique zzz hiss
47 in viverra nullam, quis tortor pharetra attack.
</p>
50 <textarea id=
"textarea" cols=
"80">
51 Stretching attack nullam stuck in a tree zzz, suspendisse cras nec
52 suspendisse lick suscipit. Nunc egestas amet litter box, nullam climb the
53 curtains biting I don't like that food tristique biting sleep on your
54 keyboard non. Lay down in your way cras nec tempus chase the red dot cras
55 nec, pharetra pharetra eat the grass leap run orci turpis attack.
56 Consectetur sleep in the sink eat I don't like that food, knock over the
57 lamp catnip in viverra tail flick zzz meow etiam enim. Ac ac hiss shed
58 everywhere kittens rhoncus, attack your ankles zzz iaculis kittens. Nullam
59 pellentesque rip the couch iaculis rhoncus nibh, give me fish orci turpis
60 purr sleep on your face quis nunc bibendum.
62 Neque jump on the table bat iaculis, adipiscing sleep on your keyboard
63 jump vel justo shed everywhere suspendisse lick. Zzz enim faucibus
64 hairball faucibus, pharetra sunbathe biting bat leap rip the couch attack.
65 Tortor nibh in viverra quis hairball nam, vulputate adipiscing sleep on
66 your keyboard purr knock over the lamp orci turpis. Vestibulum I don't
67 like that food et chase the red dot, adipiscing neque bibendum rutrum
68 accumsan quis rhoncus claw. Leap accumsan vehicula enim biting sleep on
69 your face, pharetra nam accumsan egestas kittens sunbathe. Pharetra chase
70 the red dot sniff non eat the grass, vulputate fluffy fur aliquam puking
73 Claw purr sollicitudin sollicitudin lay down in your way consectetur,
74 pellentesque vehicula zzz orci turpis consectetur. I don't like that food
75 rhoncus pellentesque sniff attack, rhoncus tortor attack your ankles
76 iaculis scratched hiss vel. Tortor zzz tortor nullam rip the couch rutrum,
77 bat enim ut leap hairball iaculis. Bibendum sunbathe elit suspendisse
78 nibh, puking adipiscing sleep on your face sleep on your face zzz catnip.
79 Judging you rutrum bat sunbathe sleep on your face, jump on the table leap
80 tincidunt a faucibus sleep in the sink. Stuck in a tree tristique zzz hiss
81 in viverra nullam, quis tortor pharetra attack.
84 <input id=
"input" type=
"text"
85 value=
"Stretching attack nullam stuck in a tree zzz, suspendisse cras nec
86 suspendisse lick suscipit. Nunc egestas amet litter box, nullam climb the
87 curtains biting I don't like that food tristique biting sleep on your
88 keyboard non. Lay down in your way cras nec tempus chase the red dot cras
89 nec, pharetra pharetra eat the grass leap run orci turpis attack.
90 Consectetur sleep in the sink eat I don't like that food, knock over the
91 lamp catnip in viverra tail flick zzz meow etiam enim. Ac ac hiss shed
92 everywhere kittens rhoncus, attack your ankles zzz iaculis kittens.
93 Nullam pellentesque rip the couch iaculis rhoncus nibh, give me fish orci
94 turpis purr sleep on your face quis nunc bibendum.">
96 <script type=
"text/javascript;version=1.8">
97 SimpleTest.waitForExplicitFinish();
99 let synthesizedKeys = [];
100 let expectations = [];
102 // Move to beginning of line
103 synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_LeftArrow,
104 {ctrlKey: true},
"\uf702",
"\uf702"]);
111 // Move to end of line
112 synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_RightArrow,
113 {ctrlKey: true},
"\uf703",
"\uf703"]);
121 synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_N,
122 {ctrlKey: true},
"\u000e",
"n"]);
124 editable: [
140,
140],
125 textarea: [
145,
145],
129 // Move to beginning of line
130 synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_LeftArrow,
131 {ctrlKey: true},
"\uf702",
"\uf702"]);
138 // Move word right and modify selection
139 synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_RightArrow,
140 {altKey: true, shiftKey: true},
"\uf703",
"\uf703"]);
148 synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_RightArrow,
149 {altKey: true},
"\uf703",
"\uf703"]);
157 synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_RightArrow,
158 {altKey: true},
"\uf703",
"\uf703"]);
165 // Move down and modify selection
166 synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_DownArrow,
167 {shiftKey: true},
"\uf701",
"\uf701"]);
174 // Move backward and modify selection
175 synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_B,
176 {ctrlKey: true, shiftKey: true},
"\u0002",
"B"]);
184 synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_D,
185 {ctrlKey: true},
"\u0004",
"d"]);
193 synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_H,
194 {ctrlKey: true},
"\u0008",
"h"]);
202 synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_B,
203 {ctrlKey: true},
"\u0002",
"b"]);
210 // Move to beginning of paragraph (line for now)
211 synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_A,
212 {ctrlKey: true},
"\u0001",
"a"]);
220 synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_F,
221 {ctrlKey: true},
"\u0006",
"f"]);
229 synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_RightArrow,
230 {altKey: true},
"\uf703",
"\uf703"]);
238 synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_RightArrow,
239 {altKey: true},
"\uf703",
"\uf703"]);
246 // Delete to end of paragraph (line for now)
247 synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_K,
248 {ctrlKey: true},
"\u000b",
"k"]);
255 // Move backward and modify selection
256 synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_B,
257 {ctrlKey: true, shiftKey: true},
"\u0002",
"B"]);
264 // Move to end of paragraph (line for now)
265 synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_E,
266 {ctrlKey: true},
"\u0005",
"e"]);
268 editable: [
144,
144],
274 synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_P,
275 {ctrlKey: true},
"\u0010",
"p"]);
282 function checkWindowSelection(aElement, aSelection)
284 let selection = window.getSelection();
286 is(selection.anchorOffset, aSelection[aElement.id][
0],
287 aElement.id +
": Incorrect anchor offset");
288 is(selection.focusOffset, aSelection[aElement.id][
1],
289 aElement.id +
": Incorrect focus offset");
292 function checkElementSelection(aElement, aSelection)
294 is(aElement.selectionStart, aSelection[aElement.id][
0],
295 aElement.id +
": Incorrect selection start");
296 is(aElement.selectionEnd, aSelection[aElement.id][
1],
297 aElement.id +
": Incorrect selection end");
300 function testRun(aElement, aSelectionCheck)
302 if (document.activeElement) {
303 document.activeElement.blur();
308 for (let i =
0; i < synthesizedKeys.length; i++) {
309 synthesizeNativeKey.apply(null, synthesizedKeys[i]);
310 aSelectionCheck.call(null, aElement, expectations[i]);
316 testRun(document.getElementById(
"editable"), checkWindowSelection);
317 testRun(document.getElementById(
"textarea"), checkElementSelection);
318 testRun(document.getElementById(
"input"), checkElementSelection);
323 SimpleTest.waitForFocus(doTest);