2016-10-31 06:07:28 +03:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
|
2017-03-04 02:34:00 +03:00
|
|
|
function toggleBreakpoint(dbg, index) {
|
|
|
|
const bp = findElement(dbg, "breakpointItem", index);
|
|
|
|
const input = bp.querySelector("input");
|
|
|
|
input.click();
|
|
|
|
}
|
|
|
|
|
2017-09-07 05:27:41 +03:00
|
|
|
async function removeBreakpoint(dbg, index) {
|
|
|
|
const removed = waitForDispatch(dbg, "REMOVE_BREAKPOINT");
|
|
|
|
const bp = findElement(dbg, "breakpointItem", index);
|
|
|
|
bp.querySelector(".close-btn").click();
|
|
|
|
await removed;
|
2017-03-04 02:34:00 +03:00
|
|
|
}
|
|
|
|
|
2017-09-07 05:27:41 +03:00
|
|
|
async function disableBreakpoint(dbg, index) {
|
|
|
|
const disabled = waitForDispatch(dbg, "DISABLE_BREAKPOINT");
|
|
|
|
toggleBreakpoint(dbg, index);
|
|
|
|
await disabled;
|
2017-03-04 02:34:00 +03:00
|
|
|
}
|
|
|
|
|
2017-09-07 05:27:41 +03:00
|
|
|
async function enableBreakpoint(dbg, index) {
|
|
|
|
const enabled = waitForDispatch(dbg, "ENABLE_BREAKPOINT");
|
|
|
|
toggleBreakpoint(dbg, index);
|
|
|
|
await enabled;
|
2017-03-04 02:34:00 +03:00
|
|
|
}
|
|
|
|
|
2017-07-21 03:08:00 +03:00
|
|
|
function toggleBreakpoints(dbg, count) {
|
|
|
|
clickElement(dbg, "toggleBreakpoints");
|
|
|
|
}
|
|
|
|
|
|
|
|
function disableBreakpoints(dbg, count) {
|
2017-09-07 05:27:41 +03:00
|
|
|
const toggled = waitForDispatch(dbg, "DISABLE_BREAKPOINT", count);
|
2017-07-21 03:08:00 +03:00
|
|
|
toggleBreakpoints(dbg);
|
2017-09-07 05:27:41 +03:00
|
|
|
return toggled;
|
2017-07-21 03:08:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function enableBreakpoints(dbg, count) {
|
2017-09-07 05:27:41 +03:00
|
|
|
const enabled = waitForDispatch(dbg, "ENABLE_BREAKPOINT", count);
|
2017-07-21 03:08:00 +03:00
|
|
|
toggleBreakpoints(dbg);
|
2017-09-07 05:27:41 +03:00
|
|
|
return enabled;
|
2017-03-04 02:34:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function findBreakpoint(dbg, url, line) {
|
|
|
|
const { selectors: { getBreakpoint }, getState } = dbg;
|
|
|
|
const source = findSource(dbg, url);
|
|
|
|
return getBreakpoint(getState(), { sourceId: source.id, line });
|
|
|
|
}
|
|
|
|
|
|
|
|
function findBreakpoints(dbg) {
|
|
|
|
const { selectors: { getBreakpoints }, getState } = dbg;
|
|
|
|
return getBreakpoints(getState());
|
|
|
|
}
|
|
|
|
|
2017-09-07 05:27:41 +03:00
|
|
|
add_task(async function() {
|
|
|
|
const dbg = await initDebugger("doc-scripts.html");
|
2017-03-04 02:34:00 +03:00
|
|
|
|
|
|
|
// Create two breakpoints
|
2017-09-07 05:27:41 +03:00
|
|
|
await selectSource(dbg, "simple2");
|
|
|
|
await addBreakpoint(dbg, "simple2", 3);
|
|
|
|
await addBreakpoint(dbg, "simple2", 5);
|
2017-03-04 02:34:00 +03:00
|
|
|
|
|
|
|
// Disable the first one
|
2017-09-07 05:27:41 +03:00
|
|
|
await disableBreakpoint(dbg, 1);
|
2017-03-04 02:34:00 +03:00
|
|
|
let bp1 = findBreakpoint(dbg, "simple2", 3);
|
|
|
|
let bp2 = findBreakpoint(dbg, "simple2", 5);
|
|
|
|
is(bp1.disabled, true, "first breakpoint is disabled");
|
|
|
|
is(bp2.disabled, false, "second breakpoint is enabled");
|
|
|
|
|
|
|
|
// Disable and Re-Enable the second one
|
2017-09-07 05:27:41 +03:00
|
|
|
await disableBreakpoint(dbg, 2);
|
|
|
|
await enableBreakpoint(dbg, 2);
|
2017-03-04 02:34:00 +03:00
|
|
|
bp2 = findBreakpoint(dbg, "simple2", 5);
|
|
|
|
is(bp2.disabled, false, "second breakpoint is enabled");
|
2016-11-11 07:47:23 +03:00
|
|
|
});
|