blob: c6652567fb2500840825a8cf4f77087f62e91577 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
<script src="resources/break-on-exception-tests.js"></script>
<script>
TestPage.allowUncaughtExceptions = true;
function test()
{
WI.debuggerManager.uncaughtExceptionsBreakpoint.disabled = false;
let suite = InspectorTest.createAsyncSuite("BreakOnUncaughtException");
function addTestCase({name, description, expression}) {
suite.addTestCase({
name, description,
test(resolve, reject) {
InspectorTest.evaluateInPage(expression);
WI.debuggerManager.singleFireEventListener(WI.DebuggerManager.Event.Paused, (event) => {
let targetData = WI.debuggerManager.dataForTarget(WI.debuggerManager.activeCallFrame.target);
InspectorTest.expectThat(targetData.pauseReason === "exception", "Should pause for exception.");
let callFrame = WI.debuggerManager.activeCallFrame;
let name = callFrame.functionName || "<anonymous>";
let location = callFrame.sourceCodeLocation;
let line = location.lineNumber + 1;
let column = location.columnNumber + 1;
InspectorTest.log(`PAUSE AT ${name}:${line}:${column}`);
WI.debuggerManager.resume().then(resolve, reject);
});
}
});
}
addTestCase({
name: "BreakOnUncaughtException.UncaughtExceptionBasic",
description: "Break on an uncaught exception thrown in a function.",
expression: "setTimeout(doThrow)",
});
addTestCase({
name: "BreakOnUncaughtException.UncaughtExceptionInFinally",
description: "Break on an uncaught exception thrown in a finally block.",
expression: "setTimeout(testFinally)",
});
addTestCase({
name: "BreakOnUncaughtException.UncaughtExceptionThruNativeCode",
description: "Break on an uncaught exception thrown thru native code (Map.prototype.forEach).",
expression: "setTimeout(testThrowingThruNativeCode)",
});
suite.addTestCase({
name: "BreakOnUncaughtException.CaughtException",
description: "No break on a caught exception.",
test(resolve, reject) {
InspectorTest.evaluateInPage(`setTimeout(() => {
testCatch();
TestPage.dispatchEventToFrontend("AfterTestFunction");
})`);
let listener = WI.debuggerManager.singleFireEventListener(WI.DebuggerManager.Event.Paused, (event) => {
InspectorTest.fail("Should not have paused.");
WI.debuggerManager.resume();
reject();
});
InspectorTest.singleFireEventListener("AfterTestFunction", (event) => {
InspectorTest.pass("Should not pause, exception was caught.");
WI.debuggerManager.removeEventListener(WI.DebuggerManager.Event.Paused, listener);
resolve();
});
}
});
suite.runTestCasesAndFinish();
}
</script>
</head>
<body onload="runTest()">
<p>Checking pause locations when pausing on uncaught exceptions.</p>
</body>
</html>