Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js (207370 => 207371)
--- trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js 2016-10-15 04:18:19 UTC (rev 207370)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js 2016-10-15 07:22:03 UTC (rev 207371)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013, 2014, 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -48,7 +48,7 @@
this._allExceptionsBreakpointEnabledSetting = new WebInspector.Setting("break-on-all-exceptions", false);
this._allUncaughtExceptionsBreakpointEnabledSetting = new WebInspector.Setting("break-on-all-uncaught-exceptions", false);
- var specialBreakpointLocation = new WebInspector.SourceCodeLocation(null, Infinity, Infinity);
+ let specialBreakpointLocation = new WebInspector.SourceCodeLocation(null, Infinity, Infinity);
this._allExceptionsBreakpoint = new WebInspector.Breakpoint(specialBreakpointLocation, !this._allExceptionsBreakpointEnabledSetting.value);
this._allExceptionsBreakpoint.resolved = true;
@@ -85,9 +85,11 @@
this._updateBreakOnExceptionsState();
+ this._ignoreBreakpointDisplayLocationDidChangeEvent = false;
+
function restoreBreakpointsSoon() {
this._restoringBreakpoints = true;
- for (var cookie of this._breakpointsSetting.value)
+ for (let cookie of this._breakpointsSetting.value)
this.addBreakpoint(new WebInspector.Breakpoint(cookie));
this._restoringBreakpoints = false;
}
@@ -99,6 +101,99 @@
// Public
+ get paused()
+ {
+ return this._paused;
+ }
+
+ get pauseReason()
+ {
+ return this._pauseReason;
+ }
+
+ get pauseData()
+ {
+ return this._pauseData;
+ }
+
+ get callFrames()
+ {
+ return this._callFrames;
+ }
+
+ get activeCallFrame()
+ {
+ return this._activeCallFrame;
+ }
+
+ set activeCallFrame(callFrame)
+ {
+ if (callFrame === this._activeCallFrame)
+ return;
+
+ this._activeCallFrame = callFrame || null;
+
+ this.dispatchEventToListeners(WebInspector.DebuggerManager.Event.ActiveCallFrameDidChange);
+ }
+
+ get allExceptionsBreakpoint()
+ {
+ return this._allExceptionsBreakpoint;
+ }
+
+ get allUncaughtExceptionsBreakpoint()
+ {
+ return this._allUncaughtExceptionsBreakpoint;
+ }
+
+ get breakpoints()
+ {
+ return this._breakpoints;
+ }
+
+ breakpointForIdentifier(id)
+ {
+ return this._breakpointIdMap.get(id) || null;
+ }
+
+ breakpointsForSourceCode(sourceCode)
+ {
+ console.assert(sourceCode instanceof WebInspector.Resource || sourceCode instanceof WebInspector.Script);
+
+ if (sourceCode instanceof WebInspector.SourceMapResource) {
+ let originalSourceCodeBreakpoints = this.breakpointsForSourceCode(sourceCode.sourceMap.originalSourceCode);
+ return originalSourceCodeBreakpoints.filter(function(breakpoint) {
+ return breakpoint.sourceCodeLocation.displaySourceCode === sourceCode;
+ });
+ }
+
+ let contentIdentifierBreakpoints = this._breakpointContentIdentifierMap.get(sourceCode.contentIdentifier);
+ if (contentIdentifierBreakpoints) {
+ this._associateBreakpointsWithSourceCode(contentIdentifierBreakpoints, sourceCode);
+ return contentIdentifierBreakpoints;
+ }
+
+ if (sourceCode instanceof WebInspector.Script) {
+ let scriptIdentifierBreakpoints = this._breakpointScriptIdentifierMap.get(sourceCode.id);
+ if (scriptIdentifierBreakpoints) {
+ this._associateBreakpointsWithSourceCode(scriptIdentifierBreakpoints, sourceCode);
+ return scriptIdentifierBreakpoints;
+ }
+ }
+
+ return [];
+ }
+
+ isBreakpointRemovable(breakpoint)
+ {
+ return breakpoint !== this._allExceptionsBreakpoint && breakpoint !== this._allUncaughtExceptionsBreakpoint;
+ }
+
+ isBreakpointEditable(breakpoint)
+ {
+ return this.isBreakpointRemovable(breakpoint);
+ }
+
get breakpointsEnabled()
{
return this._breakpointsEnabledSetting.value;
@@ -122,39 +217,39 @@
this._updateBreakOnExceptionsState();
}
- get paused()
+ get breakpointsDisabledTemporarily()
{
- return this._paused;
+ return this._temporarilyDisabledBreakpointsRestoreSetting.value !== null;
}
- get pauseReason()
+ scriptForIdentifier(id)
{
- return this._pauseReason;
+ return this._scriptIdMap.get(id) || null;
}
- get pauseData()
+ scriptsForURL(url)
{
- return this._pauseData;
+ // FIXME: This may not be safe. A Resource's URL may differ from a Script's URL.
+ return this._scriptContentIdentifierMap.get(url) || [];
}
- get callFrames()
+ get searchableScripts()
{
- return this._callFrames;
+ return this.knownNonResourceScripts.filter((script) => !!script.contentIdentifier);
}
- get activeCallFrame()
+ get knownNonResourceScripts()
{
- return this._activeCallFrame;
- }
+ let knownScripts = [];
+ for (let script of this._scriptIdMap.values()) {
+ if (script.resource)
+ continue;
+ if (!WebInspector.isDebugUIEnabled() && isWebKitInternalScript(script.sourceURL))
+ continue;
+ knownScripts.push(script);
+ }
- set activeCallFrame(callFrame)
- {
- if (callFrame === this._activeCallFrame)
- return;
-
- this._activeCallFrame = callFrame || null;
-
- this.dispatchEventToListeners(WebInspector.DebuggerManager.Event.ActiveCallFrameDidChange);
+ return knownScripts;
}
pause()
@@ -164,13 +259,13 @@
this.dispatchEventToListeners(WebInspector.DebuggerManager.Event.WaitingToPause);
- var listener = new WebInspector.EventListener(this, true);
+ let listener = new WebInspector.EventListener(this, true);
- var managerResult = new Promise(function(resolve, reject) {
+ let managerResult = new Promise(function(resolve, reject) {
listener.connect(WebInspector.debuggerManager, WebInspector.DebuggerManager.Event.Paused, resolve);
});
- var protocolResult = DebuggerAgent.pause()
+ let protocolResult = DebuggerAgent.pause()
.catch(function(error) {
listener.disconnect();
console.error("DebuggerManager.pause failed: ", error);
@@ -185,13 +280,13 @@
if (!this._paused)
return Promise.resolve();
- var listener = new WebInspector.EventListener(this, true);
+ let listener = new WebInspector.EventListener(this, true);
- var managerResult = new Promise(function(resolve, reject) {
+ let managerResult = new Promise(function(resolve, reject) {
listener.connect(WebInspector.debuggerManager, WebInspector.DebuggerManager.Event.Resumed, resolve);
});
- var protocolResult = DebuggerAgent.resume()
+ let protocolResult = DebuggerAgent.resume()
.catch(function(error) {
listener.disconnect();
console.error("DebuggerManager.resume failed: ", error);
@@ -206,13 +301,13 @@
if (!this._paused)
return Promise.reject(new Error("Cannot step over because debugger is not paused."));
- var listener = new WebInspector.EventListener(this, true);
+ let listener = new WebInspector.EventListener(this, true);
- var managerResult = new Promise(function(resolve, reject) {
+ let managerResult = new Promise(function(resolve, reject) {
listener.connect(WebInspector.debuggerManager, WebInspector.DebuggerManager.Event.ActiveCallFrameDidChange, resolve);
});
- var protocolResult = DebuggerAgent.stepOver()
+ let protocolResult = DebuggerAgent.stepOver()
.catch(function(error) {
listener.disconnect();
console.error("DebuggerManager.stepOver failed: ", error);
@@ -227,13 +322,13 @@
if (!this._paused)
return Promise.reject(new Error("Cannot step into because debugger is not paused."));
- var listener = new WebInspector.EventListener(this, true);
+ let listener = new WebInspector.EventListener(this, true);
- var managerResult = new Promise(function(resolve, reject) {
+ let managerResult = new Promise(function(resolve, reject) {
listener.connect(WebInspector.debuggerManager, WebInspector.DebuggerManager.Event.ActiveCallFrameDidChange, resolve);
});
- var protocolResult = DebuggerAgent.stepInto()
+ let protocolResult = DebuggerAgent.stepInto()
.catch(function(error) {
listener.disconnect();
console.error("DebuggerManager.stepInto failed: ", error);
@@ -248,13 +343,13 @@
if (!this._paused)
return Promise.reject(new Error("Cannot step out because debugger is not paused."));
- var listener = new WebInspector.EventListener(this, true);
+ let listener = new WebInspector.EventListener(this, true);
- var managerResult = new Promise(function(resolve, reject) {
+ let managerResult = new Promise(function(resolve, reject) {
listener.connect(WebInspector.debuggerManager, WebInspector.DebuggerManager.Event.ActiveCallFrameDidChange, resolve);
});
- var protocolResult = DebuggerAgent.stepOut()
+ let protocolResult = DebuggerAgent.stepOut()
.catch(function(error) {
listener.disconnect();
console.error("DebuggerManager.stepOut failed: ", error);
@@ -264,92 +359,14 @@
return Promise.all([managerResult, protocolResult]);
}
- get allExceptionsBreakpoint()
+ continueToLocation(scriptId, lineNumber, columnNumber)
{
- return this._allExceptionsBreakpoint;
+ return DebuggerAgent.continueToLocation({scriptId, lineNumber, columnNumber});
}
- get allUncaughtExceptionsBreakpoint()
+ addBreakpoint(breakpoint, shouldSpeculativelyResolve)
{
- return this._allUncaughtExceptionsBreakpoint;
- }
-
- get breakpoints()
- {
- return this._breakpoints;
- }
-
- breakpointsForSourceCode(sourceCode)
- {
- console.assert(sourceCode instanceof WebInspector.Resource || sourceCode instanceof WebInspector.Script);
-
- if (sourceCode instanceof WebInspector.SourceMapResource) {
- var originalSourceCodeBreakpoints = this.breakpointsForSourceCode(sourceCode.sourceMap.originalSourceCode);
- return originalSourceCodeBreakpoints.filter(function(breakpoint) {
- return breakpoint.sourceCodeLocation.displaySourceCode === sourceCode;
- });
- }
-
- let contentIdentifierBreakpoints = this._breakpointContentIdentifierMap.get(sourceCode.contentIdentifier);
- if (contentIdentifierBreakpoints) {
- this._associateBreakpointsWithSourceCode(contentIdentifierBreakpoints, sourceCode);
- return contentIdentifierBreakpoints;
- }
-
- if (sourceCode instanceof WebInspector.Script) {
- let scriptIdentifierBreakpoints = this._breakpointScriptIdentifierMap.get(sourceCode.id);
- if (scriptIdentifierBreakpoints) {
- this._associateBreakpointsWithSourceCode(scriptIdentifierBreakpoints, sourceCode);
- return scriptIdentifierBreakpoints;
- }
- }
-
- return [];
- }
-
- breakpointForIdentifier(id)
- {
- return this._breakpointIdMap.get(id) || null;
- }
-
- scriptForIdentifier(id)
- {
- return this._scriptIdMap.get(id) || null;
- }
-
- scriptsForURL(url)
- {
- // FIXME: This may not be safe. A Resource's URL may differ from a Script's URL.
- return this._scriptContentIdentifierMap.get(url) || [];
- }
-
- continueToLocation(scriptIdentifier, lineNumber, columnNumber)
- {
- DebuggerAgent.continueToLocation({scriptId: scriptIdentifier, lineNumber, columnNumber});
- }
-
- get searchableScripts()
- {
- return this.knownNonResourceScripts.filter((script) => !!script.contentIdentifier);
- }
-
- get knownNonResourceScripts()
- {
- let knownScripts = [];
- for (let script of this._scriptIdMap.values()) {
- if (script.resource)
- continue;
- if (!WebInspector.isDebugUIEnabled() && isWebKitInternalScript(script.sourceURL))
- continue;
- knownScripts.push(script);
- }
-
- return knownScripts;
- }
-
- addBreakpoint(breakpoint, skipEventDispatch, shouldSpeculativelyResolve)
- {
- console.assert(breakpoint instanceof WebInspector.Breakpoint, "Bad argument to DebuggerManger.addBreakpoint: ", breakpoint);
+ console.assert(breakpoint instanceof WebInspector.Breakpoint);
if (!breakpoint)
return;
@@ -373,22 +390,21 @@
this._breakpoints.push(breakpoint);
- function speculativelyResolveBreakpoint(breakpoint) {
- breakpoint.resolved = true;
+ if (!breakpoint.disabled) {
+ this._setBreakpoint(breakpoint, () => {
+ if (shouldSpeculativelyResolve)
+ breakpoint.resolved = true;
+ });
}
- if (!breakpoint.disabled)
- this._setBreakpoint(breakpoint, shouldSpeculativelyResolve ? speculativelyResolveBreakpoint.bind(null, breakpoint) : null);
-
this._saveBreakpoints();
- if (!skipEventDispatch)
- this.dispatchEventToListeners(WebInspector.DebuggerManager.Event.BreakpointAdded, {breakpoint});
+ this.dispatchEventToListeners(WebInspector.DebuggerManager.Event.BreakpointAdded, {breakpoint});
}
removeBreakpoint(breakpoint)
{
- console.assert(breakpoint);
+ console.assert(breakpoint instanceof WebInspector.Breakpoint);
if (!breakpoint)
return;
@@ -428,6 +444,13 @@
this.dispatchEventToListeners(WebInspector.DebuggerManager.Event.BreakpointRemoved, {breakpoint});
}
+ nextBreakpointActionIdentifier()
+ {
+ return this._nextBreakpointActionIdentifier++;
+ }
+
+ // Protected (Called from WebInspector.DebuggerObserver)
+
breakpointResolved(breakpointIdentifier, location)
{
// Called from WebInspector.DebuggerObserver.
@@ -440,7 +463,7 @@
console.assert(breakpoint.identifier === breakpointIdentifier);
if (!breakpoint.sourceCodeLocation.sourceCode) {
- var sourceCodeLocation = this._sourceCodeLocationFromPayload(location);
+ let sourceCodeLocation = this._sourceCodeLocationFromPayload(location);
breakpoint.sourceCodeLocation.sourceCode = sourceCodeLocation.sourceCode;
}
@@ -451,7 +474,7 @@
{
// Called from WebInspector.DebuggerObserver.
- var wasPaused = this._paused;
+ let wasPaused = this._paused;
WebInspector.Script.resetUniqueDisplayNameNumbers();
@@ -467,8 +490,7 @@
// Mark all the breakpoints as unresolved. They will be reported as resolved when
// breakpointResolved is called as the page loads.
- for (var i = 0; i < this._breakpoints.length; ++i) {
- var breakpoint = this._breakpoints[i];
+ for (let breakpoint of this._breakpoints) {
breakpoint.resolved = false;
if (breakpoint.sourceCodeLocation.sourceCode)
breakpoint.sourceCodeLocation.sourceCode = null;
@@ -544,11 +566,15 @@
playBreakpointActionSound(breakpointActionIdentifier)
{
+ // Called from WebInspector.DebuggerObserver.
+
InspectorFrontendHost.beep();
}
scriptDidParse(scriptIdentifier, url, startLine, startColumn, endLine, endColumn, isContentScript, sourceURL, sourceMapURL)
{
+ // Called from WebInspector.DebuggerObserver.
+
// Don't add the script again if it is already known.
if (this._scriptIdMap.has(scriptIdentifier)) {
const script = this._scriptIdMap.get(scriptIdentifier);
@@ -589,21 +615,6 @@
this.dispatchEventToListeners(WebInspector.DebuggerManager.Event.ScriptAdded, {script});
}
- isBreakpointRemovable(breakpoint)
- {
- return breakpoint !== this._allExceptionsBreakpoint && breakpoint !== this._allUncaughtExceptionsBreakpoint;
- }
-
- isBreakpointEditable(breakpoint)
- {
- return this.isBreakpointRemovable(breakpoint);
- }
-
- get nextBreakpointActionIdentifier()
- {
- return this._nextBreakpointActionIdentifier++;
- }
-
// Private
_sourceCodeLocationFromPayload(payload)
@@ -729,7 +740,7 @@
if (!(locations instanceof Array))
locations = [locations];
- for (var location of locations)
+ for (let location of locations)
this.breakpointResolved(breakpointIdentifier, location);
if (typeof callback === "function")
@@ -801,7 +812,7 @@
if (this._ignoreBreakpointDisplayLocationDidChangeEvent)
return;
- var breakpoint = event.target;
+ let breakpoint = event.target;
if (!breakpoint.identifier || breakpoint.disabled)
return;
@@ -861,16 +872,11 @@
function breakpointRemoved()
{
- // Add the breakpoint with its new condition and get a new id.
+ // Add the breakpoint with its new properties and get a new id.
this._setBreakpoint(breakpoint);
}
}
- get breakpointsDisabledTemporarily()
- {
- return this._temporarilyDisabledBreakpointsRestoreSetting.value !== null;
- }
-
_startDisablingBreakpointsTemporarily()
{
console.assert(!this.breakpointsDisabledTemporarily, "Already temporarily disabling breakpoints.");
@@ -936,7 +942,7 @@
_updateBreakOnExceptionsState()
{
- var state = "none";
+ let state = "none";
if (this._breakpointsEnabledSetting.value) {
if (!this._allExceptionsBreakpoint.disabled)
@@ -975,9 +981,8 @@
{
this._ignoreBreakpointDisplayLocationDidChangeEvent = true;
- for (var i = 0; i < breakpoints.length; ++i) {
- var breakpoint = breakpoints[i];
- if (breakpoint.sourceCodeLocation.sourceCode === null)
+ for (let breakpoint of breakpoints) {
+ if (!breakpoint.sourceCodeLocation.sourceCode)
breakpoint.sourceCodeLocation.sourceCode = sourceCode;
// SourceCodes can be unequal if the SourceCodeLocation is associated with a Script and we are looking at the Resource.
console.assert(breakpoint.sourceCodeLocation.sourceCode === sourceCode || breakpoint.sourceCodeLocation.sourceCode.contentIdentifier === sourceCode.contentIdentifier);