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
|
/* 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/>. */
"use strict";
// Tests to see if we can trigger a breakpoint action via the context menu
add_task(async function () {
const dbg = await initDebugger("doc-scripts.html", "simple2.js");
await selectSource(dbg, "simple2.js");
await waitForSelectedSource(dbg, "simple2.js");
await addBreakpoint(dbg, "simple2.js", 3);
await openFirstBreakpointContextMenu(dbg);
// select "Remove breakpoint"
selectContextMenuItem(dbg, selectors.breakpointContextMenu.remove);
await waitForState(dbg, () => dbg.selectors.getBreakpointCount() === 0);
ok(true, "successfully removed the breakpoint");
});
// Tests "disable others", "enable others" and "remove others" context actions
add_task(async function () {
const dbg = await initDebugger("doc-scripts.html");
await selectSource(dbg, "simple1.js");
await waitForSelectedSource(dbg, "simple1.js");
await addBreakpoint(dbg, "simple1.js", 4);
await addBreakpoint(dbg, "simple1.js", 5);
await addBreakpoint(dbg, "simple1.js", 6);
await openFirstBreakpointContextMenu(dbg);
// select "Disable Others"
let dispatched = waitForDispatch(dbg.store, "SET_BREAKPOINT", 2);
selectContextMenuItem(dbg, selectors.breakpointContextMenu.disableOthers);
await waitForState(dbg, () =>
dbg.selectors
.getBreakpointsList()
.every(bp => (bp.location.line !== 4) === bp.disabled)
);
await dispatched;
ok(true, "breakpoint at 4 is the only enabled breakpoint");
await openFirstBreakpointContextMenu(dbg);
// select "Disable All"
dispatched = waitForDispatch(dbg.store, "SET_BREAKPOINT");
selectContextMenuItem(dbg, selectors.breakpointContextMenu.disableAll);
await waitForState(dbg, () =>
dbg.selectors.getBreakpointsList().every(bp => bp.disabled)
);
await dispatched;
ok(true, "all breakpoints are disabled");
await openFirstBreakpointContextMenu(dbg);
// select "Enable Others"
dispatched = waitForDispatch(dbg.store, "SET_BREAKPOINT", 2);
selectContextMenuItem(dbg, selectors.breakpointContextMenu.enableOthers);
await waitForState(dbg, () =>
dbg.selectors
.getBreakpointsList()
.every(bp => (bp.location.line === 4) === bp.disabled)
);
await dispatched;
ok(true, "all breakpoints except line 1 are enabled");
await openFirstBreakpointContextMenu(dbg);
// select "Remove Others"
dispatched = waitForDispatch(dbg.store, "REMOVE_BREAKPOINT", 2);
selectContextMenuItem(dbg, selectors.breakpointContextMenu.removeOthers);
await waitForState(
dbg,
() =>
dbg.selectors.getBreakpointsList().length === 1 &&
dbg.selectors.getBreakpointsList()[0].location.line === 4
);
await dispatched;
ok(true, "remaining breakpoint should be on line 4");
});
async function openFirstBreakpointContextMenu(dbg) {
rightClickElement(dbg, "breakpointItem", 2);
await waitForContextMenu(dbg);
}
|