blob: 4e089bce4b21b99a473e454d05c2470c32996031 [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 "a"; }
function b() { return "b"; }
function c() { return "c"; }
function testStatements() {
debugger;
let x = 1;
let y = 2;
}
function testFunctions() {
debugger;
let before = 1;
a();
let after = 2;
}
function testEval() {
debugger;
let before = 1;
eval("1 + 1");
let after = 2;
}
function testAnonymousFunction() {
(function() {
debugger;
let inner = 1;
})();
let outer = 2;
}
function testCommas() {
debugger;
let x = 1,
y = 2,
z = 3;
a(), b(), c();
true && (a(), b(), c()) && true;
}
function testChainedExpressions() {
debugger;
a() && b() && c();
}
function testDeclarations() {
debugger;
let x = a(),
y = b(),
z = c();
}
function testInnerFunction() {
function alpha() {
beta();
}
function beta() {
debugger;
}
alpha();
}
// ---------
function test()
{
let suite = InspectorTest.createAsyncSuite("Debugger.stepOver");
// Always step-over when call frames change.
WI.debuggerManager.addEventListener(WI.DebuggerManager.Event.CallFramesDidChange, (event) => {
if (!WI.debuggerManager.activeCallFrame)
return;
logPauseLocation();
WI.debuggerManager.stepOver();
});
function addTestCase({name, description, expression}) {
suite.addTestCase({
name, description,
test(resolve, reject) {
InspectorTest.evaluateInPage(expression);
WI.debuggerManager.singleFireEventListener(WI.DebuggerManager.Event.Paused, (event) => {
InspectorTest.log(`PAUSED (${WI.debuggerManager.dataForTarget(WI.debuggerManager.activeCallFrame.target).pauseReason})`);
});
WI.debuggerManager.singleFireEventListener(WI.DebuggerManager.Event.Resumed, (event) => {
InspectorTest.log("RESUMED");
resolve();
});
}
});
}
addTestCase({
name: "Debugger.stepOver.statements",
description: "step-over should step over statements.",
expression: "setTimeout(testStatements)",
});
addTestCase({
name: "Debugger.stepOver.functions",
description: "step-over should step over function calls.",
expression: "setTimeout(testFunctions)",
});
addTestCase({
name: "Debugger.stepOver.eval",
description: "step-over should step over an eval program.",
expression: "setTimeout(testEval)",
});
addTestCase({
name: "Debugger.stepOver.anonymousFunction",
description: "step-over should step out of a function to its caller.",
expression: "setTimeout(testAnonymousFunction)",
});
addTestCase({
name: "Debugger.stepOver.commas",
description: "step-over should step over comma expressions, treating them as statements.",
expression: "setTimeout(testCommas)",
});
addTestCase({
name: "Debugger.stepOver.chainedExpressions",
description: "step-over should step over chained expressions as a single statement.",
expression: "setTimeout(testChainedExpressions)",
});
addTestCase({
name: "Debugger.stepOver.declarations",
description: "step-over should step over each declaration.",
expression: "setTimeout(testDeclarations)",
});
addTestCase({
name: "Debugger.stepOver.innerFunction",
description: "step-over should step out of a function to its caller.",
expression: "setTimeout(testInnerFunction)",
});
loadMainPageContent().then(() => {
suite.runTestCasesAndFinish();
});
}
</script>
</head>
<body onload="runTest()">
<p>Checking pause locations when stepping with "stepOver".</p>
</body>
</html>