From a907958e2207848b778301966e970917652cda50 Mon Sep 17 00:00:00 2001 From: Jason Laster Date: Mon, 6 Nov 2017 11:02:24 -0500 Subject: [PATCH] Re-enable tests (#4564) --- src/reducers/pause.js | 2 +- src/test/mochitest/browser.ini | 6 -- .../mochitest/browser_dbg-pause-exceptions.js | 16 ++++-- src/test/mochitest/head.js | 55 +++++++++++++------ 4 files changed, 50 insertions(+), 29 deletions(-) diff --git a/src/reducers/pause.js b/src/reducers/pause.js index 03f77a846b..b68b2b38b4 100644 --- a/src/reducers/pause.js +++ b/src/reducers/pause.js @@ -202,7 +202,7 @@ export function pausedInEval(state: OuterState) { } const exception = state.pause.pause.why.exception; - if (!exception) { + if (!exception || !exception.preview) { return false; } diff --git a/src/test/mochitest/browser.ini b/src/test/mochitest/browser.ini index ff94225fa5..dd1b845192 100644 --- a/src/test/mochitest/browser.ini +++ b/src/test/mochitest/browser.ini @@ -65,7 +65,6 @@ 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 @@ -73,7 +72,6 @@ skip-if = !e10s # This test is only valid in e10s [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] @@ -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] @@ -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] @@ -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] diff --git a/src/test/mochitest/browser_dbg-pause-exceptions.js b/src/test/mochitest/browser_dbg-pause-exceptions.js index 8cd5808762..c6c5a80dd8 100644 --- a/src/test/mochitest/browser_dbg-pause-exceptions.js +++ b/src/test/mochitest/browser_dbg-pause-exceptions.js @@ -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); 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); diff --git a/src/test/mochitest/head.js b/src/test/mochitest/head.js index d7391e632d..c5ff74f673 100644 --- a/src/test/mochitest/head.js +++ b/src/test/mochitest/head.js @@ -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.`); + }); } // Wait until an action of `type` is dispatched. This is different @@ -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)`); } }); } @@ -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); }); @@ -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 => { @@ -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. * @@ -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; }, "paused" ); @@ -504,7 +518,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(); @@ -514,7 +528,7 @@ function waitForLoadedSource(dbg, url) { return waitForState( dbg, state => findSource(dbg, url).loadedState == "loaded", - `loaded source` + "loaded source" ); } @@ -529,13 +543,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); } @@ -680,7 +694,7 @@ function removeBreakpoint(dbg, sourceId, line, col) { * @return {Promise} * @static */ -function togglePauseOnExceptions( +async function togglePauseOnExceptions( dbg, pauseOnExceptions, ignoreCaughtExceptions @@ -691,12 +705,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 /** @@ -813,7 +832,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", @@ -824,8 +843,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) {