blob: 5df430cd2ca17badaec8fa5c98132add170cc4cf [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../../http/tests/inspector/resources/inspector-test.js"></script>
<script src="../resources/log-pause-location.js"></script>
<script>
function a() {
return 1;
}
function b() {
return 1;
}
function shouldNotBeReached() {
return 0;
}
function entryTryCatchNoError() {
debugger;
try {
a();
} catch (e) {
shouldNotBeReached();
}
}
function entryTryCatchFinallyNoError() {
debugger;
try {
a();
} catch (e) {
shouldNotBeReached();
} finally {
b();
}
}
function entryTryExplicitThrow() {
debugger;
try {
throw new Error;
} catch (e) {
a();
} finally {
b();
}
}
function entryTryRuntimeException() {
debugger;
try {
[].x.x;
} catch (e) {
a();
} finally {
b();
}
}
function entryTryFinallyNoError() {
try {
a();
} finally {
b();
}
}
function entryTryFinallyWithError() {
try {
throw new Error;
} finally {
b();
}
}
// ---------
function test()
{
let suite = InspectorTest.createAsyncSuite("Debugger.stepping.try-catch-finally");
window.initializeSteppingTestSuite(suite);
addSteppingTestCase({
name: "Debugger.stepping.TryCatchNoError",
description: "Should be able to step through try/catch without error.",
expression: "setTimeout(entryTryCatchNoError)",
steps: [
"over",
"over", // try: a() - leaving entry
"resume",
]
});
addSteppingTestCase({
name: "Debugger.stepping.TryCatchFinallyNoError",
description: "Should be able to step through try/catch/finally without error.",
expression: "setTimeout(entryTryCatchFinallyNoError)",
steps: [
"over",
"over", // try: a()
"over", // finally: b() - leaving entry
"resume",
]
});
addSteppingTestCase({
name: "Debugger.stepping.TryExplicitThrow.NoPauseOnException",
description: "Should be able to step through try/catch/finally with thrown error.",
expression: "setTimeout(entryTryExplicitThrow)",
steps: [
"over",
"over", // try: new Error
"over", // catch: a()
"over", // finally: b() - leaving entry
"resume",
]
});
addSteppingTestCase({
name: "Debugger.stepping.TryExplicitThrow.PauseOnException",
description: "Should be able to step through try/catch/finally with thrown error.",
expression: "setTimeout(entryTryExplicitThrow)",
pauseOnAllException: true,
steps: [
"over",
"over", // try: new Error
"over", // EXCEPTION PAUSE
"over", // catch: a()
"over", // finally: b() - leaving entry
"resume",
]
});
addSteppingTestCase({
name: "Debugger.stepping.TryRuntimeException.NoPauseOnException",
description: "Should be able to step through try/catch/finally with runtime exception.",
expression: "setTimeout(entryTryRuntimeException)",
steps: [
"over",
"over", // try: [].x.x
"over", // catch: a()
"over", // finally: b() - leaving entry
"resume",
]
});
addSteppingTestCase({
name: "Debugger.stepping.TryRuntimeException.PauseOnException",
description: "Should be able to step through try/catch/finally with runtime exception.",
expression: "setTimeout(entryTryRuntimeException)",
pauseOnAllException: true,
steps: [
"over",
"over", // try: [].x.x
"over", // EXCEPTION PAUSE
"over", // catch: a()
"over", // finally: b() - leaving entry
"resume",
]
});
loadMainPageContent().then(() => {
suite.runTestCasesAndFinish();
});
}
</script>
</head>
<body onload="runTest()">
<p>Checking pause locations when stepping in, out, and over try/catch/finally statements.</p>
</body>
</html>