Commit 94cd8ed6 authored by sergeyv@chromium.org's avatar sergeyv@chromium.org

[WIP]Devtools: Support disabling and enabling of debugger in TargetBreakpoints

BUG=

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

git-svn-id: svn://svn.chromium.org/blink/trunk@175897 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 8f563297
...@@ -41,6 +41,11 @@ InspectorTest.DebuggerModelMock.prototype = { ...@@ -41,6 +41,11 @@ InspectorTest.DebuggerModelMock.prototype = {
return this._target; return this._target;
}, },
debuggerEnabled: function()
{
return true;
},
_addScript: function(scriptId, url) _addScript: function(scriptId, url)
{ {
this._scripts[scriptId] = new WebInspector.Script(this._target, scriptId, url); this._scripts[scriptId] = new WebInspector.Script(this._target, scriptId, url);
......
Tests that breakpoints are correctly handled while debugger is turned off
Main resource was shown.
Debugger disabled.
Breakpoint added
Debugger was enabled
Set timer for test function.
Script execution paused.
Script execution resumed.
Disable debugger again
Debugger disabled
Breakpoint removed
Debugger enabled
Evaluating test function.
function evaluated without a pause on the breakpoint.
<html>
<head>
<script src="../../../http/tests/inspector/inspector-test.js"></script>
<script src="../../../http/tests/inspector/debugger-test.js"></script>
<script>
function testFunction()
{
return 0;
}
var test = function()
{
var testName = WebInspector.resourceTreeModel.inspectedPageURL();
testName = testName.substring(testName.lastIndexOf('/') + 1);
InspectorTest.startDebuggerTest(step1);
var testSourceFrame;
function step1()
{
InspectorTest.showScriptSource(testName, step2);
}
function step2(sourceFrame)
{
testSourceFrame = sourceFrame;
InspectorTest.addResult("Main resource was shown.");
InspectorTest.addSniffer(WebInspector.debuggerModel, "_debuggerWasDisabled", step3);
WebInspector.debuggerModel.disableDebugger();
}
function step3()
{
InspectorTest.addResult("Debugger disabled.");
InspectorTest.setBreakpoint(testSourceFrame, 8, "", true);
InspectorTest.addResult("Breakpoint added");
InspectorTest.addSniffer(WebInspector.debuggerModel, "_debuggerWasEnabled", step4);
WebInspector.debuggerModel.enableDebugger();
}
function step4()
{
InspectorTest.addResult("Debugger was enabled");
InspectorTest.runTestFunctionAndWaitUntilPaused(step5);
}
function step5()
{
InspectorTest.resumeExecution(step6);
}
function step6()
{
InspectorTest.addResult("Disable debugger again");
InspectorTest.addSniffer(WebInspector.debuggerModel, "_debuggerWasDisabled", step7);
WebInspector.debuggerModel.disableDebugger();
}
function step7()
{
InspectorTest.addResult("Debugger disabled");
var breakpoint = WebInspector.breakpointManager.findBreakpointOnLine(testSourceFrame.uiSourceCode(), 8);
breakpoint.remove();
InspectorTest.addResult("Breakpoint removed");
InspectorTest.addSniffer(WebInspector.debuggerModel, "_debuggerWasEnabled", step8);
WebInspector.debuggerModel.enableDebugger();
}
function step8()
{
InspectorTest.addResult("Debugger enabled");
InspectorTest.addResult("Evaluating test function.");
InspectorTest.evaluateInConsole("testFunction()", step9);
}
function step9()
{
InspectorTest.addResult("function evaluated without a pause on the breakpoint.")
InspectorTest.completeDebuggerTest();
}
};
</script>
</head>
<body onload="runTest()">
<p>
Tests that breakpoints are correctly handled while debugger is turned off</a>
</p>
</body>
</html>
Tests that breakpoints are successfully restored after debugger disabling.
Main resource was shown.
Debugger disabled.
Evaluating test function.
function evaluated without a pause on the breakpoint.
Debugger was enabled
Set timer for test function.
Script execution paused.
Script execution resumed.
<html>
<head>
<script src="../../../http/tests/inspector/inspector-test.js"></script>
<script src="../../../http/tests/inspector/debugger-test.js"></script>
<script>
function testFunction()
{
return 0;
}
var test = function()
{
var testName = WebInspector.resourceTreeModel.inspectedPageURL();
testName = testName.substring(testName.lastIndexOf('/') + 1);
InspectorTest.startDebuggerTest(step1);
function step1()
{
InspectorTest.showScriptSource(testName, step2);
}
function step2(sourceFrame)
{
InspectorTest.addResult("Main resource was shown.");
InspectorTest.setBreakpoint(sourceFrame, 8, "", true);
InspectorTest.addSniffer(WebInspector.debuggerModel, "_debuggerWasDisabled", step3);
WebInspector.debuggerModel.disableDebugger();
}
function step3()
{
InspectorTest.addResult("Debugger disabled.");
InspectorTest.addResult("Evaluating test function.");
InspectorTest.evaluateInConsole("testFunction()", step4);
}
function step4()
{
InspectorTest.addResult("function evaluated without a pause on the breakpoint.");
InspectorTest.addSniffer(WebInspector.debuggerModel, "_debuggerWasEnabled", step5);
WebInspector.debuggerModel.enableDebugger();
}
function step5()
{
InspectorTest.addResult("Debugger was enabled");
InspectorTest.runTestFunctionAndWaitUntilPaused(step6);
}
function step6()
{
InspectorTest.completeDebuggerTest();
}
};
</script>
</head>
<body onload="runTest()">
<p>
Tests that breakpoints are successfully restored after debugger disabling.</a>
</p>
</body>
</html>
...@@ -437,8 +437,8 @@ WebInspector.BreakpointManager.Breakpoint = function(breakpointManager, projectI ...@@ -437,8 +437,8 @@ WebInspector.BreakpointManager.Breakpoint = function(breakpointManager, projectI
/** @type {!Map.<!WebInspector.Target, !WebInspector.BreakpointManager.TargetBreakpoint>}*/ /** @type {!Map.<!WebInspector.Target, !WebInspector.BreakpointManager.TargetBreakpoint>}*/
this._targetBreakpoints = new Map(); this._targetBreakpoints = new Map();
this._breakpointManager._targetManager.observeTargets(this);
this._updateState(condition, enabled); this._updateState(condition, enabled);
this._breakpointManager._targetManager.observeTargets(this);
} }
WebInspector.BreakpointManager.Breakpoint.prototype = { WebInspector.BreakpointManager.Breakpoint.prototype = {
...@@ -455,7 +455,9 @@ WebInspector.BreakpointManager.Breakpoint.prototype = { ...@@ -455,7 +455,9 @@ WebInspector.BreakpointManager.Breakpoint.prototype = {
*/ */
targetRemoved: function(target) targetRemoved: function(target)
{ {
this._targetBreakpoints.remove(target)._resetLocations(); var targetBreakpoint = this._targetBreakpoints.remove(target);
targetBreakpoint._cleanUpAfterDebuggerIsGone();
targetBreakpoint._removeEventListeners();
}, },
/** /**
...@@ -594,8 +596,10 @@ WebInspector.BreakpointManager.Breakpoint.prototype = { ...@@ -594,8 +596,10 @@ WebInspector.BreakpointManager.Breakpoint.prototype = {
var removeFromStorage = !keepInStorage; var removeFromStorage = !keepInStorage;
this._removeFakeBreakpointAtPrimaryLocation(); this._removeFakeBreakpointAtPrimaryLocation();
var targetBreakpoints = this._targetBreakpoints.values(); var targetBreakpoints = this._targetBreakpoints.values();
for (var i = 0; i < targetBreakpoints.length; ++i) for (var i = 0; i < targetBreakpoints.length; ++i) {
targetBreakpoints[i]._removeFromDebugger(); targetBreakpoints[i]._removeFromDebugger();
targetBreakpoints[i]._removeEventListeners();
}
this._breakpointManager._removeBreakpoint(this, removeFromStorage); this._breakpointManager._removeBreakpoint(this, removeFromStorage);
this._breakpointManager._targetManager.unobserveTargets(this); this._breakpointManager._targetManager.unobserveTargets(this);
...@@ -661,6 +665,10 @@ WebInspector.BreakpointManager.TargetBreakpoint = function(target, breakpoint) ...@@ -661,6 +665,10 @@ WebInspector.BreakpointManager.TargetBreakpoint = function(target, breakpoint)
/** @type {!Object.<string, !WebInspector.UILocation>} */ /** @type {!Object.<string, !WebInspector.UILocation>} */
this._uiLocations = {}; this._uiLocations = {};
target.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.DebuggerWasDisabled, this._cleanUpAfterDebuggerIsGone, this);
target.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.DebuggerWasEnabled, this._updateInDebugger, this);
if (target.debuggerModel.debuggerEnabled())
this._updateInDebugger();
} }
WebInspector.BreakpointManager.TargetBreakpoint.prototype = { WebInspector.BreakpointManager.TargetBreakpoint.prototype = {
...@@ -777,6 +785,19 @@ WebInspector.BreakpointManager.TargetBreakpoint.prototype = { ...@@ -777,6 +785,19 @@ WebInspector.BreakpointManager.TargetBreakpoint.prototype = {
return true; return true;
}, },
_cleanUpAfterDebuggerIsGone: function()
{
this._resetLocations();
if (this._debuggerId)
this._didRemoveFromDebugger();
},
_removeEventListeners: function()
{
this.target().debuggerModel.removeEventListener(WebInspector.DebuggerModel.Events.DebuggerWasDisabled, this._cleanUpAfterDebuggerIsGone, this);
this.target().debuggerModel.removeEventListener(WebInspector.DebuggerModel.Events.DebuggerWasEnabled, this._updateInDebugger, this);
},
__proto__: WebInspector.TargetAware.prototype __proto__: WebInspector.TargetAware.prototype
} }
......
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