Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/reducers/pause.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export function pausedInEval(state: OuterState) {
}

const exception = state.pause.pause.why.exception;
if (!exception) {
if (!exception || !exception.preview) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was recently added and not well tested before

return false;
}

Expand Down
6 changes: 0 additions & 6 deletions src/test/mochitest/browser.ini
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,13 @@ support-files =
[browser_dbg-breakpoints.js]
[browser_dbg-breakpoints-toggle.js]
[browser_dbg-breakpoints-reloading.js]
skip-if = true # Bug 1383576
[browser_dbg-breakpoints-cond.js]
[browser_dbg-browser-content-toolbox.js]
skip-if = !e10s # This test is only valid in e10s
[browser_dbg-call-stack.js]
[browser_dbg-scopes.js]
[browser_dbg-chrome-create.js]
[browser_dbg-chrome-debugging.js]
skip-if = debug # bug 1374187
[browser_dbg-console.js]
[browser_dbg-debugger-buttons.js]
[browser_dbg-editor-gutter.js]
Expand All @@ -87,7 +85,6 @@ skip-if = debug # bug 1374187
skip-if = os == "linux" # bug 1351952
[browser_dbg-layout-changes.js]
[browser_dbg-pause-exceptions.js]
skip-if = true # Bug 1393121
[browser_dbg-navigation.js]
[browser_dbg-minified.js]
[browser_dbg-pretty-print.js]
Expand All @@ -97,9 +94,7 @@ skip-if = true # Bug 1393121
[browser_dbg-search-file.js]
skip-if = os == "win" # Bug 1393121
[browser_dbg-quick-open.js]
skip-if = true
[browser_dbg-search-project.js]
skip-if = true # Bug 1393121, 1393299
[browser_dbg-sourcemaps.js]
[browser_dbg-sourcemaps-reloading.js]
[browser_dbg-sourcemaps2.js]
Expand All @@ -108,5 +103,4 @@ skip-if = true # Bug 1393121, 1393299
[browser_dbg-tabs.js]
[browser_dbg-toggling-tools.js]
[browser_dbg-wasm-sourcemaps.js]
skip-if = true
[browser_dbg-reload.js]
16 changes: 12 additions & 4 deletions src/test/mochitest/browser_dbg-pause-exceptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,34 @@ function caughtException() {
add_task(async function() {
const dbg = await initDebugger("doc-exceptions.html");

// test skipping an uncaught exception
log("1. test skipping an uncaught exception");
await uncaughtException();
ok(!isPaused(dbg));

// Test pausing on an uncaught exception
log("2. Test pausing on an uncaught exception");
await togglePauseOnExceptions(dbg, true, false);
uncaughtException();
await waitForPaused(dbg);
assertPausedLocation(dbg);
await resume(dbg);
await waitForActive(dbg);

// Test pausing on a caught Error
log("3. Test pausing on a caught Error");
caughtException();
await waitForPaused(dbg);
assertPausedLocation(dbg);

log("3.b Test pausing in the catch statement");
await resume(dbg);
await waitForPaused(dbg);
assertPausedLocation(dbg);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we had previously been sloppy w/ this test and had allowed togglePauseOnExceptions to do an implicit resume, which was creating a race condition.

await resume(dbg);

// Test skipping a caught error
log("4. Test skipping a caught error");
await togglePauseOnExceptions(dbg, true, true);
caughtException();

log("4.b Test pausing in the catch statement");
await waitForPaused(dbg);
assertPausedLocation(dbg);
await resume(dbg);
Expand Down
55 changes: 37 additions & 18 deletions src/test/mochitest/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,15 @@ registerCleanupFunction(() => {
});

function log(msg, data) {
info(`${msg} ${JSON.stringify(data)}`);
info(`${msg} ${!data ? "" : JSON.stringify(data)}`);
}

function logThreadEvents(dbg, event) {
const thread = dbg.toolbox.threadClient;

thread.addListener(event, function onEvent(eventName, ...args) {
info(`Thread event '${eventName}' fired.`);
});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a new log that is helpful for debugging

}

// Wait until an action of `type` is dispatched. This is different
Expand Down Expand Up @@ -113,11 +121,11 @@ function waitForDispatch(dbg, type, eventRepeat = 1) {
let count = 0;

return Task.spawn(function*() {
info("Waiting for " + type + " to dispatch " + eventRepeat + " time(s)");
info(`Waiting for ${type} to dispatch ${eventRepeat} time(s)`);
while (count < eventRepeat) {
yield _afterDispatchDone(dbg.store, type);
count++;
info(type + " dispatched " + count + " time(s)");
info(`${type} dispatched ${count} time(s)`);
}
});
}
Expand All @@ -132,12 +140,12 @@ function waitForDispatch(dbg, type, eventRepeat = 1) {
* @static
*/
function waitForThreadEvents(dbg, eventName) {
info("Waiting for thread event '" + eventName + "' to fire.");
info(`Waiting for thread event '${eventName}' to fire.`);
const thread = dbg.toolbox.threadClient;

return new Promise(function(resolve, reject) {
thread.addListener(eventName, function onEvent(eventName, ...args) {
info("Thread event '" + eventName + "' fired.");
info(`Thread event '${eventName}' fired.`);
thread.removeListener(eventName, onEvent);
resolve.apply(resolve, args);
});
Expand Down Expand Up @@ -184,7 +192,7 @@ function waitForSources(dbg, ...sources) {
return Promise.resolve();
}

info("Waiting on sources: " + sources.join(", "));
info(`Waiting on sources: ${sources.join(", ")}`);
const { selectors: { getSources }, store } = dbg;
return Promise.all(
sources.map(url => {
Expand Down Expand Up @@ -339,6 +347,14 @@ function isPaused(dbg) {
return !!getPause(getState());
}

async function waitForLoadedObjects(dbg) {
const { hasLoadingObjects } = dbg.selectors;
return waitForState(
dbg,
state => !hasLoadingObjects(state),
"loaded objects"
);
}
/**
* Waits for the debugger to be fully paused.
*
Expand All @@ -355,9 +371,7 @@ async function waitForPaused(dbg) {
const paused = isPaused(dbg);
const scope = !!getSelectedScope(state);
const loaded = !hasLoadingObjects(state);
return (
isPaused(dbg) && getSelectedScope(state) && !hasLoadingObjects(state)
);
return paused && scope && loaded;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:)

},
"paused"
);
Expand Down Expand Up @@ -486,7 +500,7 @@ function findSource(dbg, url) {
const source = sources.find(s => (s.get("url") || "").includes(url));

if (!source) {
throw new Error("Unable to find source: " + url);
throw new Error(`Unable to find source: ${url}`);
}

return source.toJS();
Expand All @@ -496,7 +510,7 @@ function waitForLoadedSource(dbg, url) {
return waitForState(
dbg,
state => findSource(dbg, url).loadedState == "loaded",
`loaded source`
"loaded source"
);
}

Expand All @@ -511,13 +525,13 @@ function waitForLoadedSource(dbg, url) {
* @static
*/
function selectSource(dbg, url, line) {
info("Selecting source: " + url);
info(`Selecting source: ${url}`);
const source = findSource(dbg, url);
return dbg.actions.selectSource(source.id, { location: { line } });
}

function closeTab(dbg, url) {
info("Closing tab: " + url);
info(`Closing tab: ${url}`);
const source = findSource(dbg, url);
return dbg.actions.closeTab(source.url);
}
Expand Down Expand Up @@ -662,7 +676,7 @@ function removeBreakpoint(dbg, sourceId, line, col) {
* @return {Promise}
* @static
*/
function togglePauseOnExceptions(
async function togglePauseOnExceptions(
dbg,
pauseOnExceptions,
ignoreCaughtExceptions
Expand All @@ -673,12 +687,17 @@ function togglePauseOnExceptions(
);

if (!isPaused(dbg)) {
return waitForThreadEvents(dbg, "resumed");
await waitForThreadEvents(dbg, "resumed");
await waitForLoadedObjects(dbg);
}

return command;
}

function waitForActive(dbg) {
return waitForState(dbg, state => !dbg.selectors.isPaused(state), "active");
}

// Helpers

/**
Expand Down Expand Up @@ -795,7 +814,7 @@ const selectors = {
highlightLine: ".CodeMirror-code > .highlight-line",
codeMirror: ".CodeMirror",
resume: ".resume.active",
sourceTabs: `.source-tabs`,
sourceTabs: ".source-tabs",
stepOver: ".stepOver.active",
stepOut: ".stepOut.active",
stepIn: ".stepIn.active",
Expand All @@ -806,8 +825,8 @@ const selectors = {
sourceNode: i => `.sources-list .tree-node:nth-child(${i})`,
sourceNodes: ".sources-list .tree-node",
sourceArrow: i => `.sources-list .tree-node:nth-child(${i}) .arrow`,
resultItems: `.result-list .result-item`,
fileMatch: `.managed-tree .result`
resultItems: ".result-list .result-item",
fileMatch: ".managed-tree .result"
};

function getSelector(elementName, ...args) {
Expand Down