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
|
/* 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/>. */
// Test enabling and disabling a breakpoint using the check boxes
"use strict";
add_task(async function () {
const dbg = await initDebugger("doc-scripts.html", "simple2.js");
// Create two breakpoints
await selectSource(dbg, "simple2.js");
await addBreakpoint(dbg, "simple2.js", 3);
await addBreakpoint(dbg, "simple2.js", 5);
// Disable the first one
await disableBreakpoint(dbg, 0);
let bp1 = findBreakpoint(dbg, "simple2.js", 3);
let bp2 = findBreakpoint(dbg, "simple2.js", 5);
is(bp1.disabled, true, "first breakpoint is disabled");
is(bp2.disabled, false, "second breakpoint is enabled");
// Disable and Re-Enable the second one
await disableBreakpoint(dbg, 1);
await enableBreakpoint(dbg, 1);
bp2 = findBreakpoint(dbg, "simple2.js", 5);
is(bp2.disabled, false, "second breakpoint is enabled");
// Cleanup
await cleanupBreakpoints(dbg);
// Test enabling and disabling a breakpoint using the context menu
await selectSource(dbg, "simple2.js");
await addBreakpoint(dbg, "simple2.js", 3);
await addBreakpoint(dbg, "simple2.js", 5);
assertBreakpointSnippet(dbg, 3, "return x + y;");
rightClickElement(dbg, "breakpointItem", 2);
await waitForContextMenu(dbg);
const disableBreakpointDispatch = waitForDispatch(
dbg.store,
"SET_BREAKPOINT"
);
selectContextMenuItem(dbg, selectors.breakpointContextMenu.disableSelf);
await disableBreakpointDispatch;
bp1 = findBreakpoint(dbg, "simple2.js", 3);
bp2 = findBreakpoint(dbg, "simple2.js", 5);
is(bp1.disabled, true, "first breakpoint is disabled");
is(bp2.disabled, false, "second breakpoint is enabled");
rightClickElement(dbg, "breakpointItem", 2);
await waitForContextMenu(dbg);
const enableBreakpointDispatch = waitForDispatch(dbg.store, "SET_BREAKPOINT");
selectContextMenuItem(dbg, selectors.breakpointContextMenu.enableSelf);
await enableBreakpointDispatch;
bp1 = findBreakpoint(dbg, "simple2.js", 3);
bp2 = findBreakpoint(dbg, "simple2.js", 5);
is(bp1.disabled, false, "first breakpoint is enabled");
is(bp2.disabled, false, "second breakpoint is enabled");
// Cleanup
await cleanupBreakpoints(dbg);
// Test creation of disabled breakpoint with shift-click
await shiftClickElement(dbg, "gutter", 3);
await waitForBreakpoint(dbg, "simple2.js", 3);
const bp = findBreakpoint(dbg, "simple2.js", 3);
is(bp.disabled, true, "breakpoint is disabled");
// Cleanup
await cleanupBreakpoints(dbg);
});
function toggleBreakpoint(dbg, index) {
const bp = findAllElements(dbg, "breakpointItems")[index];
const input = bp.querySelector("input");
input.click();
}
async function disableBreakpoint(dbg, index) {
const disabled = waitForDispatch(dbg.store, "SET_BREAKPOINT");
toggleBreakpoint(dbg, index);
await disabled;
}
async function enableBreakpoint(dbg, index) {
const enabled = waitForDispatch(dbg.store, "SET_BREAKPOINT");
toggleBreakpoint(dbg, index);
await enabled;
}
async function cleanupBreakpoints(dbg) {
clickElement(dbg, "gutter", 3);
clickElement(dbg, "gutter", 5);
await waitForBreakpointRemoved(dbg, "simple2.js", 3);
await waitForBreakpointRemoved(dbg, "simple2.js", 5);
}
|