browser/devtools/debugger/test/browser_dbg_variables-view-accessibility.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 /**
michael@0 5 * Make sure that the variables view is keyboard accessible.
michael@0 6 */
michael@0 7
michael@0 8 let gTab, gDebuggee, gPanel, gDebugger;
michael@0 9 let gVariablesView;
michael@0 10
michael@0 11 function test() {
michael@0 12 initDebugger("about:blank").then(([aTab, aDebuggee, aPanel]) => {
michael@0 13 gTab = aTab;
michael@0 14 gDebuggee = aDebuggee;
michael@0 15 gPanel = aPanel;
michael@0 16 gDebugger = gPanel.panelWin;
michael@0 17 gVariablesView = gDebugger.DebuggerView.Variables;
michael@0 18
michael@0 19 performTest().then(null, aError => {
michael@0 20 ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
michael@0 21 });
michael@0 22 });
michael@0 23 }
michael@0 24
michael@0 25 function performTest() {
michael@0 26 let arr = [
michael@0 27 42,
michael@0 28 true,
michael@0 29 "nasu",
michael@0 30 undefined,
michael@0 31 null,
michael@0 32 [0, 1, 2],
michael@0 33 { prop1: 9, prop2: 8 }
michael@0 34 ];
michael@0 35
michael@0 36 let obj = {
michael@0 37 p0: 42,
michael@0 38 p1: true,
michael@0 39 p2: "nasu",
michael@0 40 p3: undefined,
michael@0 41 p4: null,
michael@0 42 p5: [3, 4, 5],
michael@0 43 p6: { prop1: 7, prop2: 6 },
michael@0 44 get p7() { return arr; },
michael@0 45 set p8(value) { arr[0] = value }
michael@0 46 };
michael@0 47
michael@0 48 let test = {
michael@0 49 someProp0: 42,
michael@0 50 someProp1: true,
michael@0 51 someProp2: "nasu",
michael@0 52 someProp3: undefined,
michael@0 53 someProp4: null,
michael@0 54 someProp5: arr,
michael@0 55 someProp6: obj,
michael@0 56 get someProp7() { return arr; },
michael@0 57 set someProp7(value) { arr[0] = value }
michael@0 58 };
michael@0 59
michael@0 60 gVariablesView.eval = function() {};
michael@0 61 gVariablesView.switch = function() {};
michael@0 62 gVariablesView.delete = function() {};
michael@0 63 gVariablesView.rawObject = test;
michael@0 64 gVariablesView.scrollPageSize = 5;
michael@0 65
michael@0 66 return Task.spawn(function() {
michael@0 67 yield waitForTick();
michael@0 68
michael@0 69 // Part 0: Test generic focus methods on the variables view.
michael@0 70
michael@0 71 gVariablesView.focusFirstVisibleItem();
michael@0 72 is(gVariablesView.getFocusedItem().name, "someProp0",
michael@0 73 "The 'someProp0' item should be focused.");
michael@0 74
michael@0 75 gVariablesView.focusNextItem();
michael@0 76 is(gVariablesView.getFocusedItem().name, "someProp1",
michael@0 77 "The 'someProp1' item should be focused.");
michael@0 78
michael@0 79 gVariablesView.focusPrevItem();
michael@0 80 is(gVariablesView.getFocusedItem().name, "someProp0",
michael@0 81 "The 'someProp0' item should be focused.");
michael@0 82
michael@0 83 // Part 1: Make sure that UP/DOWN keys don't scroll the variables view.
michael@0 84
michael@0 85 yield synthesizeKeyAndWaitForTick("VK_DOWN", {});
michael@0 86 is(gVariablesView._parent.scrollTop, 0,
michael@0 87 "The 'variables' view shouldn't scroll when pressing the DOWN key.");
michael@0 88
michael@0 89 yield synthesizeKeyAndWaitForTick("VK_UP", {});
michael@0 90 is(gVariablesView._parent.scrollTop, 0,
michael@0 91 "The 'variables' view shouldn't scroll when pressing the UP key.");
michael@0 92
michael@0 93 // Part 2: Make sure that RETURN/ESCAPE toggle input elements.
michael@0 94
michael@0 95 yield synthesizeKeyAndWaitForElement("VK_RETURN", {}, ".element-value-input", true);
michael@0 96 yield synthesizeKeyAndWaitForElement("VK_ESCAPE", {}, ".element-value-input", false);
michael@0 97 yield synthesizeKeyAndWaitForElement("VK_RETURN", { shiftKey: true }, ".element-name-input", true);
michael@0 98 yield synthesizeKeyAndWaitForElement("VK_ESCAPE", {}, ".element-name-input", false);
michael@0 99
michael@0 100 // Part 3: Test simple navigation.
michael@0 101
michael@0 102 EventUtils.sendKey("DOWN", gDebugger);
michael@0 103 is(gVariablesView.getFocusedItem().name, "someProp1",
michael@0 104 "The 'someProp1' item should be focused.");
michael@0 105
michael@0 106 EventUtils.sendKey("UP", gDebugger);
michael@0 107 is(gVariablesView.getFocusedItem().name, "someProp0",
michael@0 108 "The 'someProp0' item should be focused.");
michael@0 109
michael@0 110 EventUtils.sendKey("PAGE_DOWN", gDebugger);
michael@0 111 is(gVariablesView.getFocusedItem().name, "someProp5",
michael@0 112 "The 'someProp5' item should be focused.");
michael@0 113
michael@0 114 EventUtils.sendKey("PAGE_UP", gDebugger);
michael@0 115 is(gVariablesView.getFocusedItem().name, "someProp0",
michael@0 116 "The 'someProp0' item should be focused.");
michael@0 117
michael@0 118 EventUtils.sendKey("END", gDebugger);
michael@0 119 is(gVariablesView.getFocusedItem().name, "__proto__",
michael@0 120 "The '__proto__' item should be focused.");
michael@0 121
michael@0 122 EventUtils.sendKey("HOME", gDebugger);
michael@0 123 is(gVariablesView.getFocusedItem().name, "someProp0",
michael@0 124 "The 'someProp0' item should be focused.");
michael@0 125
michael@0 126 // Part 4: Test if pressing the same navigation key twice works as expected.
michael@0 127
michael@0 128 EventUtils.sendKey("DOWN", gDebugger);
michael@0 129 is(gVariablesView.getFocusedItem().name, "someProp1",
michael@0 130 "The 'someProp1' item should be focused.");
michael@0 131
michael@0 132 EventUtils.sendKey("DOWN", gDebugger);
michael@0 133 is(gVariablesView.getFocusedItem().name, "someProp2",
michael@0 134 "The 'someProp2' item should be focused.");
michael@0 135
michael@0 136 EventUtils.sendKey("UP", gDebugger);
michael@0 137 is(gVariablesView.getFocusedItem().name, "someProp1",
michael@0 138 "The 'someProp1' item should be focused.");
michael@0 139
michael@0 140 EventUtils.sendKey("UP", gDebugger);
michael@0 141 is(gVariablesView.getFocusedItem().name, "someProp0",
michael@0 142 "The 'someProp0' item should be focused.");
michael@0 143
michael@0 144 EventUtils.sendKey("PAGE_DOWN", gDebugger);
michael@0 145 is(gVariablesView.getFocusedItem().name, "someProp5",
michael@0 146 "The 'someProp5' item should be focused.");
michael@0 147
michael@0 148 EventUtils.sendKey("PAGE_DOWN", gDebugger);
michael@0 149 is(gVariablesView.getFocusedItem().name, "__proto__",
michael@0 150 "The '__proto__' item should be focused.");
michael@0 151
michael@0 152 EventUtils.sendKey("PAGE_UP", gDebugger);
michael@0 153 is(gVariablesView.getFocusedItem().name, "someProp5",
michael@0 154 "The 'someProp5' item should be focused.");
michael@0 155
michael@0 156 EventUtils.sendKey("PAGE_UP", gDebugger);
michael@0 157 is(gVariablesView.getFocusedItem().name, "someProp0",
michael@0 158 "The 'someProp0' item should be focused.");
michael@0 159
michael@0 160 // Part 5: Test that HOME/PAGE_UP/PAGE_DOWN are symmetrical.
michael@0 161
michael@0 162 EventUtils.sendKey("HOME", gDebugger);
michael@0 163 is(gVariablesView.getFocusedItem().name, "someProp0",
michael@0 164 "The 'someProp0' item should be focused.");
michael@0 165
michael@0 166 EventUtils.sendKey("HOME", gDebugger);
michael@0 167 is(gVariablesView.getFocusedItem().name, "someProp0",
michael@0 168 "The 'someProp0' item should be focused.");
michael@0 169
michael@0 170 EventUtils.sendKey("PAGE_UP", gDebugger);
michael@0 171 is(gVariablesView.getFocusedItem().name, "someProp0",
michael@0 172 "The 'someProp0' item should be focused.");
michael@0 173
michael@0 174 EventUtils.sendKey("HOME", gDebugger);
michael@0 175 is(gVariablesView.getFocusedItem().name, "someProp0",
michael@0 176 "The 'someProp0' item should be focused.");
michael@0 177
michael@0 178 EventUtils.sendKey("END", gDebugger);
michael@0 179 is(gVariablesView.getFocusedItem().name, "__proto__",
michael@0 180 "The '__proto__' item should be focused.");
michael@0 181
michael@0 182 EventUtils.sendKey("END", gDebugger);
michael@0 183 is(gVariablesView.getFocusedItem().name, "__proto__",
michael@0 184 "The '__proto__' item should be focused.");
michael@0 185
michael@0 186 EventUtils.sendKey("PAGE_DOWN", gDebugger);
michael@0 187 is(gVariablesView.getFocusedItem().name, "__proto__",
michael@0 188 "The '__proto__' item should be focused.");
michael@0 189
michael@0 190 EventUtils.sendKey("END", gDebugger);
michael@0 191 is(gVariablesView.getFocusedItem().name, "__proto__",
michael@0 192 "The '__proto__' item should be focused.");
michael@0 193
michael@0 194 // Part 6: Test that focus doesn't leave the variables view.
michael@0 195
michael@0 196 EventUtils.sendKey("PAGE_UP", gDebugger);
michael@0 197 is(gVariablesView.getFocusedItem().name, "someProp5",
michael@0 198 "The 'someProp5' item should be focused.");
michael@0 199
michael@0 200 EventUtils.sendKey("PAGE_UP", gDebugger);
michael@0 201 is(gVariablesView.getFocusedItem().name, "someProp0",
michael@0 202 "The 'someProp0' item should be focused.");
michael@0 203
michael@0 204 EventUtils.sendKey("UP", gDebugger);
michael@0 205 is(gVariablesView.getFocusedItem().name, "someProp0",
michael@0 206 "The 'someProp0' item should be focused.");
michael@0 207
michael@0 208 EventUtils.sendKey("UP", gDebugger);
michael@0 209 is(gVariablesView.getFocusedItem().name, "someProp0",
michael@0 210 "The 'someProp0' item should be focused.");
michael@0 211
michael@0 212 EventUtils.sendKey("PAGE_DOWN", gDebugger);
michael@0 213 is(gVariablesView.getFocusedItem().name, "someProp5",
michael@0 214 "The 'someProp5' item should be focused.");
michael@0 215
michael@0 216 EventUtils.sendKey("PAGE_DOWN", gDebugger);
michael@0 217 is(gVariablesView.getFocusedItem().name, "__proto__",
michael@0 218 "The '__proto__' item should be focused.");
michael@0 219
michael@0 220 EventUtils.sendKey("PAGE_DOWN", gDebugger);
michael@0 221 is(gVariablesView.getFocusedItem().name, "__proto__",
michael@0 222 "The '__proto__' item should be focused.");
michael@0 223
michael@0 224 EventUtils.sendKey("PAGE_DOWN", gDebugger);
michael@0 225 is(gVariablesView.getFocusedItem().name, "__proto__",
michael@0 226 "The '__proto__' item should be focused.");
michael@0 227
michael@0 228 // Part 7: Test that random offsets don't occur in tandem with HOME/END.
michael@0 229
michael@0 230 EventUtils.sendKey("HOME", gDebugger);
michael@0 231 is(gVariablesView.getFocusedItem().name, "someProp0",
michael@0 232 "The 'someProp0' item should be focused.");
michael@0 233
michael@0 234 EventUtils.sendKey("DOWN", gDebugger);
michael@0 235 is(gVariablesView.getFocusedItem().name, "someProp1",
michael@0 236 "The 'someProp1' item should be focused.");
michael@0 237
michael@0 238 EventUtils.sendKey("END", gDebugger);
michael@0 239 is(gVariablesView.getFocusedItem().name, "__proto__",
michael@0 240 "The '__proto__' item should be focused.");
michael@0 241
michael@0 242 EventUtils.sendKey("DOWN", gDebugger);
michael@0 243 is(gVariablesView.getFocusedItem().name, "__proto__",
michael@0 244 "The '__proto__' item should be focused.");
michael@0 245
michael@0 246 // Part 8: Test that the RIGHT key expands elements as intended.
michael@0 247
michael@0 248 EventUtils.sendKey("PAGE_UP", gDebugger);
michael@0 249 is(gVariablesView.getFocusedItem().name, "someProp5",
michael@0 250 "The 'someProp5' item should be focused.");
michael@0 251 is(gVariablesView.getFocusedItem().expanded, false,
michael@0 252 "The 'someProp5' item should not be expanded yet.");
michael@0 253
michael@0 254 yield synthesizeKeyAndWaitForTick("VK_RIGHT", {});
michael@0 255 is(gVariablesView.getFocusedItem().name, "someProp5",
michael@0 256 "The 'someProp5' item should be focused.");
michael@0 257 is(gVariablesView.getFocusedItem().expanded, true,
michael@0 258 "The 'someProp5' item should now be expanded.");
michael@0 259 is(gVariablesView.getFocusedItem()._store.size, 9,
michael@0 260 "There should be 9 properties in the selected variable.");
michael@0 261 is(gVariablesView.getFocusedItem()._enumItems.length, 7,
michael@0 262 "There should be 7 enumerable properties in the selected variable.");
michael@0 263 is(gVariablesView.getFocusedItem()._nonEnumItems.length, 2,
michael@0 264 "There should be 2 non-enumerable properties in the selected variable.");
michael@0 265
michael@0 266 yield waitForChildNodes(gVariablesView.getFocusedItem()._enum, 7);
michael@0 267 yield waitForChildNodes(gVariablesView.getFocusedItem()._nonenum, 2);
michael@0 268
michael@0 269 EventUtils.sendKey("RIGHT", gDebugger);
michael@0 270 is(gVariablesView.getFocusedItem().name, "0",
michael@0 271 "The '0' item should be focused.");
michael@0 272
michael@0 273 EventUtils.sendKey("RIGHT", gDebugger);
michael@0 274 is(gVariablesView.getFocusedItem().name, "0",
michael@0 275 "The '0' item should still be focused.");
michael@0 276
michael@0 277 EventUtils.sendKey("PAGE_DOWN", gDebugger);
michael@0 278 is(gVariablesView.getFocusedItem().name, "5",
michael@0 279 "The '5' item should be focused.");
michael@0 280 is(gVariablesView.getFocusedItem().expanded, false,
michael@0 281 "The '5' item should not be expanded yet.");
michael@0 282
michael@0 283 yield synthesizeKeyAndWaitForTick("VK_RIGHT", {});
michael@0 284 is(gVariablesView.getFocusedItem().name, "5",
michael@0 285 "The '5' item should be focused.");
michael@0 286 is(gVariablesView.getFocusedItem().expanded, true,
michael@0 287 "The '5' item should now be expanded.");
michael@0 288 is(gVariablesView.getFocusedItem()._store.size, 5,
michael@0 289 "There should be 5 properties in the selected variable.");
michael@0 290 is(gVariablesView.getFocusedItem()._enumItems.length, 3,
michael@0 291 "There should be 3 enumerable properties in the selected variable.");
michael@0 292 is(gVariablesView.getFocusedItem()._nonEnumItems.length, 2,
michael@0 293 "There should be 2 non-enumerable properties in the selected variable.");
michael@0 294
michael@0 295 yield waitForChildNodes(gVariablesView.getFocusedItem()._enum, 3);
michael@0 296 yield waitForChildNodes(gVariablesView.getFocusedItem()._nonenum, 2);
michael@0 297
michael@0 298 EventUtils.sendKey("RIGHT", gDebugger);
michael@0 299 is(gVariablesView.getFocusedItem().name, "0",
michael@0 300 "The '0' item should be focused.");
michael@0 301
michael@0 302 EventUtils.sendKey("RIGHT", gDebugger);
michael@0 303 is(gVariablesView.getFocusedItem().name, "0",
michael@0 304 "The '0' item should still be focused.");
michael@0 305
michael@0 306 EventUtils.sendKey("PAGE_DOWN", gDebugger);
michael@0 307 is(gVariablesView.getFocusedItem().name, "6",
michael@0 308 "The '6' item should be focused.");
michael@0 309 is(gVariablesView.getFocusedItem().expanded, false,
michael@0 310 "The '6' item should not be expanded yet.");
michael@0 311
michael@0 312 yield synthesizeKeyAndWaitForTick("VK_RIGHT", {});
michael@0 313 is(gVariablesView.getFocusedItem().name, "6",
michael@0 314 "The '6' item should be focused.");
michael@0 315 is(gVariablesView.getFocusedItem().expanded, true,
michael@0 316 "The '6' item should now be expanded.");
michael@0 317 is(gVariablesView.getFocusedItem()._store.size, 3,
michael@0 318 "There should be 3 properties in the selected variable.");
michael@0 319 is(gVariablesView.getFocusedItem()._enumItems.length, 2,
michael@0 320 "There should be 2 enumerable properties in the selected variable.");
michael@0 321 is(gVariablesView.getFocusedItem()._nonEnumItems.length, 1,
michael@0 322 "There should be 1 non-enumerable properties in the selected variable.");
michael@0 323
michael@0 324 yield waitForChildNodes(gVariablesView.getFocusedItem()._enum, 2);
michael@0 325 yield waitForChildNodes(gVariablesView.getFocusedItem()._nonenum, 1);
michael@0 326
michael@0 327 EventUtils.sendKey("RIGHT", gDebugger);
michael@0 328 is(gVariablesView.getFocusedItem().name, "prop1",
michael@0 329 "The 'prop1' item should be focused.");
michael@0 330
michael@0 331 EventUtils.sendKey("RIGHT", gDebugger);
michael@0 332 is(gVariablesView.getFocusedItem().name, "prop1",
michael@0 333 "The 'prop1' item should still be focused.");
michael@0 334
michael@0 335 EventUtils.sendKey("PAGE_DOWN", gDebugger);
michael@0 336 is(gVariablesView.getFocusedItem().name, "someProp6",
michael@0 337 "The 'someProp6' item should be focused.");
michael@0 338 is(gVariablesView.getFocusedItem().expanded, false,
michael@0 339 "The 'someProp6' item should not be expanded yet.");
michael@0 340
michael@0 341 // Part 9: Test that the RIGHT key collapses elements as intended.
michael@0 342
michael@0 343 EventUtils.sendKey("LEFT", gDebugger);
michael@0 344 is(gVariablesView.getFocusedItem().name, "someProp6",
michael@0 345 "The 'someProp6' item should be focused.");
michael@0 346
michael@0 347 EventUtils.sendKey("UP", gDebugger);
michael@0 348 is(gVariablesView.getFocusedItem().name, "__proto__",
michael@0 349 "The '__proto__' item should be focused.");
michael@0 350
michael@0 351 EventUtils.sendKey("LEFT", gDebugger);
michael@0 352 is(gVariablesView.getFocusedItem().name, "someProp5",
michael@0 353 "The 'someProp5' item should be focused.");
michael@0 354 is(gVariablesView.getFocusedItem().expanded, true,
michael@0 355 "The '6' item should still be expanded.");
michael@0 356
michael@0 357 EventUtils.sendKey("LEFT", gDebugger);
michael@0 358 is(gVariablesView.getFocusedItem().name, "someProp5",
michael@0 359 "The 'someProp5' item should still be focused.");
michael@0 360 is(gVariablesView.getFocusedItem().expanded, false,
michael@0 361 "The '6' item should still not be expanded anymore.");
michael@0 362
michael@0 363 EventUtils.sendKey("LEFT", gDebugger);
michael@0 364 is(gVariablesView.getFocusedItem().name, "someProp5",
michael@0 365 "The 'someProp5' item should still be focused.");
michael@0 366
michael@0 367 // Part 9: Test continuous navigation.
michael@0 368
michael@0 369 EventUtils.sendKey("UP", gDebugger);
michael@0 370 is(gVariablesView.getFocusedItem().name, "someProp4",
michael@0 371 "The 'someProp4' item should be focused.");
michael@0 372
michael@0 373 EventUtils.sendKey("UP", gDebugger);
michael@0 374 is(gVariablesView.getFocusedItem().name, "someProp3",
michael@0 375 "The 'someProp3' item should be focused.");
michael@0 376
michael@0 377 EventUtils.sendKey("UP", gDebugger);
michael@0 378 is(gVariablesView.getFocusedItem().name, "someProp2",
michael@0 379 "The 'someProp2' item should be focused.");
michael@0 380
michael@0 381 EventUtils.sendKey("UP", gDebugger);
michael@0 382 is(gVariablesView.getFocusedItem().name, "someProp1",
michael@0 383 "The 'someProp1' item should be focused.");
michael@0 384
michael@0 385 EventUtils.sendKey("UP", gDebugger);
michael@0 386 is(gVariablesView.getFocusedItem().name, "someProp0",
michael@0 387 "The 'someProp0' item should be focused.");
michael@0 388
michael@0 389 EventUtils.sendKey("PAGE_UP", gDebugger);
michael@0 390 is(gVariablesView.getFocusedItem().name, "someProp0",
michael@0 391 "The 'someProp0' item should be focused.");
michael@0 392
michael@0 393 EventUtils.sendKey("PAGE_DOWN", gDebugger);
michael@0 394 is(gVariablesView.getFocusedItem().name, "someProp5",
michael@0 395 "The 'someProp5' item should be focused.");
michael@0 396
michael@0 397 EventUtils.sendKey("DOWN", gDebugger);
michael@0 398 is(gVariablesView.getFocusedItem().name, "someProp6",
michael@0 399 "The 'someProp6' item should be focused.");
michael@0 400
michael@0 401 EventUtils.sendKey("DOWN", gDebugger);
michael@0 402 is(gVariablesView.getFocusedItem().name, "someProp7",
michael@0 403 "The 'someProp7' item should be focused.");
michael@0 404
michael@0 405 EventUtils.sendKey("DOWN", gDebugger);
michael@0 406 is(gVariablesView.getFocusedItem().name, "get",
michael@0 407 "The 'get' item should be focused.");
michael@0 408
michael@0 409 EventUtils.sendKey("DOWN", gDebugger);
michael@0 410 is(gVariablesView.getFocusedItem().name, "set",
michael@0 411 "The 'set' item should be focused.");
michael@0 412
michael@0 413 EventUtils.sendKey("DOWN", gDebugger);
michael@0 414 is(gVariablesView.getFocusedItem().name, "__proto__",
michael@0 415 "The '__proto__' item should be focused.");
michael@0 416
michael@0 417 // Part 10: Test that BACKSPACE deletes items in the variables view.
michael@0 418
michael@0 419 EventUtils.sendKey("BACK_SPACE", gDebugger);
michael@0 420 is(gVariablesView.getFocusedItem().name, "__proto__",
michael@0 421 "The '__proto__' variable should still be focused.");
michael@0 422 is(gVariablesView.getFocusedItem().value, "[object Object]",
michael@0 423 "The '__proto__' variable should not have an empty value.");
michael@0 424 is(gVariablesView.getFocusedItem().visible, false,
michael@0 425 "The '__proto__' variable should be hidden.");
michael@0 426
michael@0 427 EventUtils.sendKey("UP", gDebugger);
michael@0 428 is(gVariablesView.getFocusedItem().name, "set",
michael@0 429 "The 'set' item should be focused.");
michael@0 430 is(gVariablesView.getFocusedItem().value, "[object Object]",
michael@0 431 "The 'set' item should not have an empty value.");
michael@0 432 is(gVariablesView.getFocusedItem().visible, true,
michael@0 433 "The 'set' item should be visible.");
michael@0 434
michael@0 435 EventUtils.sendKey("BACK_SPACE", gDebugger);
michael@0 436 is(gVariablesView.getFocusedItem().name, "set",
michael@0 437 "The 'set' item should still be focused.");
michael@0 438 is(gVariablesView.getFocusedItem().value, "[object Object]",
michael@0 439 "The 'set' item should not have an empty value.");
michael@0 440 is(gVariablesView.getFocusedItem().visible, true,
michael@0 441 "The 'set' item should be visible.");
michael@0 442 is(gVariablesView.getFocusedItem().twisty, false,
michael@0 443 "The 'set' item should be disabled and have a hidden twisty.");
michael@0 444
michael@0 445 EventUtils.sendKey("UP", gDebugger);
michael@0 446 is(gVariablesView.getFocusedItem().name, "get",
michael@0 447 "The 'get' item should be focused.");
michael@0 448 is(gVariablesView.getFocusedItem().value, "[object Object]",
michael@0 449 "The 'get' item should not have an empty value.");
michael@0 450 is(gVariablesView.getFocusedItem().visible, true,
michael@0 451 "The 'get' item should be visible.");
michael@0 452
michael@0 453 EventUtils.sendKey("BACK_SPACE", gDebugger);
michael@0 454 is(gVariablesView.getFocusedItem().name, "get",
michael@0 455 "The 'get' item should still be focused.");
michael@0 456 is(gVariablesView.getFocusedItem().value, "[object Object]",
michael@0 457 "The 'get' item should not have an empty value.");
michael@0 458 is(gVariablesView.getFocusedItem().visible, true,
michael@0 459 "The 'get' item should be visible.");
michael@0 460 is(gVariablesView.getFocusedItem().twisty, false,
michael@0 461 "The 'get' item should be disabled and have a hidden twisty.");
michael@0 462
michael@0 463 EventUtils.sendKey("UP", gDebugger);
michael@0 464 is(gVariablesView.getFocusedItem().name, "someProp7",
michael@0 465 "The 'someProp7' item should be focused.");
michael@0 466 is(gVariablesView.getFocusedItem().value, undefined,
michael@0 467 "The 'someProp7' variable should have an empty value.");
michael@0 468 is(gVariablesView.getFocusedItem().visible, true,
michael@0 469 "The 'someProp7' variable should be visible.");
michael@0 470
michael@0 471 EventUtils.sendKey("BACK_SPACE", gDebugger);
michael@0 472 is(gVariablesView.getFocusedItem().name, "someProp7",
michael@0 473 "The 'someProp7' variable should still be focused.");
michael@0 474 is(gVariablesView.getFocusedItem().value, undefined,
michael@0 475 "The 'someProp7' variable should have an empty value.");
michael@0 476 is(gVariablesView.getFocusedItem().visible, false,
michael@0 477 "The 'someProp7' variable should be hidden.");
michael@0 478
michael@0 479 // Part 11: Test that Ctrl-C copies the current item to the system clipboard
michael@0 480
michael@0 481 gVariablesView.focusFirstVisibleItem();
michael@0 482 let copied = promise.defer();
michael@0 483 let expectedValue = gVariablesView.getFocusedItem().name
michael@0 484 + gVariablesView.getFocusedItem().separatorStr
michael@0 485 + gVariablesView.getFocusedItem().value;
michael@0 486
michael@0 487 waitForClipboard(expectedValue, function setup() {
michael@0 488 EventUtils.synthesizeKey("C", { metaKey: true }, gDebugger);
michael@0 489 }, copied.resolve, copied.reject
michael@0 490 );
michael@0 491
michael@0 492 try {
michael@0 493 yield copied.promise;
michael@0 494 ok(true,
michael@0 495 "Ctrl-C copied the selected item to the clipboard.");
michael@0 496 } catch (e) {
michael@0 497 ok(false,
michael@0 498 "Ctrl-C didn't copy the selected item to the clipboard.");
michael@0 499 }
michael@0 500
michael@0 501 yield closeDebuggerAndFinish(gPanel);
michael@0 502 });
michael@0 503 }
michael@0 504
michael@0 505 registerCleanupFunction(function() {
michael@0 506 gTab = null;
michael@0 507 gDebuggee = null;
michael@0 508 gPanel = null;
michael@0 509 gDebugger = null;
michael@0 510 gVariablesView = null;
michael@0 511 });
michael@0 512
michael@0 513 function synthesizeKeyAndWaitForElement(aKey, aModifiers, aSelector, aExistence) {
michael@0 514 EventUtils.synthesizeKey(aKey, aModifiers, gDebugger);
michael@0 515 return waitForElement(aSelector, aExistence);
michael@0 516 }
michael@0 517
michael@0 518 function synthesizeKeyAndWaitForTick(aKey, aModifiers) {
michael@0 519 EventUtils.synthesizeKey(aKey, aModifiers, gDebugger);
michael@0 520 return waitForTick();
michael@0 521 }
michael@0 522
michael@0 523 function waitForElement(aSelector, aExistence) {
michael@0 524 return waitForPredicate(() => {
michael@0 525 return !!gVariablesView._list.querySelector(aSelector) == aExistence;
michael@0 526 });
michael@0 527 }
michael@0 528
michael@0 529 function waitForChildNodes(aTarget, aCount) {
michael@0 530 return waitForPredicate(() => {
michael@0 531 return aTarget.childNodes.length == aCount;
michael@0 532 });
michael@0 533 }
michael@0 534
michael@0 535 function waitForPredicate(aPredicate, aInterval = 10) {
michael@0 536 let deferred = promise.defer();
michael@0 537
michael@0 538 // Poll every few milliseconds until the element is retrieved.
michael@0 539 let count = 0;
michael@0 540 let intervalID = window.setInterval(() => {
michael@0 541 // Make sure we don't wait for too long.
michael@0 542 if (++count > 1000) {
michael@0 543 deferred.reject("Timed out while polling for the element.");
michael@0 544 window.clearInterval(intervalID);
michael@0 545 return;
michael@0 546 }
michael@0 547 // Check if the predicate condition is fulfilled.
michael@0 548 if (!aPredicate()) {
michael@0 549 return;
michael@0 550 }
michael@0 551 // We got the element, it's safe to callback.
michael@0 552 window.clearInterval(intervalID);
michael@0 553 deferred.resolve();
michael@0 554 }, aInterval);
michael@0 555
michael@0 556 return deferred.promise;
michael@0 557 }

mercurial