Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <head> |
michael@0 | 4 | <meta charset='utf-8'/> |
michael@0 | 5 | <title>Native Key Bindings for Cocoa Test</title> |
michael@0 | 6 | <!-- Any copyright is dedicated to the Public Domain. |
michael@0 | 7 | http://creativecommons.org/publicdomain/zero/1.0/ --> |
michael@0 | 8 | <script type="text/javascript" |
michael@0 | 9 | src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 10 | <script type="text/javascript" |
michael@0 | 11 | src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> |
michael@0 | 12 | <script type="text/javascript" |
michael@0 | 13 | src="chrome://mochikit/content/tests/SimpleTest/NativeKeyCodes.js"></script> |
michael@0 | 14 | </head> |
michael@0 | 15 | <body> |
michael@0 | 16 | <div id="editable" contenteditable> |
michael@0 | 17 | <p>Stretching attack nullam stuck in a tree zzz, suspendisse cras nec |
michael@0 | 18 | suspendisse lick suscipit. Nunc egestas amet litter box, nullam climb the |
michael@0 | 19 | curtains biting I don't like that food tristique biting sleep on your |
michael@0 | 20 | keyboard non. Lay down in your way cras nec tempus chase the red dot cras |
michael@0 | 21 | nec, pharetra pharetra eat the grass leap run orci turpis attack. |
michael@0 | 22 | Consectetur sleep in the sink eat I don't like that food, knock over the |
michael@0 | 23 | lamp catnip in viverra tail flick zzz meow etiam enim. Ac ac hiss shed |
michael@0 | 24 | everywhere kittens rhoncus, attack your ankles zzz iaculis kittens. Nullam |
michael@0 | 25 | pellentesque rip the couch iaculis rhoncus nibh, give me fish orci turpis |
michael@0 | 26 | purr sleep on your face quis nunc bibendum.</p> |
michael@0 | 27 | |
michael@0 | 28 | <p>Neque jump on the table bat iaculis, adipiscing sleep on your keyboard |
michael@0 | 29 | jump vel justo shed everywhere suspendisse lick. Zzz enim faucibus |
michael@0 | 30 | hairball faucibus, pharetra sunbathe biting bat leap rip the couch attack. |
michael@0 | 31 | Tortor nibh in viverra quis hairball nam, vulputate adipiscing sleep on |
michael@0 | 32 | your keyboard purr knock over the lamp orci turpis. Vestibulum I don't |
michael@0 | 33 | like that food et chase the red dot, adipiscing neque bibendum rutrum |
michael@0 | 34 | accumsan quis rhoncus claw. Leap accumsan vehicula enim biting sleep on |
michael@0 | 35 | your face, pharetra nam accumsan egestas kittens sunbathe. Pharetra chase |
michael@0 | 36 | the red dot sniff non eat the grass, vulputate fluffy fur aliquam puking |
michael@0 | 37 | judging you.</p> |
michael@0 | 38 | |
michael@0 | 39 | <p>Claw purr sollicitudin sollicitudin lay down in your way consectetur, |
michael@0 | 40 | pellentesque vehicula zzz orci turpis consectetur. I don't like that food |
michael@0 | 41 | rhoncus pellentesque sniff attack, rhoncus tortor attack your ankles |
michael@0 | 42 | iaculis scratched hiss vel. Tortor zzz tortor nullam rip the couch rutrum, |
michael@0 | 43 | bat enim ut leap hairball iaculis. Bibendum sunbathe elit suspendisse |
michael@0 | 44 | nibh, puking adipiscing sleep on your face sleep on your face zzz catnip. |
michael@0 | 45 | Judging you rutrum bat sunbathe sleep on your face, jump on the table leap |
michael@0 | 46 | tincidunt a faucibus sleep in the sink. Stuck in a tree tristique zzz hiss |
michael@0 | 47 | in viverra nullam, quis tortor pharetra attack.</p> |
michael@0 | 48 | </div> |
michael@0 | 49 | |
michael@0 | 50 | <textarea id="textarea" cols="80"> |
michael@0 | 51 | Stretching attack nullam stuck in a tree zzz, suspendisse cras nec |
michael@0 | 52 | suspendisse lick suscipit. Nunc egestas amet litter box, nullam climb the |
michael@0 | 53 | curtains biting I don't like that food tristique biting sleep on your |
michael@0 | 54 | keyboard non. Lay down in your way cras nec tempus chase the red dot cras |
michael@0 | 55 | nec, pharetra pharetra eat the grass leap run orci turpis attack. |
michael@0 | 56 | Consectetur sleep in the sink eat I don't like that food, knock over the |
michael@0 | 57 | lamp catnip in viverra tail flick zzz meow etiam enim. Ac ac hiss shed |
michael@0 | 58 | everywhere kittens rhoncus, attack your ankles zzz iaculis kittens. Nullam |
michael@0 | 59 | pellentesque rip the couch iaculis rhoncus nibh, give me fish orci turpis |
michael@0 | 60 | purr sleep on your face quis nunc bibendum. |
michael@0 | 61 | |
michael@0 | 62 | Neque jump on the table bat iaculis, adipiscing sleep on your keyboard |
michael@0 | 63 | jump vel justo shed everywhere suspendisse lick. Zzz enim faucibus |
michael@0 | 64 | hairball faucibus, pharetra sunbathe biting bat leap rip the couch attack. |
michael@0 | 65 | Tortor nibh in viverra quis hairball nam, vulputate adipiscing sleep on |
michael@0 | 66 | your keyboard purr knock over the lamp orci turpis. Vestibulum I don't |
michael@0 | 67 | like that food et chase the red dot, adipiscing neque bibendum rutrum |
michael@0 | 68 | accumsan quis rhoncus claw. Leap accumsan vehicula enim biting sleep on |
michael@0 | 69 | your face, pharetra nam accumsan egestas kittens sunbathe. Pharetra chase |
michael@0 | 70 | the red dot sniff non eat the grass, vulputate fluffy fur aliquam puking |
michael@0 | 71 | judging you. |
michael@0 | 72 | |
michael@0 | 73 | Claw purr sollicitudin sollicitudin lay down in your way consectetur, |
michael@0 | 74 | pellentesque vehicula zzz orci turpis consectetur. I don't like that food |
michael@0 | 75 | rhoncus pellentesque sniff attack, rhoncus tortor attack your ankles |
michael@0 | 76 | iaculis scratched hiss vel. Tortor zzz tortor nullam rip the couch rutrum, |
michael@0 | 77 | bat enim ut leap hairball iaculis. Bibendum sunbathe elit suspendisse |
michael@0 | 78 | nibh, puking adipiscing sleep on your face sleep on your face zzz catnip. |
michael@0 | 79 | Judging you rutrum bat sunbathe sleep on your face, jump on the table leap |
michael@0 | 80 | tincidunt a faucibus sleep in the sink. Stuck in a tree tristique zzz hiss |
michael@0 | 81 | in viverra nullam, quis tortor pharetra attack. |
michael@0 | 82 | </textarea> |
michael@0 | 83 | |
michael@0 | 84 | <input id="input" type="text" |
michael@0 | 85 | value="Stretching attack nullam stuck in a tree zzz, suspendisse cras nec |
michael@0 | 86 | suspendisse lick suscipit. Nunc egestas amet litter box, nullam climb the |
michael@0 | 87 | curtains biting I don't like that food tristique biting sleep on your |
michael@0 | 88 | keyboard non. Lay down in your way cras nec tempus chase the red dot cras |
michael@0 | 89 | nec, pharetra pharetra eat the grass leap run orci turpis attack. |
michael@0 | 90 | Consectetur sleep in the sink eat I don't like that food, knock over the |
michael@0 | 91 | lamp catnip in viverra tail flick zzz meow etiam enim. Ac ac hiss shed |
michael@0 | 92 | everywhere kittens rhoncus, attack your ankles zzz iaculis kittens. |
michael@0 | 93 | Nullam pellentesque rip the couch iaculis rhoncus nibh, give me fish orci |
michael@0 | 94 | turpis purr sleep on your face quis nunc bibendum."> |
michael@0 | 95 | |
michael@0 | 96 | <script type="text/javascript;version=1.8"> |
michael@0 | 97 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 98 | |
michael@0 | 99 | let synthesizedKeys = []; |
michael@0 | 100 | let expectations = []; |
michael@0 | 101 | |
michael@0 | 102 | // Move to beginning of line |
michael@0 | 103 | synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_LeftArrow, |
michael@0 | 104 | {ctrlKey: true}, "\uf702", "\uf702"]); |
michael@0 | 105 | expectations.push({ |
michael@0 | 106 | editable: [0, 0], |
michael@0 | 107 | textarea: [0, 0], |
michael@0 | 108 | input: [0, 0] |
michael@0 | 109 | }); |
michael@0 | 110 | |
michael@0 | 111 | // Move to end of line |
michael@0 | 112 | synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_RightArrow, |
michael@0 | 113 | {ctrlKey: true}, "\uf703", "\uf703"]); |
michael@0 | 114 | expectations.push({ |
michael@0 | 115 | editable: [73, 73], |
michael@0 | 116 | textarea: [72, 72], |
michael@0 | 117 | input: [732, 732] |
michael@0 | 118 | }); |
michael@0 | 119 | |
michael@0 | 120 | // Move down |
michael@0 | 121 | synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_N, |
michael@0 | 122 | {ctrlKey: true}, "\u000e", "n"]); |
michael@0 | 123 | expectations.push({ |
michael@0 | 124 | editable: [140, 140], |
michael@0 | 125 | textarea: [145, 145], |
michael@0 | 126 | input: [732, 732] |
michael@0 | 127 | }); |
michael@0 | 128 | |
michael@0 | 129 | // Move to beginning of line |
michael@0 | 130 | synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_LeftArrow, |
michael@0 | 131 | {ctrlKey: true}, "\uf702", "\uf702"]); |
michael@0 | 132 | expectations.push({ |
michael@0 | 133 | editable: [73, 73], |
michael@0 | 134 | textarea: [73, 73], |
michael@0 | 135 | input: [0, 0] |
michael@0 | 136 | }); |
michael@0 | 137 | |
michael@0 | 138 | // Move word right and modify selection |
michael@0 | 139 | synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_RightArrow, |
michael@0 | 140 | {altKey: true, shiftKey: true}, "\uf703", "\uf703"]); |
michael@0 | 141 | expectations.push({ |
michael@0 | 142 | editable: [73, 84], |
michael@0 | 143 | textarea: [73, 90], |
michael@0 | 144 | input: [0, 10] |
michael@0 | 145 | }); |
michael@0 | 146 | |
michael@0 | 147 | // Move word right |
michael@0 | 148 | synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_RightArrow, |
michael@0 | 149 | {altKey: true}, "\uf703", "\uf703"]); |
michael@0 | 150 | expectations.push({ |
michael@0 | 151 | editable: [84, 84], |
michael@0 | 152 | textarea: [90, 90], |
michael@0 | 153 | input: [10, 10] |
michael@0 | 154 | }); |
michael@0 | 155 | |
michael@0 | 156 | // Move word right |
michael@0 | 157 | synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_RightArrow, |
michael@0 | 158 | {altKey: true}, "\uf703", "\uf703"]); |
michael@0 | 159 | expectations.push({ |
michael@0 | 160 | editable: [89, 89], |
michael@0 | 161 | textarea: [95, 95], |
michael@0 | 162 | input: [17, 17] |
michael@0 | 163 | }); |
michael@0 | 164 | |
michael@0 | 165 | // Move down and modify selection |
michael@0 | 166 | synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_DownArrow, |
michael@0 | 167 | {shiftKey: true}, "\uf701", "\uf701"]); |
michael@0 | 168 | expectations.push({ |
michael@0 | 169 | editable: [89, 171], |
michael@0 | 170 | textarea: [95, 175], |
michael@0 | 171 | input: [17, 732] |
michael@0 | 172 | }); |
michael@0 | 173 | |
michael@0 | 174 | // Move backward and modify selection |
michael@0 | 175 | synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_B, |
michael@0 | 176 | {ctrlKey: true, shiftKey: true}, "\u0002", "B"]); |
michael@0 | 177 | expectations.push({ |
michael@0 | 178 | editable: [89, 170], |
michael@0 | 179 | textarea: [95, 174], |
michael@0 | 180 | input: [17, 731] |
michael@0 | 181 | }); |
michael@0 | 182 | |
michael@0 | 183 | // Delete forward |
michael@0 | 184 | synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_D, |
michael@0 | 185 | {ctrlKey: true}, "\u0004", "d"]); |
michael@0 | 186 | expectations.push({ |
michael@0 | 187 | editable: [89, 89], |
michael@0 | 188 | textarea: [95, 95], |
michael@0 | 189 | input: [17, 17] |
michael@0 | 190 | }); |
michael@0 | 191 | |
michael@0 | 192 | // Delete backward |
michael@0 | 193 | synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_H, |
michael@0 | 194 | {ctrlKey: true}, "\u0008", "h"]); |
michael@0 | 195 | expectations.push({ |
michael@0 | 196 | editable: [88, 88], |
michael@0 | 197 | textarea: [94, 94], |
michael@0 | 198 | input: [16, 16] |
michael@0 | 199 | }); |
michael@0 | 200 | |
michael@0 | 201 | // Move backward |
michael@0 | 202 | synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_B, |
michael@0 | 203 | {ctrlKey: true}, "\u0002", "b"]); |
michael@0 | 204 | expectations.push({ |
michael@0 | 205 | editable: [87, 87], |
michael@0 | 206 | textarea: [93, 93], |
michael@0 | 207 | input: [15, 15] |
michael@0 | 208 | }); |
michael@0 | 209 | |
michael@0 | 210 | // Move to beginning of paragraph (line for now) |
michael@0 | 211 | synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_A, |
michael@0 | 212 | {ctrlKey: true}, "\u0001", "a"]); |
michael@0 | 213 | expectations.push({ |
michael@0 | 214 | editable: [73, 73], |
michael@0 | 215 | textarea: [73, 73], |
michael@0 | 216 | input: [0, 0] |
michael@0 | 217 | }); |
michael@0 | 218 | |
michael@0 | 219 | // Move forward |
michael@0 | 220 | synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_F, |
michael@0 | 221 | {ctrlKey: true}, "\u0006", "f"]); |
michael@0 | 222 | expectations.push({ |
michael@0 | 223 | editable: [74, 74], |
michael@0 | 224 | textarea: [74, 74], |
michael@0 | 225 | input: [1, 1] |
michael@0 | 226 | }); |
michael@0 | 227 | |
michael@0 | 228 | // Move word right |
michael@0 | 229 | synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_RightArrow, |
michael@0 | 230 | {altKey: true}, "\uf703", "\uf703"]); |
michael@0 | 231 | expectations.push({ |
michael@0 | 232 | editable: [84, 84], |
michael@0 | 233 | textarea: [90, 90], |
michael@0 | 234 | input: [10, 10] |
michael@0 | 235 | }); |
michael@0 | 236 | |
michael@0 | 237 | // Move word right |
michael@0 | 238 | synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_RightArrow, |
michael@0 | 239 | {altKey: true}, "\uf703", "\uf703"]); |
michael@0 | 240 | expectations.push({ |
michael@0 | 241 | editable: [88, 88], |
michael@0 | 242 | textarea: [94, 94], |
michael@0 | 243 | input: [17, 17] |
michael@0 | 244 | }); |
michael@0 | 245 | |
michael@0 | 246 | // Delete to end of paragraph (line for now) |
michael@0 | 247 | synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_K, |
michael@0 | 248 | {ctrlKey: true}, "\u000b", "k"]); |
michael@0 | 249 | expectations.push({ |
michael@0 | 250 | editable: [88, 88], |
michael@0 | 251 | textarea: [94, 94], |
michael@0 | 252 | input: [17, 17] |
michael@0 | 253 | }); |
michael@0 | 254 | |
michael@0 | 255 | // Move backward and modify selection |
michael@0 | 256 | synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_B, |
michael@0 | 257 | {ctrlKey: true, shiftKey: true}, "\u0002", "B"]); |
michael@0 | 258 | expectations.push({ |
michael@0 | 259 | editable: [88, 87], |
michael@0 | 260 | textarea: [93, 94], |
michael@0 | 261 | input: [16, 17] |
michael@0 | 262 | }); |
michael@0 | 263 | |
michael@0 | 264 | // Move to end of paragraph (line for now) |
michael@0 | 265 | synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_E, |
michael@0 | 266 | {ctrlKey: true}, "\u0005", "e"]); |
michael@0 | 267 | expectations.push({ |
michael@0 | 268 | editable: [144, 144], |
michael@0 | 269 | textarea: [94, 94], |
michael@0 | 270 | input: [17, 17] |
michael@0 | 271 | }); |
michael@0 | 272 | |
michael@0 | 273 | // Move up |
michael@0 | 274 | synthesizedKeys.push([KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_P, |
michael@0 | 275 | {ctrlKey: true}, "\u0010", "p"]); |
michael@0 | 276 | expectations.push({ |
michael@0 | 277 | editable: [73, 73], |
michael@0 | 278 | textarea: [21, 21], |
michael@0 | 279 | input: [0, 0] |
michael@0 | 280 | }); |
michael@0 | 281 | |
michael@0 | 282 | function checkWindowSelection(aElement, aSelection) |
michael@0 | 283 | { |
michael@0 | 284 | let selection = window.getSelection(); |
michael@0 | 285 | |
michael@0 | 286 | is(selection.anchorOffset, aSelection[aElement.id][0], |
michael@0 | 287 | aElement.id + ": Incorrect anchor offset"); |
michael@0 | 288 | is(selection.focusOffset, aSelection[aElement.id][1], |
michael@0 | 289 | aElement.id + ": Incorrect focus offset"); |
michael@0 | 290 | } |
michael@0 | 291 | |
michael@0 | 292 | function checkElementSelection(aElement, aSelection) |
michael@0 | 293 | { |
michael@0 | 294 | is(aElement.selectionStart, aSelection[aElement.id][0], |
michael@0 | 295 | aElement.id + ": Incorrect selection start"); |
michael@0 | 296 | is(aElement.selectionEnd, aSelection[aElement.id][1], |
michael@0 | 297 | aElement.id + ": Incorrect selection end"); |
michael@0 | 298 | } |
michael@0 | 299 | |
michael@0 | 300 | function testRun(aElement, aSelectionCheck) |
michael@0 | 301 | { |
michael@0 | 302 | if (document.activeElement) { |
michael@0 | 303 | document.activeElement.blur(); |
michael@0 | 304 | } |
michael@0 | 305 | |
michael@0 | 306 | aElement.focus(); |
michael@0 | 307 | |
michael@0 | 308 | for (let i = 0; i < synthesizedKeys.length; i++) { |
michael@0 | 309 | synthesizeNativeKey.apply(null, synthesizedKeys[i]); |
michael@0 | 310 | aSelectionCheck.call(null, aElement, expectations[i]); |
michael@0 | 311 | } |
michael@0 | 312 | } |
michael@0 | 313 | |
michael@0 | 314 | function doTest() |
michael@0 | 315 | { |
michael@0 | 316 | testRun(document.getElementById("editable"), checkWindowSelection); |
michael@0 | 317 | testRun(document.getElementById("textarea"), checkElementSelection); |
michael@0 | 318 | testRun(document.getElementById("input"), checkElementSelection); |
michael@0 | 319 | |
michael@0 | 320 | SimpleTest.finish(); |
michael@0 | 321 | } |
michael@0 | 322 | |
michael@0 | 323 | SimpleTest.waitForFocus(doTest); |
michael@0 | 324 | </script> |
michael@0 | 325 | </body> |
michael@0 | 326 | </html> |
michael@0 | 327 |