Commit 811f83e6 authored by Jason Laster's avatar Jason Laster
Browse files

Bug 1448431 - Don't pause on console expression exceptions. r=jimb

MozReview-Commit-ID: JrQjvtBy3LP
parent f24699c2
......@@ -22,11 +22,11 @@ function getValue(dbg, index) {
}
async function addExpression(dbg, input) {
info("Adding an expression");
const evaluation = waitForDispatch(dbg, "EVALUATE_EXPRESSION");
findElementWithSelector(dbg, expressionSelectors.input).focus();
type(dbg, input);
pressKey(dbg, "Enter");
await waitForDispatch(dbg, "EVALUATE_EXPRESSION");
await evaluation;
}
async function editExpression(dbg, input) {
......@@ -40,37 +40,17 @@ async function editExpression(dbg, input) {
await evaluation;
}
/*
* When we add a bad expression, we'll pause,
* resume, and wait for the expression to finish being evaluated.
*/
async function addBadExpression(dbg, input) {
const evaluation = waitForDispatch(dbg, "EVALUATE_EXPRESSION");
findElementWithSelector(dbg, expressionSelectors.input).focus();
type(dbg, input);
pressKey(dbg, "Enter");
await waitForPaused(dbg);
ok(dbg.selectors.isEvaluatingExpression(dbg.getState()));
await resume(dbg);
await evaluation;
}
add_task(async function() {
const dbg = await initDebugger("doc-script-switching.html");
const onPausedOnException = togglePauseOnExceptions(dbg, true, false);
await togglePauseOnExceptions(dbg, true, false);
// add a good expression, 2 bad expressions, and another good one
await addExpression(dbg, "location");
await addBadExpression(dbg, "foo.bar");
await addBadExpression(dbg, "foo.batt");
await addExpression(dbg, "foo.bar");
await addExpression(dbg, "foo.batt");
await addExpression(dbg, "2");
await onPausedOnException;
// check the value of
is(getValue(dbg, 2), "(unavailable)");
is(getValue(dbg, 3), "(unavailable)");
......
......@@ -1537,7 +1537,9 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
this.sources.getOriginalLocation(generatedLocation));
const url = originalSourceActor ? originalSourceActor.url : null;
if (this.sources.isBlackBoxed(url)) {
// We ignore sources without a url because we do not
// want to pause at console evaluations or watch expressions.
if (!url || this.sources.isBlackBoxed(url)) {
return undefined;
}
......
......@@ -11,46 +11,52 @@
var gDebuggee;
var gClient;
var gThreadClient;
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-stack");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function() {
attachTestTabAndResume(gClient, "test-stack",
function(response, tabClient, threadClient) {
gThreadClient = threadClient;
test_pause_frame();
});
});
do_test_pending();
run_test_with_server(DebuggerServer, function() {
run_test_with_server(WorkerDebuggerServer, do_test_finished);
});
}
function test_pause_frame() {
gThreadClient.addOneTimeListener("paused", function(event, packet) {
gThreadClient.addOneTimeListener("paused", function(event, packet) {
Assert.equal(packet.why.type, "exception");
Assert.equal(packet.why.exception, "bar");
gThreadClient.resume(function() {
finishClient(gClient);
});
});
gThreadClient.pauseOnExceptions(true, true);
gThreadClient.resume();
});
function run_test_with_server(server, callback) {
initTestDebuggerServer(server);
gDebuggee = addTestGlobal("test-pausing", server);
gClient = new DebuggerClient(server.connectPipe());
gClient.connect(test_pause_frame);
}
async function test_pause_frame() {
const [,, threadClient] = await attachTestTabAndResume(gClient, "test-pausing");
await executeOnNextTickAndWaitForPause(evaluateTestCode, gClient);
evaluateTestCode();
threadClient.pauseOnExceptions(true, true);
await resume(threadClient);
const paused = await waitForPause(gClient);
Assert.equal(paused.why.type, "exception");
equal(paused.frame.where.line, 6, "paused at throw");
await resume(threadClient);
finishClient(gClient);
}
function evaluateTestCode() {
/* eslint-disable */
try {
/* eslint-disable */
gDebuggee.eval("(" + function () {
debugger;
try {
throw "foo";
} catch (e) {}
throw "bar";
} + ")()");
/* eslint-enable */
} catch (e) {
/* Empty */
}
Cu.evalInSandbox(` // 1
debugger; // 2
try { // 3
throw "foo"; // 4
} catch (e) {} // 5
throw "bar"; // 6
`, // 7
gDebuggee,
"1.8",
"test_pause_exceptions-03.js",
1
);
} catch (e) {}
/* eslint-disable */
}
......@@ -10,47 +10,55 @@
var gDebuggee;
var gClient;
var gThreadClient;
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-no-interface");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function() {
attachTestTabAndResume(gClient, "test-no-interface",
function(response, tabClient, threadClient) {
gThreadClient = threadClient;
test_pause_frame();
});
});
do_test_pending();
run_test_with_server(DebuggerServer, function() {
run_test_with_server(WorkerDebuggerServer, do_test_finished);
});
}
function test_pause_frame() {
gThreadClient.pauseOnExceptions(true, false, function() {
gThreadClient.addOneTimeListener("paused", function(event, packet) {
Assert.equal(packet.why.type, "exception");
Assert.equal(packet.why.exception, 42);
gThreadClient.resume(function() {
finishClient(gClient);
});
});
/* eslint-disable */
gDebuggee.eval("(" + function () {
function QueryInterface() {
throw Cr.NS_ERROR_NO_INTERFACE;
}
function stopMe() {
throw 42;
}
try {
QueryInterface();
} catch (e) {}
try {
stopMe();
} catch (e) {}
} + ")()");
/* eslint-enable */
});
function run_test_with_server(server, callback) {
initTestDebuggerServer(server);
gDebuggee = addTestGlobal("test-pausing", server);
gClient = new DebuggerClient(server.connectPipe());
gClient.connect(test_pause_frame);
}
async function test_pause_frame() {
const [,, threadClient] = await attachTestTabAndResume(gClient, "test-pausing");
await threadClient.pauseOnExceptions(true, false);
await executeOnNextTickAndWaitForPause(evaluateTestCode, gClient);
await resume(threadClient);
const paused = await waitForPause(gClient);
Assert.equal(paused.why.type, "exception");
equal(paused.frame.where.line, 12, "paused at throw");
await resume(threadClient);
finishClient(gClient);
}
function evaluateTestCode() {
/* eslint-disable */
Cu.evalInSandbox(` // 1
function QueryInterface() { // 2
throw Cr.NS_ERROR_NO_INTERFACE; // 3
} // 4
function stopMe() { // 5
throw 42; // 6
} // 7
try { // 8
QueryInterface(); // 9
} catch (e) {} // 10
try { // 11
stopMe(); // 12
} catch (e) {}`, // 13
gDebuggee,
"1.8",
"test_ignore_no_interface_exceptions.js",
1
);
/* eslint-disable */
}
......@@ -30,12 +30,11 @@ function run_test() {
function test_pause_frame() {
gThreadClient.addOneTimeListener("paused", function(event, packet) {
gThreadClient.addOneTimeListener("paused", function(event, packet) {
Assert.equal(packet.why.type, "exception");
Assert.equal(packet.why.exception, 42);
gThreadClient.resume(function() {
finishClient(gClient);
});
Assert.equal(packet.why.type, "debuggerStatement");
Assert.equal(packet.frame.where.line, 9);
gThreadClient.resume(() => finishClient(gClient));
});
gThreadClient.pauseOnExceptions(true);
gThreadClient.resume();
});
......@@ -48,7 +47,9 @@ function test_pause_frame() {
}
try {
stopMe();
} catch (e) {}
} catch (e) {
debugger
}
} + ")()");
/* eslint-enable */
}
......@@ -5,7 +5,7 @@
/**
* Test that setting pauseOnExceptions to true when the debugger isn't in a
* paused state will cause the debuggee to pause when an exceptions is thrown.
* paused state will not cause the debuggee to pause when an exceptions is thrown.
*/
var gDebuggee;
......@@ -29,21 +29,21 @@ function run_test() {
function test_pause_frame() {
gThreadClient.pauseOnExceptions(true, false, function() {
gThreadClient.addOneTimeListener("paused", function(event, packet) {
Assert.equal(packet.why.type, "exception");
Assert.equal(packet.why.exception, 42);
gThreadClient.resume(function() {
finishClient(gClient);
});
Assert.equal(packet.why.type, "debuggerStatement");
Assert.equal(packet.frame.where.line, 8);
gThreadClient.resume(() => finishClient(gClient));
});
/* eslint-disable */
gDebuggee.eval("(" + function () {
function stopMe() {
throw 42;
}
try {
stopMe();
} catch (e) {}
gDebuggee.eval("(" + function () { // 1
function stopMe() { // 2
throw 42; // 3
} // 4
try { // 5
stopMe(); // 6
} catch (e) { // 7
debugger; // 8
} // 9
} + ")()");
/* eslint-enable */
});
......
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow */
"use strict";
/**
* Test that setting pauseOnExceptions to true will cause the debuggee to pause
* when an exception is thrown.
*/
var gDebuggee;
var gClient;
function run_test() {
do_test_pending();
run_test_with_server(DebuggerServer, function() {
run_test_with_server(WorkerDebuggerServer, do_test_finished);
});
}
function run_test_with_server(server, callback) {
initTestDebuggerServer(server);
gDebuggee = addTestGlobal("test-pausing", server);
gClient = new DebuggerClient(server.connectPipe());
gClient.connect(test_pause_frame);
}
async function test_pause_frame() {
const [,, threadClient] = await attachTestTabAndResume(gClient, "test-pausing");
await executeOnNextTickAndWaitForPause(evaluateTestCode, gClient);
threadClient.pauseOnExceptions(true);
await resume(threadClient);
const paused = await waitForPause(gClient);
Assert.equal(paused.why.type, "exception");
equal(paused.frame.where.line, 4, "paused at throw");
await resume(threadClient);
finishClient(gClient);
}
function evaluateTestCode() {
/* eslint-disable */
Cu.evalInSandbox(
` // 1
function stopMe() { // 2
debugger; // 3
throw 42; // 4
} // 5
try { // 6
stopMe(); // 7
} catch (e) {}`, // 8
gDebuggee,
"1.8",
"test_pause_exceptions-03.js",
1
);
/* eslint-disable */
}
\ No newline at end of file
......@@ -198,6 +198,7 @@ reason = bug 1104838
[test_framebindings-07.js]
[test_pause_exceptions-01.js]
[test_pause_exceptions-02.js]
[test_pause_exceptions-03.js]
[test_longstringactor.js]
[test_longstringgrips-01.js]
[test_longstringgrips-02.js]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment