Modified: trunk/LayoutTests/inspector/debugger/breakpoint-manager.html (112265 => 112266)
--- trunk/LayoutTests/inspector/debugger/breakpoint-manager.html 2012-03-27 14:42:47 UTC (rev 112265)
+++ trunk/LayoutTests/inspector/debugger/breakpoint-manager.html 2012-03-27 14:43:46 UTC (rev 112266)
@@ -13,15 +13,17 @@
};
var uiBreakpoints = {};
- function breakpointAdded(breakpoint)
+ function breakpointAdded(event)
{
+ var breakpoint = event.data;
InspectorTest.addResult("breakpointAdded(" + [breakpoint.uiSourceCode.id, breakpoint.lineNumber, breakpoint.condition, breakpoint.enabled].join(", ") + ")");
var breakpointId = breakpoint.uiSourceCode.id + ":" + breakpoint.lineNumber;
InspectorTest.assertTrue(!(breakpointId in uiBreakpoints));
uiBreakpoints[breakpointId] = breakpoint.condition + "|" + breakpoint.enabled;
}
- function breakpointRemoved(breakpoint)
+ function breakpointRemoved(event)
{
+ var breakpoint = event.data;
InspectorTest.addResult("breakpointRemoved(" + [breakpoint.uiSourceCode.id, breakpoint.lineNumber].join(", ") + ")");
var breakpointId = breakpoint.uiSourceCode.id + ":" + breakpoint.lineNumber;
InspectorTest.assertTrue(breakpointId in uiBreakpoints);
@@ -59,15 +61,12 @@
serializedBreakpoints.push(createBreakpoint("b.js", 3, "", true));
function createUISourceCode(id, url) { return new WebInspector.UISourceCodeImpl(id, url, null); }
- var uiSourceCodeA = createUISourceCode("a.js", "a.js");
- var uiSourceCodeB = createUISourceCode("b.js", "b.js");
var scriptMapping = {};
scriptMapping.rawLocationToUILocation = function(rawLocation) { return rawLocation; };
scriptMapping.uiLocationToRawLocation = function(uiSourceCode, lineNumber)
{
- scriptId = uiSourceCode === uiSourceCodeA ? "a.js" : "b.js";
- return { scriptId: scriptId, lineNumber: lineNumber, columnNumber: 0 };
+ return { scriptId: uiSourceCode.id, lineNumber: lineNumber, columnNumber: 0 };
}
function createBreakpointManager(breakpoints, scriptMapping)
@@ -76,15 +75,22 @@
uiBreakpoints = {};
debuggerBreakpoints = {};
debuggerModel.removeAllListeners();
- return new WebInspector.BreakpointManager(breakpointStorage, breakpointAdded, breakpointRemoved, debuggerModel, scriptMapping);
+ return new WebInspector.BreakpointManager(breakpointStorage, debuggerModel, scriptMapping);
}
+ function addUISourceCode(breakpointManager, uiSourceCode)
+ {
+ uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.BreakpointAdded, breakpointAdded);
+ uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.BreakpointRemoved, breakpointRemoved);
+ breakpointManager.uiSourceCodeAdded(uiSourceCode);
+ }
+
InspectorTest.runTestSuite([
function uiSourceCodeAdded(next)
{
var breakpointManager = createBreakpointManager(serializedBreakpoints, scriptMapping);
-
- breakpointManager.uiSourceCodeAdded(uiSourceCodeA);
+ var uiSourceCode = createUISourceCode("a.js", "a.js");
+ addUISourceCode(breakpointManager, uiSourceCode);
setTimeout(checkResults, 0);
function checkResults()
@@ -98,18 +104,18 @@
function setAndRemoveBreakpoints(next)
{
var breakpointManager = createBreakpointManager(serializedBreakpoints, scriptMapping);
-
- breakpointManager.uiSourceCodeAdded(uiSourceCodeA);
+ var uiSourceCode = createUISourceCode("a.js", "a.js");
+ addUISourceCode(breakpointManager, uiSourceCode);
setTimeout(setAndRemove, 0);
function setAndRemove()
{
- breakpointManager.setBreakpoint(uiSourceCodeA, 30, "", true);
+ breakpointManager.setBreakpoint(uiSourceCode, 30, "", true);
// Remove breakpoint immediately, breakpoint should be removed correctly from both debugger model and UI.
- breakpointManager.removeBreakpoint(uiSourceCodeA, 30);
+ breakpointManager.removeBreakpoint(uiSourceCode, 30);
- breakpointManager.removeBreakpoint(uiSourceCodeA, 10);
- breakpointManager.removeBreakpoint(uiSourceCodeA, 20);
+ breakpointManager.removeBreakpoint(uiSourceCode, 10);
+ breakpointManager.removeBreakpoint(uiSourceCode, 20);
setTimeout(checkResults, 0);
}
@@ -124,11 +130,11 @@
function setBreakpointOnComment(next)
{
var breakpointManager = createBreakpointManager([], scriptMapping);
+ var uiSourceCode = createUISourceCode("a.js", "a.js");
+ addUISourceCode(breakpointManager, uiSourceCode);
- breakpointManager.uiSourceCodeAdded(uiSourceCodeA);
-
debuggerModel.actualLocations = [{ lineNumber: 16, columnNumber: 0 }];
- breakpointManager.setBreakpoint(uiSourceCodeA, 15, "", true);
+ breakpointManager.setBreakpoint(uiSourceCode, 15, "", true);
setTimeout(checkResults, 0);
function checkResults()
{
@@ -140,11 +146,11 @@
function setBreakpointOutsideOfScript(next)
{
var breakpointManager = createBreakpointManager([], scriptMapping);
+ var uiSourceCode = createUISourceCode("a.js", "a.js");
+ addUISourceCode(breakpointManager, uiSourceCode);
- breakpointManager.uiSourceCodeAdded(uiSourceCodeA);
-
debuggerModel.actualLocations = [];
- breakpointManager.setBreakpoint(uiSourceCodeA, 15, "", true);
+ breakpointManager.setBreakpoint(uiSourceCode, 15, "", true);
setTimeout(checkResults, 0);
function checkResults()
{
@@ -156,8 +162,8 @@
function testNavigation(next)
{
var breakpointManager = createBreakpointManager(serializedBreakpoints, scriptMapping);
-
- breakpointManager.uiSourceCodeAdded(uiSourceCodeA);
+ var uiSourceCodeA = createUISourceCode("a.js", "a.js");
+ addUISourceCode(breakpointManager, uiSourceCodeA);
setTimeout(navigateToB, 0);
function navigateToB()
@@ -167,7 +173,8 @@
InspectorTest.addResult("\nNavigate to B.");
breakpointManager.debuggerReset();
- breakpointManager.uiSourceCodeAdded(uiSourceCodeB);
+ var uiSourceCodeB = createUISourceCode("b.js", "b.js");
+ addUISourceCode(breakpointManager, uiSourceCodeB);
setTimeout(navigateToA, 0);
}
@@ -181,7 +188,8 @@
var eventData = { breakpointId: "a.js:10:0", location: { scriptId: "a.js", lineNumber: 11, columnNumber: 5 }};
debuggerModel.dispatchEventToListeners(WebInspector.DebuggerModel.Events.BreakpointResolved, eventData);
- breakpointManager.uiSourceCodeAdded(uiSourceCodeA);
+ var uiSourceCodeA = createUISourceCode("a.js", "a.js");
+ addUISourceCode(breakpointManager, uiSourceCodeA);
setTimeout(checkResults, 0);
}
@@ -207,7 +215,7 @@
scriptMapping.rawLocationToUILocation = function(rawLocation) { return rawLocation; };
scriptMapping.uiLocationToRawLocation = function(uiSourceCode, lineNumber) { return { scriptId: "c.js", lineNumber: lineNumber, columnNumber: 0 }; };
- breakpointManager.uiSourceCodeAdded(originalUISourceCode);
+ addUISourceCode(breakpointManager, originalUISourceCode);
setTimeout(format, 0);
function format()
@@ -222,7 +230,7 @@
scriptMapping.rawLocationToUILocation = function(rawLocation) { return { lineNumber: rawLocation.lineNumber * 2, columnNumber: rawLocation.columnNumber * 2 }; };
scriptMapping.uiLocationToRawLocation = function(uiSourceCode, lineNumber) { return { scriptId: "c.js", lineNumber: Math.floor(lineNumber / 2), columnNumber: 0 }; };
- breakpointManager.uiSourceCodeAdded(formattedUISourceCode);
+ addUISourceCode(breakpointManager, formattedUISourceCode);
breakpointManager.setBreakpoint(formattedUISourceCode, 4, "", true);
breakpointManager.setBreakpoint(formattedUISourceCode, 8, "", false);
setTimeout(changeBreakpoints, 0);
@@ -245,7 +253,8 @@
InspectorTest.addResult("\nReload.");
breakpointManager.debuggerReset();
- breakpointManager.uiSourceCodeAdded(formattedUISourceCode);
+ var formattedUISourceCode = createUISourceCode("deobfuscated:c.js", "c.js");
+ addUISourceCode(breakpointManager, formattedUISourceCode);
var eventData = { breakpointId: "c.js:2:0", location: { scriptId: "c.js", lineNumber: 3, columnNumber: 0 }};
debuggerModel.dispatchEventToListeners(WebInspector.DebuggerModel.Events.BreakpointResolved, eventData);
eventData = { breakpointId: "c.js:6:0", location: { scriptId: "c.js", lineNumber: 6, columnNumber: 0 }};
Modified: trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js (112265 => 112266)
--- trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js 2012-03-27 14:42:47 UTC (rev 112265)
+++ trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js 2012-03-27 14:43:46 UTC (rev 112266)
@@ -39,7 +39,7 @@
this._presentationCallFrames = [];
- this._breakpointManager = new WebInspector.BreakpointManager(WebInspector.settings.breakpoints, this._breakpointAdded.bind(this), this._breakpointRemoved.bind(this), WebInspector.debuggerModel, this._scriptMapping);
+ this._breakpointManager = new WebInspector.BreakpointManager(WebInspector.settings.breakpoints, WebInspector.debuggerModel, this._scriptMapping);
this._pendingConsoleMessages = {};
this._consoleMessageLiveLocations = [];
@@ -63,8 +63,6 @@
UISourceCodeRemoved: "source-file-removed",
ConsoleMessageAdded: "console-message-added",
ConsoleMessagesCleared: "console-messages-cleared",
- UIBreakpointAdded: "ui-breakpoint-added",
- UIBreakpointRemoved: "ui-breakpoint-removed",
DebuggerPaused: "debugger-paused",
DebuggerResumed: "debugger-resumed",
DebuggerReset: "debugger-reset",
@@ -436,22 +434,6 @@
return uiSourceCode.breakpoints()[lineNumber];
},
- /**
- * @param {WebInspector.UIBreakpoint} uiBreakpoint
- */
- _breakpointAdded: function(uiBreakpoint)
- {
- this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.UIBreakpointAdded, uiBreakpoint);
- },
-
- /**
- * @param {WebInspector.UIBreakpoint} uiBreakpoint
- */
- _breakpointRemoved: function(uiBreakpoint)
- {
- this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.UIBreakpointRemoved, uiBreakpoint);
- },
-
_debuggerPaused: function()
{
var callFrames = WebInspector.debuggerModel.callFrames;
@@ -596,13 +578,17 @@
breakpointAdded: function(lineNumber, breakpoint)
{
+ console.assert(!this._breakpoints[lineNumber]);
this._breakpoints[lineNumber] = breakpoint;
+ this.dispatchEventToListeners(WebInspector.UISourceCode.Events.BreakpointAdded, breakpoint);
},
breakpointRemoved: function(lineNumber)
{
+ var breakpoint = this._breakpoints[lineNumber];
delete this._breakpoints[lineNumber];
- }
+ this.dispatchEventToListeners(WebInspector.UISourceCode.Events.BreakpointRemoved, breakpoint);
+ },
}
WebInspector.UISourceCodeImpl.prototype.__proto__ = WebInspector.UISourceCode.prototype;
Modified: trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js (112265 => 112266)
--- trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js 2012-03-27 14:42:47 UTC (rev 112265)
+++ trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js 2012-03-27 14:43:46 UTC (rev 112266)
@@ -177,8 +177,6 @@
this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.UISourceCodeRemoved, this._uiSourceCodeRemoved, this);
this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.ConsoleMessageAdded, this._consoleMessageAdded, this);
this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.ConsoleMessagesCleared, this._consoleMessagesCleared, this);
- this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.UIBreakpointAdded, this._uiBreakpointAdded, this);
- this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.UIBreakpointRemoved, this._uiBreakpointRemoved, this);
this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.DebuggerPaused, this._debuggerPaused, this);
this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.DebuggerResumed, this._debuggerResumed, this);
this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.CallFrameSelected, this._callFrameSelected, this);
@@ -258,6 +256,7 @@
_uiSourceCodeAdded: function(event)
{
var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.data;
+ this._addBreakpointListeners(uiSourceCode);
if (!uiSourceCode.url || uiSourceCode.isSnippetEvaluation) {
// Anonymous sources and snippets evaluations are shown only when stepping.
@@ -280,10 +279,29 @@
{
var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.data;
this._removeSourceFrame(uiSourceCode);
+ this._removeBreakpointListeners(uiSourceCode);
},
/**
* @param {WebInspector.UISourceCode} uiSourceCode
+ */
+ _addBreakpointListeners: function(uiSourceCode)
+ {
+ uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.BreakpointAdded, this._uiBreakpointAdded, this);
+ uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.BreakpointRemoved, this._uiBreakpointRemoved, this);
+ },
+
+ /**
+ * @param {WebInspector.UISourceCode} uiSourceCode
+ */
+ _removeBreakpointListeners: function(uiSourceCode)
+ {
+ uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.BreakpointAdded, this._uiBreakpointAdded, this);
+ uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.BreakpointRemoved, this._uiBreakpointRemoved, this);
+ },
+
+ /**
+ * @param {WebInspector.UISourceCode} uiSourceCode
* @param {boolean} isDirty
*/
setScriptSourceIsDirty: function(uiSourceCode, isDirty)
@@ -573,6 +591,11 @@
this._editorContainer.replaceFiles(oldUISourceCodeList, uiSourceCodeList);
for (var i = 0; i < oldUISourceCodeList.length; ++i)
this._removeSourceFrame(oldUISourceCodeList[i]);
+
+ for (var i = 0; i < oldUISourceCodeList.length; ++i)
+ this._removeBreakpointListeners(oldUISourceCodeList[i]);
+ for (var i = 0; i < uiSourceCodeList.length; ++i)
+ this._addBreakpointListeners(uiSourceCodeList[i]);
},
_sourceFrameLoaded: function(event)