blob: 56d5c0259d8025e07e35f81dc035a55e25ef6f6c [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 src="resources/breakpoint-options-utilities.js"></script>
<script>
TestPage.allowUncaughtExceptions = true;
function triggerException() {
queueMicrotask(() => {
TestPage.dispatchEventToFrontend("TestPage-exception");
});
throw "TestError";
}
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();
});
}
});
InspectorTest.BreakpointOptions.addTestCases(suite, {
createBreakpoint() {
WI.debuggerManager.uncaughtExceptionsBreakpoint.disabled = false;
return WI.debuggerManager.uncaughtExceptionsBreakpoint;
},
triggerBreakpoint() {
return Promise.all([
InspectorTest.evaluateInPage(`queueMicrotask(triggerException)`),
InspectorTest.awaitEvent("TestPage-exception"),
]);
},
});
suite.runTestCasesAndFinish();
}
</script>
</head>
<body onload="runTest()">
<p>Checking pause locations when pausing on uncaught exceptions.</p>
</body>
</html>