Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Web Inspector: Pause Reason Improvements (Breakpoint, Debugger Statem…
…ent, Pause on Next Statement) https://bugs.webkit.org/show_bug.cgi?id=138991 Reviewed by Timothy Hatcher. Source/JavaScriptCore: * debugger/Debugger.cpp: (JSC::Debugger::Debugger): (JSC::Debugger::pauseIfNeeded): (JSC::Debugger::didReachBreakpoint): When actually pausing, if we hit a breakpoint ensure the reason is PausedForBreakpoint, otherwise use the current reason. * debugger/Debugger.h: Make pause reason and pausing breakpoint ID public. * inspector/agents/InspectorDebuggerAgent.h: * inspector/agents/InspectorDebuggerAgent.cpp: (Inspector::buildAssertPauseReason): (Inspector::buildCSPViolationPauseReason): (Inspector::InspectorDebuggerAgent::buildBreakpointPauseReason): (Inspector::InspectorDebuggerAgent::buildExceptionPauseReason): (Inspector::InspectorDebuggerAgent::handleConsoleAssert): (Inspector::buildObjectForBreakpointCookie): (Inspector::InspectorDebuggerAgent::setBreakpointByUrl): (Inspector::InspectorDebuggerAgent::removeBreakpoint): (Inspector::InspectorDebuggerAgent::resolveBreakpoint): (Inspector::InspectorDebuggerAgent::pause): (Inspector::InspectorDebuggerAgent::scriptExecutionBlockedByCSP): (Inspector::InspectorDebuggerAgent::currentCallFrames): (Inspector::InspectorDebuggerAgent::clearDebuggerBreakpointState): Clean up creation of pause reason objects and other cleanup of PassRefPtr use and InjectedScript use. (Inspector::InspectorDebuggerAgent::didPause): Clean up so that we first check for an Exception, and then fall back to including a Pause Reason derived from the Debugger. * inspector/protocol/Debugger.json: Add new DebuggerStatement, Breakpoint, and PauseOnNextStatement reasons. Source/WebInspectorUI: * Localizations/en.lproj/localizedStrings.js: New UI strings for Pause Reasons. * UserInterface/Controllers/DebuggerManager.js: (WebInspector.DebuggerManager.prototype.breakpointForIdentifier): Provide a way to get the breakpoint with an identifier. * UserInterface/Images/PausedBreakpoint.svg: Added. * UserInterface/Images/gtk/PausedBreakpoint.svg: Added. Copy PseudoElement.svg icon and give it a new name. * UserInterface/Views/BreakpointTreeElement.css: (.breakpoint-paused-icon .icon): New icon for a breakpoint causing a pause. * UserInterface/Views/BreakpointTreeElement.js: (WebInspector.BreakpointTreeElement.prototype.removeStatusImage): (WebInspector.BreakpointTreeElement.prototype._updateStatus): Give API to remove the breakpoint status icon from a BreakpointTreeElement. * UserInterface/Views/DebuggerSidebarPanel.js: (WebInspector.DebuggerSidebarPanel): (WebInspector.DebuggerSidebarPanel.prototype.get hasSelectedElement): (WebInspector.DebuggerSidebarPanel.prototype.deselectBreakpointContentTreeElements): (WebInspector.DebuggerSidebarPanel.prototype.deselectPauseReasonContentTreeElements): (WebInspector.DebuggerSidebarPanel.prototype._treeElementSelected): Give DebuggerSidebarPanel an optional pause reason tree outline. When available include it in the pattern of ensuring a single exclusive selection. (WebInspector.DebuggerSidebarPanel.prototype._breakpointRemoved): When a breakpoint is removed, check if we should update the pause reason tree outline. (WebInspector.DebuggerSidebarPanel.prototype._updatePauseReason): (WebInspector.DebuggerSidebarPanel.prototype._updatePauseReasonSection): Update Pause Reason section contents depending on the reason. (WebInspector.DebuggerSidebarPanel.prototype._updatePauseReasonGotoArrow): Always try to include a goto arrow to jump to the original pause location if it is available at the time of pausing. LayoutTests: Test that the frontend receives expected pause reasons for different kinds of pauses. * inspector/debugger/pause-reason-expected.txt: Added. * inspector/debugger/pause-reason.html: Added. * inspector/debugger/resources/pause-reasons.js: Added. (triggerBreakpoint): (triggerException): (triggerDebuggerStatement): (triggerAssert): Canonical link: https://commits.webkit.org/158231@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@178137 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
with
852 additions
and 81 deletions.
- +17 −0 LayoutTests/ChangeLog
- +30 −0 LayoutTests/inspector/debugger/pause-reason-expected.txt
- +88 −0 LayoutTests/inspector/debugger/pause-reason.html
- +19 −0 LayoutTests/inspector/debugger/resources/pause-reasons.js
- +42 −0 Source/JavaScriptCore/ChangeLog
- +9 −2 Source/JavaScriptCore/debugger/Debugger.cpp
- +15 −14 Source/JavaScriptCore/debugger/Debugger.h
- +93 −33 Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp
- +7 −2 Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.h
- +9 −1 Source/JavaScriptCore/inspector/protocol/Debugger.json
- +47 −0 Source/WebInspectorUI/ChangeLog
- BIN Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
- +17 −3 Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js
- +8 −0 Source/WebInspectorUI/UserInterface/Images/PausedBreakpoint.svg
- +319 −0 Source/WebInspectorUI/UserInterface/Images/gtk/PausedBreakpoint.svg
- +4 −0 Source/WebInspectorUI/UserInterface/Views/BreakpointTreeElement.css
- +9 −0 Source/WebInspectorUI/UserInterface/Views/BreakpointTreeElement.js
- +119 −26 Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.js
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,30 @@ | ||
CONSOLE MESSAGE: line 8: TypeError: undefined is not an object (evaluating '[].x.x') | ||
CONSOLE MESSAGE: line 18: Assertion message | ||
Test that pausing in different ways triggers different pause reasons. | ||
|
||
PAUSE #1 | ||
REASON: exception | ||
DATA: {"description":"TypeError: undefined is not an object (evaluating '[].x.x')"} | ||
RESUMED | ||
|
||
PAUSE #2 | ||
REASON: debugger-statement | ||
NO DATA | ||
RESUMED | ||
|
||
PAUSE #3 | ||
REASON: assertion | ||
DATA: {"message":"Assertion message"} | ||
RESUMED | ||
|
||
PAUSE #4 | ||
REASON: breakpoint | ||
DATA: {"breakpointId":"pause-reasons.js:3:0"} | ||
RESUMED | ||
|
||
PAUSE #5 | ||
REASON: pause-on-next-statement | ||
NO DATA | ||
RESUMED | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,88 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<script type="text/javascript" src="../../http/tests/inspector/inspector-test.js"></script> | ||
<script type="text/javascript" src="./resources/pause-reasons.js"></script> | ||
<script> | ||
// We expect uncaught exceptions, so avoid logs for them. | ||
window.onerror = function(){}; | ||
|
||
function test() | ||
{ | ||
var pauses = 0; | ||
var index = 0; | ||
var testCases = [ | ||
{ expression: "setTimeout(triggerException, 0)" }, | ||
{ expression: "setTimeout(triggerDebuggerStatement, 0)" }, | ||
{ expression: "setTimeout(triggerAssert, 0)" }, | ||
{ expression: "setTimeout(triggerBreakpoint, 0)" }, | ||
{ expression: "setTimeout(function() { 1+1 }, 0)", setup: function() { WebInspector.debuggerManager.pause(); } }, | ||
]; | ||
|
||
function nextTestCase() | ||
{ | ||
var test = testCases[index++]; | ||
if (!test) { | ||
InspectorTest.completeTest(); | ||
return; | ||
} | ||
|
||
if (test.setup) | ||
test.setup(); | ||
|
||
InspectorTest.evaluateInPage(test.expression); | ||
} | ||
|
||
function sanitizePauseData(data) | ||
{ | ||
// Sanitize RemoteObjects to just output the description. | ||
if (data.description) | ||
return {description: data.description}; | ||
|
||
// Sanitize BreakpointIdentifier path. | ||
if (data.breakpointId) | ||
return {breakpointId: data.breakpointId.substring(data.breakpointId.indexOf("pause-reasons.js"))}; | ||
|
||
return data; | ||
} | ||
|
||
WebInspector.debuggerManager.allExceptionsBreakpoint.disabled = false; | ||
|
||
WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.ScriptAdded, function(event) { | ||
var scriptObject = event.data.script; | ||
if (!/pause-reasons\.js$/.test(scriptObject.url)) | ||
return; | ||
|
||
var sourceCodeLocation = scriptObject.createSourceCodeLocation(3, 0); | ||
var breakpoint = new WebInspector.Breakpoint(sourceCodeLocation); | ||
WebInspector.debuggerManager.addBreakpoint(breakpoint); | ||
|
||
nextTestCase(); | ||
}); | ||
|
||
WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.Paused, function(event) { | ||
InspectorTest.log("PAUSE #" + (++pauses)); | ||
InspectorTest.log(" REASON: " + WebInspector.debuggerManager.pauseReason); | ||
if (WebInspector.debuggerManager.pauseData) | ||
InspectorTest.log(" DATA: " + JSON.stringify(sanitizePauseData(WebInspector.debuggerManager.pauseData))); | ||
else | ||
InspectorTest.log(" NO DATA"); | ||
|
||
WebInspector.debuggerManager.resume(); | ||
}); | ||
|
||
WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.Resumed, function(event) { | ||
InspectorTest.log("RESUMED"); | ||
InspectorTest.log(""); | ||
|
||
nextTestCase(); | ||
}); | ||
|
||
InspectorTest.reloadPage(); | ||
} | ||
</script> | ||
</head> | ||
<body onload="runTest()"> | ||
<p>Test that pausing in different ways triggers different pause reasons.</p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,19 @@ | ||
function triggerBreakpoint() | ||
{ | ||
1+1; // BREAKPOINT | ||
} | ||
|
||
function triggerException() | ||
{ | ||
[].x.x; | ||
} | ||
|
||
function triggerDebuggerStatement() | ||
{ | ||
debugger; | ||
} | ||
|
||
function triggerAssert() | ||
{ | ||
console.assert(false, "Assertion message"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.