Commit e148fa29 authored by aandrey@chromium.org's avatar aandrey@chromium.org

DevTools: [Frameworks] Bugfix: do StepOut in framework code after StepIn limit is up.

Bump up the limit from 10 StepIns to 20.
Add a test on framework code.

BUG=267592
R=pfeldman, yurys

Review URL: https://codereview.chromium.org/210243002

git-svn-id: svn://svn.chromium.org/blink/trunk@169921 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 372218eb
// A framework for testing.
var Framework = {};
Framework.safeRun = function(callback, onSuccess, onException, breakOnUncaught)
{
try {
callback();
if (onSuccess)
Framework.safeRun(onSuccess, undefined, onException, breakOnUncaught);
} catch (e) {
if (onException)
Framework.safeRun(onException, undefined, breakOnUncaught ? Framework.breakInFramework : undefined);
else if (breakOnUncaught)
Framework.breakInFramework();
}
}
Framework.throwFrameworkException = function(msg)
{
throw Error("FrameworkException" + (msg ? ": " + msg : ""));
}
Framework.breakInFramework = function()
{
debugger;
}
Framework.empty = function()
{
}
Framework.doSomeWork = function()
{
const numberOfSteps = 50;
for (var i = 0; i < numberOfSteps; ++i) {
if (window["dummy property should not exist!" + i]) // Prevent optimizations.
return i;
Framework.safeRun(Framework.empty, Framework.empty, Framework.empty, true);
}
}
Tests the skip stack frames feature when stepping.
Debugger was enabled.
Set timer for test function.
Call stack:
0) test1 (skip-stack-frames-steps.html:23)
1) testFunction (skip-stack-frames-steps.html:11)
Call stack:
0) test2 (skip-stack-frames-steps.html:29)
1) testFunction (skip-stack-frames-steps.html:11)
Call stack:
0) callback (skip-stack-frames-steps.html:16)
1) Framework.safeRun (framework.js:8)
2) Framework.safeRun (framework.js:10)
3) test3 (skip-stack-frames-steps.html:34)
4) testFunction (skip-stack-frames-steps.html:11)
Call stack:
0) test4 (skip-stack-frames-steps.html:41)
1) testFunction (skip-stack-frames-steps.html:11)
Call stack:
0) callback (skip-stack-frames-steps.html:16)
1) Framework.safeRun (framework.js:8)
2) Framework.safeRun (framework.js:13)
3) Framework.safeRun (framework.js:10)
4) test5 (skip-stack-frames-steps.html:46)
5) testFunction (skip-stack-frames-steps.html:11)
Debugger was disabled.
<html>
<head>
<script src="../../../http/tests/inspector/inspector-test.js"></script>
<script src="../../../http/tests/inspector/debugger-test.js"></script>
<script src="resources/framework.js"></script>
<script>
function testFunction()
{
for (var i = 1, func; func = eval("typeof test" + i + " === 'function' && test" + i); ++i)
func();
}
function callback()
{
return 0;
}
function test1()
{
debugger;
Framework.empty();
}
function test2()
{
debugger;
Framework.doSomeWork();
}
function test3()
{
debugger;
Framework.safeRun(Framework.empty, callback); // Should step into callback
}
function test4()
{
debugger;
Framework.safeRun(Framework.doSomeWork, callback); // Should NOT step into callback (otherwise too many StepIns)
}
function test5()
{
debugger;
Framework.safeRun(Framework.empty, Framework.throwFrameworkException, callback); // Should be enough to step into callback
}
function test()
{
var frameworkRegexString = "/framework\\.js$";
var totalDebuggerStatements = 5;
InspectorTest.setQuiet(true);
InspectorTest.startDebuggerTest(step1);
function step1()
{
DebuggerAgent.skipStackFrames(frameworkRegexString, step2);
}
function step2()
{
InspectorTest.runTestFunctionAndWaitUntilPaused(didPaused);
}
var step = 0;
var stepInCount = 0;
function didPaused(callFrames, reason, breakpointIds, asyncStackTrace)
{
if (stepInCount < 2) {
++stepInCount;
WebInspector.panels.sources._stepIntoButton.element.click();
InspectorTest.waitUntilResumed(InspectorTest.waitUntilPaused.bind(InspectorTest, didPaused));
return;
}
stepInCount = 0;
InspectorTest.captureStackTrace(callFrames);
InspectorTest.addResult("");
if (++step < totalDebuggerStatements)
InspectorTest.resumeExecution(InspectorTest.waitUntilPaused.bind(InspectorTest, didPaused));
else
InspectorTest.completeDebuggerTest();
}
}
</script>
</head>
<body onload="runTest()">
<input type='button' onclick='testFunction()' value='Test'/>
<p>
Tests the skip stack frames feature when stepping.
</p>
</body>
</html>
......@@ -428,17 +428,13 @@ void ScriptDebugServer::v8DebugEventCallback(const v8::Debug::EventDetails& even
bool ScriptDebugServer::executeSkipPauseRequest(ScriptDebugListener::SkipPauseRequest request, v8::Handle<v8::Object> executionState)
{
switch (request) {
case ScriptDebugListener::NoSkip:
if (request == ScriptDebugListener::NoSkip)
return false;
case ScriptDebugListener::Continue:
if (request == ScriptDebugListener::Continue)
return true;
case ScriptDebugListener::StepInto:
case ScriptDebugListener::StepOut:
break;
}
ASSERT(request == ScriptDebugListener::StepInto || request == ScriptDebugListener::StepOut);
v8::Handle<v8::Value> argv[] = { executionState };
callDebuggerMethod(stepIntoV8MethodName, 1, argv);
callDebuggerMethod(request == ScriptDebugListener::StepInto ? stepIntoV8MethodName : stepOutV8MethodName, 1, argv);
return true;
}
......
......@@ -76,7 +76,7 @@ static const char skipAllPausesExpiresOnReload[] = "skipAllPausesExpiresOnReload
};
static const int numberOfStepsBeforeStepOut = 10;
static const int numberOfStepsBeforeStepOut = 20;
const char InspectorDebuggerAgent::backtraceObjectGroup[] = "backtrace";
......
Markdown is supported
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