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

DevTools: Don't stop debugger inside V8 internal scripts with empty stack trace.

R=yurys
TEST=inspector/sources/debugger/debugger-autocontinue-on-syntax-error.html, inspector/sources/debugger/debugger-step-into-v8-internals.html

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

git-svn-id: svn://svn.chromium.org/blink/trunk@179137 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 05e61f73
......@@ -159,6 +159,51 @@ InspectorTest.waitUntilPausedAndDumpStackAndResume = function(callback, options)
}
};
InspectorTest.waitUntilPausedAndPerformSteppingActions = function(actions, callback)
{
callback = InspectorTest.safeWrap(callback);
InspectorTest.waitUntilPaused(didPause);
function didPause(callFrames, reason, breakpointIds, asyncStackTrace)
{
var action = actions.shift();
if (action === "Print") {
InspectorTest.captureStackTrace(callFrames, asyncStackTrace);
InspectorTest.addResult("");
while (action === "Print")
action = actions.shift();
}
if (!action) {
callback()
return;
}
InspectorTest.addResult("Executing " + action + "...");
switch (action) {
case "StepInto":
WebInspector.panels.sources._stepIntoButton.element.click();
break;
case "StepOver":
WebInspector.panels.sources._stepOverButton.element.click();
break;
case "StepOut":
WebInspector.panels.sources._stepOutButton.element.click();
break;
case "Resume":
WebInspector.panels.sources.togglePause();
break;
default:
InspectorTest.addResult("FAIL: Unknown action: " + action);
callback()
return;
}
InspectorTest.waitUntilResumed(InspectorTest.waitUntilPaused.bind(InspectorTest, didPause));
}
};
InspectorTest.captureStackTrace = function(callFrames, asyncStackTrace, options)
{
InspectorTest.addResult(InspectorTest.captureStackTraceIntoString(callFrames, asyncStackTrace, options));
......
Tests that debugger will not step into V8 internal scripts.
Set timer for test function.
Call stack:
0) (debugger-step-into-v8-internals.html:10)
Executing StepInto...
Call stack:
0) (debugger-step-into-v8-internals.html:11)
Executing StepInto...
Call stack:
0) (debugger-step-into-v8-internals.html:14)
Executing StepInto...
Call stack:
0) (debugger-step-into-v8-internals.html:15)
<html>
<head>
<script src="../../../http/tests/inspector/inspector-test.js"></script>
<script src="../../../http/tests/inspector/debugger-test.js"></script>
<script>
function testFunction()
{
Promise.resolve(42).then(function() {
debugger;
}).then(function() {
var dummy1 = 1;
var dummy2 = 2;
debugger;
});
}
function test()
{
InspectorTest.setQuiet(true);
InspectorTest.startDebuggerTest(step1);
function step1()
{
InspectorTest.runTestFunctionAndWaitUntilPaused(step2);
}
function step2()
{
var actions = [
"Print", // debugger;
"StepInto", "Print",
"StepInto", "Print",
"StepInto", "Print",
];
InspectorTest.waitUntilPausedAndPerformSteppingActions(actions, step3);
}
function step3()
{
InspectorTest.completeDebuggerTest();
}
}
</script>
</head>
<body onload="runTest()">
<input type='button' onclick='testFunction()' value='Test'/>
<p>
Tests that debugger will not step into V8 internal scripts.
</p>
</body>
</html>
......@@ -28,57 +28,24 @@ function test()
{
xhrPane = WebInspector.panels.sources.sidebarPanes.xhrBreakpoints;
xhrPane._setBreakpoint("foo", true);
InspectorTest.runTestFunctionAndWaitUntilPaused(didPause);
InspectorTest.runTestFunctionAndWaitUntilPaused(step2);
}
var actions = [
"Print", // debugger;
"StepInto", "Print",
"StepOver", "Print",
"StepOut", "Print",
"StepInto", "Print", // should not step inside
"Resume", "Print", // should stop on XHR.send()
"StepInto", "Print", // should step inside framework
];
function didPause(callFrames, reason, breakpointIds, asyncStackTrace)
function step2()
{
var action = actions.shift();
if (action === "Print") {
InspectorTest.captureStackTrace(callFrames);
InspectorTest.addResult("");
while (action === "Print")
action = actions.shift();
}
if (!action) {
completeTest()
return;
}
InspectorTest.addResult("Executing " + action + "...");
switch (action) {
case "StepInto":
WebInspector.panels.sources._stepIntoButton.element.click();
break;
case "StepOver":
WebInspector.panels.sources._stepOverButton.element.click();
break;
case "StepOut":
WebInspector.panels.sources._stepOutButton.element.click();
break;
case "Resume":
InspectorTest.resumeExecution(InspectorTest.waitUntilPaused.bind(InspectorTest, didPause));
break;
default:
InspectorTest.addResult("FAIL: Unknown action: " + action);
completeTest()
return;
}
InspectorTest.waitUntilResumed(InspectorTest.waitUntilPaused.bind(InspectorTest, didPause));
var actions = [
"Print", // debugger;
"StepInto", "Print",
"StepOver", "Print",
"StepOut", "Print",
"StepInto", "Print", // should not step inside
"Resume", "Print", // should stop on XHR.send()
"StepInto", "Print", // should step inside framework
];
InspectorTest.waitUntilPausedAndPerformSteppingActions(actions, step3);
}
function completeTest()
function step3()
{
xhrPane._removeBreakpoint("foo");
InspectorTest.completeDebuggerTest();
......
......@@ -50,55 +50,30 @@ function test()
function step1()
{
InspectorTest.runTestFunctionAndWaitUntilPaused(didPause);
InspectorTest.runTestFunctionAndWaitUntilPaused(step2);
}
var actions = [
"Print", // debugger;
"StepInto", "StepInto", "Print", // callback1
"StepInto", "Print", // callback2
"StepInto", "Print", // callback2, skipped
"StepInto", "Print", // callback3
"StepInto", "StepInto", "StepInto", "StepInto", "Print", // callback4
"StepInto", "Print", // callback4, skipped
"StepInto", "Print", // callback4, inside catch
"StepOut", "Print", // return to callback3
"StepOver", "Print", // return to callback2
"StepInto", "Print", // return to callback1
];
function didPause(callFrames, reason, breakpointIds, asyncStackTrace)
function step2()
{
var action = actions.shift();
if (action === "Print") {
InspectorTest.captureStackTrace(callFrames);
InspectorTest.addResult("");
while (action === "Print")
action = actions.shift();
}
if (!action) {
InspectorTest.completeDebuggerTest();
return;
}
var actions = [
"Print", // debugger;
"StepInto", "StepInto", "Print", // callback1
"StepInto", "Print", // callback2
"StepInto", "Print", // callback2, skipped
"StepInto", "Print", // callback3
"StepInto", "StepInto", "StepInto", "StepInto", "Print", // callback4
"StepInto", "Print", // callback4, skipped
"StepInto", "Print", // callback4, inside catch
"StepOut", "Print", // return to callback3
"StepOver", "Print", // return to callback2
"StepInto", "Print", // return to callback1
];
InspectorTest.waitUntilPausedAndPerformSteppingActions(actions, step3);
}
InspectorTest.addResult("Executing " + action + "...");
switch (action) {
case "StepInto":
WebInspector.panels.sources._stepIntoButton.element.click();
break;
case "StepOver":
WebInspector.panels.sources._stepOverButton.element.click();
break;
case "StepOut":
WebInspector.panels.sources._stepOutButton.element.click();
break;
default:
InspectorTest.addResult("FAIL: Unknown action: " + action);
InspectorTest.completeDebuggerTest();
return;
}
InspectorTest.waitUntilResumed(InspectorTest.waitUntilPaused.bind(InspectorTest, didPause));
function step3()
{
InspectorTest.completeDebuggerTest();
}
}
......
......@@ -492,10 +492,6 @@ void ScriptDebugServer::handleV8DebugEvent(const v8::Debug::EventDetails& eventD
v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(value);
dispatchDidParseSource(listener, object, event != v8::AfterCompile ? CompileError : CompileSuccess);
} else if (event == v8::Exception) {
v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(m_isolate, 1);
// Stack trace is empty in case of syntax error. Silently continue execution in such cases.
if (!stackTrace->GetFrameCount())
return;
v8::Handle<v8::Object> eventData = eventDetails.GetEventData();
v8::Handle<v8::Value> exception = callInternalGetterFunction(eventData, "exception", m_isolate);
handleProgramBreak(ScriptState::from(eventContext), eventDetails.GetExecutionState(), exception, v8::Handle<v8::Array>());
......
......@@ -1297,7 +1297,9 @@ void InspectorDebuggerAgent::didParseSource(const String& scriptId, const Script
ScriptDebugListener::SkipPauseRequest InspectorDebuggerAgent::didPause(ScriptState* scriptState, const ScriptValue& callFrames, const ScriptValue& exception, const Vector<String>& hitBreakpoints)
{
ScriptDebugListener::SkipPauseRequest result;
if (m_javaScriptPauseScheduled)
if (callFrames.isEmpty())
result = ScriptDebugListener::Continue; // Skip pauses inside V8 internal scripts and on syntax errors.
else if (m_javaScriptPauseScheduled)
result = ScriptDebugListener::NoSkip; // Don't skip explicit pause requests from front-end.
else if (m_skipAllPauses)
result = ScriptDebugListener::Continue;
......
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