1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// This test covers all the blackboxing functionality relating to a selected
// source open in the debugger editor.
"use strict";
requestLongerTimeout(5);
const contextMenuItems = {
ignoreSource: { selector: "#node-menu-blackbox", label: "Ignore source" },
unignoreSource: { selector: "#node-menu-blackbox", label: "Unignore source" },
ignoreLines: { selector: "#node-menu-blackbox-lines", label: "Ignore lines" },
unignoreLines: {
selector: "#node-menu-blackbox-lines",
label: "Unignore lines",
},
ignoreLine: { selector: "#node-menu-blackbox-line", label: "Ignore line" },
unignoreLine: {
selector: "#node-menu-blackbox-line",
label: "Unignore line",
},
};
const SOURCE_IS_FULLY_IGNORED = "source";
const SOURCE_LINES_ARE_IGNORED = "line";
const SOURCE_IS_NOT_IGNORED = "none";
// Tests basic functionality for blackbox source and blackbox single and multiple lines
add_task(async function testAllBlackBox() {
// using the doc-command-click.html as it has a simple js file we can use
// testing.
const file = "simple4.js";
const dbg = await initDebugger("doc-command-click.html", file);
const source = findSource(dbg, file);
await selectSource(dbg, source);
await addBreakpoint(dbg, file, 8);
await testBlackBoxSource(dbg, source);
await testBlackBoxMultipleLines(dbg, source);
await testBlackBoxSingleLine(dbg, source);
});
// Test that the blackboxed lines are persisted accross reloads and still work accordingly.
add_task(async function testBlackBoxOnReload() {
const file = "simple4.js";
const dbg = await initDebugger("doc-command-click.html", file);
const source = findSource(dbg, file);
await selectSource(dbg, source);
// Adding 2 breakpoints in funcB() and funcC() which
// would be hit in order.
await addBreakpoint(dbg, file, 8);
await addBreakpoint(dbg, file, 12);
info("Reload without any blackboxing to make all necesary postions are hit");
const onReloaded = reload(dbg, file);
await waitForPaused(dbg);
assertPausedAtSourceAndLine(dbg, source.id, 2);
await resume(dbg);
await waitForPaused(dbg);
assertPausedAtSourceAndLine(dbg, source.id, 8);
await resume(dbg);
await waitForPaused(dbg);
assertPausedAtSourceAndLine(dbg, source.id, 12);
await resumeAndWaitForPauseCounter(dbg);
info("Wait for reload to complete after resume");
await onReloaded;
assertNotPaused(dbg);
info("Ignoring line 2 using the gutter context menu");
await openContextMenuInDebugger(dbg, "gutter", 2);
await selectBlackBoxContextMenuItem(dbg, "blackbox-line");
info("Ignoring line 7 to 9 using the editor context menu");
await selectEditorLinesAndOpenContextMenu(dbg, { startLine: 7, endLine: 9 });
await selectBlackBoxContextMenuItem(dbg, "blackbox-lines");
const onReloaded2 = reload(dbg, file);
await waitForPaused(dbg);
assertPausedAtSourceAndLine(dbg, source.id, 12);
await resume(dbg);
info("Wait for reload to complete after resume");
await onReloaded2;
assertNotPaused(dbg);
info(
"Check that the expected blackbox context menu state is correct across reload"
);
await assertEditorBlackBoxBoxContextMenuItems(dbg, {
blackboxedLine: 2,
nonBlackBoxedLine: 4,
blackBoxedLines: [7, 9],
nonBlackBoxedLines: [3, 4],
blackboxedSourceState: SOURCE_LINES_ARE_IGNORED,
});
await assertGutterBlackBoxBoxContextMenuItems(dbg, {
blackboxedLine: 2,
nonBlackBoxedLine: 4,
blackboxedSourceState: SOURCE_LINES_ARE_IGNORED,
});
await assertSourceTreeBlackBoxBoxContextMenuItems(dbg, {
blackBoxedSourceTreeNode: findSourceNodeWithText(dbg, "simple4.js"),
nonBlackBoxedSourceTreeNode: findSourceNodeWithText(dbg, "simple2.js"),
});
});
add_task(async function testBlackBoxOnToolboxRestart() {
const dbg = await initDebugger("doc-command-click.html", "simple4.js");
const source = findSource(dbg, "simple4.js");
await selectSource(dbg, source);
const onReloaded = reload(dbg, "simple4.js");
await waitForPaused(dbg);
info("Assert it paused at the debugger statement");
assertPausedAtSourceAndLine(dbg, source.id, 2);
await resume(dbg);
await onReloaded;
info("Ignoring line 2 using the gutter context menu");
await openContextMenuInDebugger(dbg, "gutter", 2);
await selectBlackBoxContextMenuItem(dbg, "blackbox-line");
await reloadBrowser();
// Wait a little bit incase of a pause
await wait(1000);
info("Assert that the debugger no longer pauses on the debugger statement");
assertNotPaused(dbg);
info("Close the toolbox");
await dbg.toolbox.closeToolbox();
info("Reopen the toolbox on the debugger");
const toolbox = await openToolboxForTab(gBrowser.selectedTab, "jsdebugger");
const dbg2 = createDebuggerContext(toolbox);
await waitForSelectedSource(dbg2, findSource(dbg2, "simple4.js"));
await reloadBrowser();
// Wait a little incase of a pause
await wait(1000);
info("Assert that debbuger still does not pause on the debugger statement");
assertNotPaused(dbg2);
});
async function testBlackBoxSource(dbg, source) {
info("Start testing blackboxing the whole source");
info("Assert the blackbox context menu items before any blackboxing is done");
// When the source is not blackboxed there are no blackboxed lines
await assertEditorBlackBoxBoxContextMenuItems(dbg, {
blackboxedLine: null,
nonBlackBoxedLine: 4,
blackBoxedLines: null,
nonBlackBoxedLines: [3, 4],
blackboxedSourceState: SOURCE_IS_NOT_IGNORED,
});
await assertGutterBlackBoxBoxContextMenuItems(dbg, {
blackboxedLine: null,
nonBlackBoxedLine: 4,
blackboxedSourceState: SOURCE_IS_NOT_IGNORED,
});
await assertSourceTreeBlackBoxBoxContextMenuItems(dbg, {
blackBoxedSourceTreeNode: null,
nonBlackBoxedSourceTreeNode: findSourceNodeWithText(dbg, "simple4.js"),
});
info(
"Blackbox the whole simple4.js source file using the editor context menu"
);
await openContextMenuInDebugger(dbg, "CodeMirrorLines");
await selectBlackBoxContextMenuItem(dbg, "blackbox");
info("Assert that all lines in the source are styled correctly");
assertIgnoredStyleInSourceLines(dbg, { hasBlackboxedLinesClass: true });
info("Assert that the source tree for simple4.js has the ignored style");
const node = findSourceNodeWithText(dbg, "simple4.js");
ok(
node.querySelector(".blackboxed"),
"simple4.js node does not have the ignored style"
);
invokeInTab("funcA");
info(
"The debugger statement on line 2 and the breakpoint on line 8 should not be hit"
);
assertNotPaused(dbg);
info("Assert the blackbox context menu items after blackboxing is done");
// When the whole source is blackboxed there are no nonBlackboxed lines
await assertEditorBlackBoxBoxContextMenuItems(dbg, {
blackboxedLine: 2,
nonBlackBoxedLine: null,
blackBoxedLines: [3, 5],
nonBlackBoxedLines: null,
blackboxedSourceState: SOURCE_IS_FULLY_IGNORED,
});
await assertGutterBlackBoxBoxContextMenuItems(dbg, {
blackboxedLine: 2,
nonBlackBoxedLine: null,
blackboxedSourceState: SOURCE_IS_FULLY_IGNORED,
});
await assertSourceTreeBlackBoxBoxContextMenuItems(dbg, {
blackBoxedSourceTreeNode: findSourceNodeWithText(dbg, "simple4.js"),
nonBlackBoxedSourceTreeNode: findSourceNodeWithText(dbg, "simple2.js"),
});
info("Unblackbox the whole source using the sourcetree context menu");
rightClickEl(dbg, findSourceNodeWithText(dbg, "simple4.js"));
await waitForContextMenu(dbg);
await selectBlackBoxContextMenuItem(dbg, "blackbox");
info("Assert that all lines in the source are un-styled correctly");
assertIgnoredStyleInSourceLines(dbg, { hasBlackboxedLinesClass: false });
info(
"Assert that the source tree for simple4.js does not have the ignored style"
);
const nodeAfterBlackbox = findSourceNodeWithText(dbg, "simple4.js");
ok(
!nodeAfterBlackbox.querySelector(".blackboxed"),
"simple4.js node still has the ignored style"
);
invokeInTab("funcA");
info("assert the pause at the debugger statement on line 2");
await waitForPaused(dbg);
assertPausedAtSourceAndLine(dbg, source.id, 2);
await resume(dbg);
info("assert the pause at the breakpoint set on line 8");
await waitForPaused(dbg);
assertPausedAtSourceAndLine(dbg, source.id, 8);
await resumeAndWaitForPauseCounter(dbg);
assertNotPaused(dbg);
// When the source is not blackboxed there are no blackboxed lines
await assertEditorBlackBoxBoxContextMenuItems(dbg, {
blackboxedLine: null,
nonBlackBoxedLine: 4,
blackBoxedLines: null,
nonBlackBoxedLines: [3, 4],
blackboxedSourceState: SOURCE_IS_NOT_IGNORED,
});
await assertGutterBlackBoxBoxContextMenuItems(dbg, {
blackboxedLine: null,
nonBlackBoxedLine: 4,
blackboxedSourceState: SOURCE_IS_NOT_IGNORED,
});
await assertSourceTreeBlackBoxBoxContextMenuItems(dbg, {
blackBoxedSourceTreeNode: null,
nonBlackBoxedSourceTreeNode: findSourceNodeWithText(dbg, "simple2.js"),
});
}
async function testBlackBoxMultipleLines(dbg, source) {
info("Blackbox lines 7 to 13 using the editor content menu items");
await selectEditorLinesAndOpenContextMenu(dbg, { startLine: 7, endLine: 13 });
await selectBlackBoxContextMenuItem(dbg, "blackbox-lines");
await assertEditorBlackBoxBoxContextMenuItems(dbg, {
blackboxedLine: null,
nonBlackBoxedLine: 3,
blackBoxedLines: [7, 9],
nonBlackBoxedLines: [3, 4],
blackboxedSourceState: SOURCE_LINES_ARE_IGNORED,
});
await assertGutterBlackBoxBoxContextMenuItems(dbg, {
blackboxedLine: null,
nonBlackBoxedLine: 3,
blackboxedSourceState: SOURCE_LINES_ARE_IGNORED,
});
await assertSourceTreeBlackBoxBoxContextMenuItems(dbg, {
blackBoxedSourceTreeNode: findSourceNodeWithText(dbg, "simple4.js"),
nonBlackBoxedSourceTreeNode: findSourceNodeWithText(dbg, "simple2.js"),
});
info("Assert that the ignored lines are styled correctly");
assertIgnoredStyleInSourceLines(dbg, {
lines: [7, 13],
hasBlackboxedLinesClass: true,
});
info("Assert that the source tree for simple4.js has the ignored style");
const node = findSourceNodeWithText(dbg, "simple4.js");
ok(
node.querySelector(".blackboxed"),
"simple4.js node does not have the ignored style"
);
invokeInTab("funcA");
info("assert the pause at the debugger statement on line 2");
await waitForPaused(dbg);
assertPausedAtSourceAndLine(dbg, source.id, 2);
await resumeAndWaitForPauseCounter(dbg);
info(
"The breakpoint set on line 8 should not get hit as its within the blackboxed range"
);
assertNotPaused(dbg);
info("Unblackbox lines 7 to 13");
await selectEditorLinesAndOpenContextMenu(dbg, { startLine: 7, endLine: 13 });
await selectBlackBoxContextMenuItem(dbg, "blackbox-lines");
await assertEditorBlackBoxBoxContextMenuItems(dbg, {
blackboxedLine: null,
nonBlackBoxedLine: 4,
blackBoxedLines: null,
nonBlackBoxedLines: [3, 4],
blackboxedSourceState: SOURCE_IS_NOT_IGNORED,
});
await assertGutterBlackBoxBoxContextMenuItems(dbg, {
blackboxedLine: null,
nonBlackBoxedLine: 4,
blackboxedSourceState: SOURCE_IS_NOT_IGNORED,
});
await assertSourceTreeBlackBoxBoxContextMenuItems(dbg, {
blackBoxedSourceTreeNode: null,
nonBlackBoxedSourceTreeNode: findSourceNodeWithText(dbg, "simple2.js"),
});
info("Assert that the un-ignored lines are no longer have the style");
assertIgnoredStyleInSourceLines(dbg, {
lines: [7, 13],
hasBlackboxedLinesClass: false,
});
info(
"Assert that the source tree for simple4.js does not have the ignored style"
);
const nodeAfterBlackbox = findSourceNodeWithText(dbg, "simple4.js");
ok(
!nodeAfterBlackbox.querySelector(".blackboxed"),
"simple4.js still has the ignored style"
);
invokeInTab("funcA");
// assert the pause at the debugger statement on line 2
await waitForPaused(dbg);
assertPausedAtSourceAndLine(dbg, source.id, 2);
await resume(dbg);
// assert the pause at the breakpoint set on line 8
await waitForPaused(dbg);
assertPausedAtSourceAndLine(dbg, source.id, 8);
await resumeAndWaitForPauseCounter(dbg);
assertNotPaused(dbg);
}
async function testBlackBoxSingleLine(dbg, source) {
info("Black box line 2 of funcA() with the debugger statement");
await openContextMenuInDebugger(dbg, "gutter", 2);
await selectBlackBoxContextMenuItem(dbg, "blackbox-line");
await assertEditorBlackBoxBoxContextMenuItems(dbg, {
blackboxedLine: 2,
nonBlackBoxedLine: 4,
blackBoxedLines: null,
nonBlackBoxedLines: [3, 4],
blackboxedSourceState: SOURCE_LINES_ARE_IGNORED,
});
await assertGutterBlackBoxBoxContextMenuItems(dbg, {
blackboxedLine: null,
nonBlackBoxedLine: 4,
blackboxedSourceState: SOURCE_LINES_ARE_IGNORED,
});
await assertSourceTreeBlackBoxBoxContextMenuItems(dbg, {
blackBoxedSourceTreeNode: findSourceNodeWithText(dbg, "simple4.js"),
nonBlackBoxedSourceTreeNode: findSourceNodeWithText(dbg, "simple2.js"),
});
info("Assert that the ignored line 2 is styled correctly");
assertIgnoredStyleInSourceLines(dbg, {
lines: [2],
hasBlackboxedLinesClass: true,
});
info("Black box line 4 of funcC() with the debugger statement");
await openContextMenuInDebugger(dbg, "gutter", 4);
await selectBlackBoxContextMenuItem(dbg, "blackbox-line");
info("Assert that the ignored line 4 is styled correctly");
assertIgnoredStyleInSourceLines(dbg, {
lines: [4],
hasBlackboxedLinesClass: true,
});
invokeInTab("funcA");
// assert the pause at the breakpoint set on line 8
await waitForPaused(dbg);
assertPausedAtSourceAndLine(dbg, source.id, 8);
await resumeAndWaitForPauseCounter(dbg);
assertNotPaused(dbg);
info("Un-blackbox line 2 of funcA()");
selectEditorLines(dbg, 2, 2);
await openContextMenuInDebugger(dbg, "CodeMirrorLines");
await selectBlackBoxContextMenuItem(dbg, "blackbox-line");
await assertEditorBlackBoxBoxContextMenuItems(dbg, {
blackboxedLine: 4,
nonBlackBoxedLine: 3,
blackBoxedLines: null,
nonBlackBoxedLines: [11, 12],
blackboxedSourceState: SOURCE_LINES_ARE_IGNORED,
});
await assertGutterBlackBoxBoxContextMenuItems(dbg, {
blackboxedLine: 4,
nonBlackBoxedLine: 3,
blackboxedSourceState: SOURCE_LINES_ARE_IGNORED,
});
await assertSourceTreeBlackBoxBoxContextMenuItems(dbg, {
blackBoxedSourceTreeNode: null,
nonBlackBoxedSourceTreeNode: findSourceNodeWithText(dbg, "simple2.js"),
});
info("Assert that the un-ignored line 2 is styled correctly");
assertIgnoredStyleInSourceLines(dbg, {
lines: [2],
hasBlackboxedLinesClass: false,
});
invokeInTab("funcA");
// assert the pause at the debugger statement on line 2
await waitForPaused(dbg);
assertPausedAtSourceAndLine(dbg, source.id, 2);
await resume(dbg);
// assert the pause at the breakpoint set on line 8
await waitForPaused(dbg);
assertPausedAtSourceAndLine(dbg, source.id, 8);
await resume(dbg);
assertNotPaused(dbg);
}
// Resume and wait for the thread context's `pauseCounter` to get
// updated.
async function resumeAndWaitForPauseCounter(dbg) {
const prevThreadPauseCounter = getThreadContext(dbg).pauseCounter;
await resume(dbg);
return waitFor(
() => getThreadContext(dbg).pauseCounter > prevThreadPauseCounter
);
}
async function assertContextMenuDisabled(dbg, selector, shouldBeDisabled) {
const item = await waitFor(() => findContextMenu(dbg, selector));
is(
item.disabled,
shouldBeDisabled,
`The the context menu item is ${
shouldBeDisabled ? "disabled" : "not disabled"
}`
);
}
/**
* Asserts that the gutter blackbox context menu items which are visible are correct
* @params {Object} dbg
* @params {Array} testFixtures
* Details needed for the assertion. Any blackboxed/nonBlackboxed lines
* and any blackboxed/nonBlackboxed sources
*/
async function assertGutterBlackBoxBoxContextMenuItems(dbg, testFixtures) {
const { blackboxedLine, nonBlackBoxedLine, blackboxedSourceState } =
testFixtures;
if (blackboxedLine) {
info(
"Asserts that the gutter context menu items when clicking on the gutter of a blackboxed line"
);
const popup = await openContextMenuInDebugger(
dbg,
"gutter",
blackboxedLine
);
// When the whole source is blackboxed the the gutter visually shows `ignore line`
// but it is disabled indicating that individual lines cannot be nonBlackboxed.
const item =
blackboxedSourceState == SOURCE_IS_FULLY_IGNORED
? contextMenuItems.ignoreLine
: contextMenuItems.unignoreLine;
await assertContextMenuLabel(dbg, item.selector, item.label);
await assertContextMenuDisabled(
dbg,
item.selector,
blackboxedSourceState == SOURCE_IS_FULLY_IGNORED
);
await closeContextMenu(dbg, popup);
}
if (nonBlackBoxedLine) {
info(
"Asserts that the gutter context menu items when clicking on the gutter of a nonBlackboxed line"
);
const popup = await openContextMenuInDebugger(
dbg,
"gutter",
nonBlackBoxedLine
);
const item = contextMenuItems.ignoreLine;
await assertContextMenuLabel(dbg, item.selector, item.label);
await assertContextMenuDisabled(dbg, item.selector, false);
await closeContextMenu(dbg, popup);
}
}
/**
* Asserts that the source tree blackbox context menu items which are visible are correct
* @params {Object} dbg
* @params {Array} testFixtures
* Details needed for the assertion. Any blackboxed/nonBlackboxed sources
*/
async function assertSourceTreeBlackBoxBoxContextMenuItems(dbg, testFixtures) {
const { blackBoxedSourceTreeNode, nonBlackBoxedSourceTreeNode } =
testFixtures;
if (blackBoxedSourceTreeNode) {
info(
"Asserts that the source tree blackbox context menu items when clicking on a blackboxed source tree node"
);
rightClickEl(dbg, blackBoxedSourceTreeNode);
const popup = await waitForContextMenu(dbg);
const item = contextMenuItems.unignoreSource;
await assertContextMenuLabel(dbg, item.selector, item.label);
await closeContextMenu(dbg, popup);
}
if (nonBlackBoxedSourceTreeNode) {
info(
"Asserts that the source tree blackbox context menu items when clicking on an un-blackboxed sorce tree node"
);
rightClickEl(dbg, nonBlackBoxedSourceTreeNode);
const popup = await waitForContextMenu(dbg);
const _item = contextMenuItems.ignoreSource;
await assertContextMenuLabel(dbg, _item.selector, _item.label);
await closeContextMenu(dbg, popup);
}
}
/**
* Asserts that the editor blackbox context menu items which are visible are correct
* @params {Object} dbg
* @params {Array} testFixtures
* Details needed for the assertion. Any blackboxed/nonBlackboxed lines
* and any blackboxed/nonBlackboxed sources
*/
async function assertEditorBlackBoxBoxContextMenuItems(dbg, testFixtures) {
const {
blackboxedLine,
nonBlackBoxedLine,
blackBoxedLines,
nonBlackBoxedLines,
blackboxedSourceState,
} = testFixtures;
if (blackboxedLine) {
info(
"Asserts the editor blackbox context menu items when right-clicking on a single blackboxed line"
);
const popup = await selectEditorLinesAndOpenContextMenu(dbg, {
startLine: blackboxedLine,
});
const expectedContextMenuItems = [contextMenuItems.unignoreSource];
if (blackboxedSourceState !== SOURCE_IS_FULLY_IGNORED) {
expectedContextMenuItems.push(contextMenuItems.unignoreLine);
}
for (const expectedContextMenuItem of expectedContextMenuItems) {
info(
"Checking context menu item " +
expectedContextMenuItem.selector +
" with label " +
expectedContextMenuItem.label
);
await assertContextMenuLabel(
dbg,
expectedContextMenuItem.selector,
expectedContextMenuItem.label
);
}
await closeContextMenu(dbg, popup);
}
if (nonBlackBoxedLine) {
info(
"Asserts the editor blackbox context menu items when right-clicking on a single non-blackboxed line"
);
const popup = await selectEditorLinesAndOpenContextMenu(dbg, {
startLine: nonBlackBoxedLine,
});
const expectedContextMenuItems = [
blackboxedSourceState == SOURCE_IS_NOT_IGNORED
? contextMenuItems.ignoreSource
: contextMenuItems.unignoreSource,
contextMenuItems.ignoreLine,
];
for (const expectedContextMenuItem of expectedContextMenuItems) {
info(
"Checking context menu item " +
expectedContextMenuItem.selector +
" with label " +
expectedContextMenuItem.label
);
await assertContextMenuLabel(
dbg,
expectedContextMenuItem.selector,
expectedContextMenuItem.label
);
}
await closeContextMenu(dbg, popup);
}
if (blackBoxedLines) {
info(
"Asserts the editor blackbox context menu items when right-clicking on multiple blackboxed lines"
);
const popup = await selectEditorLinesAndOpenContextMenu(dbg, {
startLine: blackBoxedLines[0],
endLine: blackBoxedLines[1],
});
const expectedContextMenuItems = [contextMenuItems.unignoreSource];
if (blackboxedSourceState !== SOURCE_IS_FULLY_IGNORED) {
expectedContextMenuItems.push(contextMenuItems.unignoreLines);
}
for (const expectedContextMenuItem of expectedContextMenuItems) {
info(
"Checking context menu item " +
expectedContextMenuItem.selector +
" with label " +
expectedContextMenuItem.label
);
await assertContextMenuLabel(
dbg,
expectedContextMenuItem.selector,
expectedContextMenuItem.label
);
}
await closeContextMenu(dbg, popup);
}
if (nonBlackBoxedLines) {
info(
"Asserts the editor blackbox context menu items when right-clicking on multiple non-blackboxed lines"
);
const popup = await selectEditorLinesAndOpenContextMenu(dbg, {
startLine: nonBlackBoxedLines[0],
endLine: nonBlackBoxedLines[1],
});
const expectedContextMenuItems = [
blackboxedSourceState == SOURCE_IS_NOT_IGNORED
? contextMenuItems.ignoreSource
: contextMenuItems.unignoreSource,
];
if (blackboxedSourceState !== SOURCE_IS_FULLY_IGNORED) {
expectedContextMenuItems.push(contextMenuItems.ignoreLines);
}
for (const expectedContextMenuItem of expectedContextMenuItems) {
info(
"Checking context menu item " +
expectedContextMenuItem.selector +
" with label " +
expectedContextMenuItem.label
);
await assertContextMenuLabel(
dbg,
expectedContextMenuItem.selector,
expectedContextMenuItem.label
);
}
await closeContextMenu(dbg, popup);
}
}
/**
* Selects a range of lines
* @param {Object} dbg
* @param {Number} startLine
* @param {Number} endLine
*/
function selectEditorLines(dbg, startLine, endLine) {
getCM(dbg).setSelection(
{ line: startLine - 1, ch: 0 },
{ line: endLine, ch: 0 }
);
}
|