function test()
{
+ var workspace;
var uiSourceCodes = {};
+ var mockTarget = {};
var defaultMapping = {
rawLocationToUILocation: function(rawLocation)
{
- return new WebInspector.UILocation(uiSourceCodes[rawLocation.scriptId], rawLocation.lineNumber, 0);
+ return uiSourceCodes[rawLocation.scriptId].uiLocation(rawLocation.lineNumber, 0);
},
uiLocationToRawLocation: function(uiSourceCode, lineNumber)
{
if (!uiSourceCodes[uiSourceCode.url])
return null;
- return new WebInspector.DebuggerModel.Location(uiSourceCode.url, lineNumber, 0);
+ return new WebInspector.DebuggerModel.Location(mockTarget, uiSourceCode.url, lineNumber, 0);
},
isIdentity: function()
{
if (this._disabled)
return null;
- return new WebInspector.UILocation(uiSourceCodes[rawLocation.scriptId], rawLocation.lineNumber + 10, 0);
+ return uiSourceCodes[rawLocation.scriptId].uiLocation(rawLocation.lineNumber + 10, 0);
},
uiLocationToRawLocation: function(uiSourceCode, lineNumber)
{
- return new WebInspector.DebuggerModel.Location(uiSourceCode.url, lineNumber - 10, 0);
+ return new WebInspector.DebuggerModel.Location(mockTarget, uiSourceCode.url, lineNumber - 10, 0);
},
isIdentity: function()
{
if (this._disabled)
return null;
- return new WebInspector.UILocation(uiSourceCodeB, rawLocation.lineNumber + 10, 0);
+ return uiSourceCodeB.uiLocation(rawLocation.lineNumber + 10, 0);
},
uiLocationToRawLocation: function(uiSourceCode, lineNumber)
{
- return new WebInspector.DebuggerModel.Location(uiSourceCodeA.url, lineNumber - 10, 0);
+ return new WebInspector.DebuggerModel.Location(mockTarget, uiSourceCodeA.url, lineNumber - 10, 0);
},
isIdentity: function()
function DebuggerModelMock(sourceMapping)
{
+ mockTarget.debuggerModel = this;
this._scripts = {};
this._sourceMapping = sourceMapping;
this._breakpoints = {};
}
DebuggerModelMock.prototype = {
+ target: function()
+ {
+ return mockTarget;
+ },
+
_addScript: function(scriptId, url)
{
- this._scripts[scriptId] = new WebInspector.Script(scriptId, url);
+ this._scripts[scriptId] = new WebInspector.Script(mockTarget, scriptId, url);
this._scripts[scriptId].pushSourceMapping(this._sourceMapping);
},
var locations = [];
var script = this._scriptForURL(url);
if (script) {
- var location = new WebInspector.DebuggerModel.Location(script.scriptId, lineNumber, 0);
+ var location = new WebInspector.DebuggerModel.Location(mockTarget, script.scriptId, lineNumber, 0);
locations.push(location);
}
return;
}
if (location.lineNumber >= 1000) {
- var shiftedLocation = {scriptId: location.scriptId, lineNumber: location.lineNumber + 10, columnNumber: location.columnNumber };
+ var shiftedLocation = new WebInspector.DebuggerModel.Location(mockTarget, location.scriptId, location.lineNumber + 10, location.columnNumber);
this._scheduleSetBeakpointCallback(callback, breakpointId, [shiftedLocation]);
return;
}
- this._scheduleSetBeakpointCallback(callback, breakpointId, [location]);
+ this._scheduleSetBeakpointCallback(callback, breakpointId, [WebInspector.DebuggerModel.Location.fromPayload(mockTarget, location)]);
},
removeBreakpoint: function(breakpointId, callback)
createLiveLocation: function(rawLocation, updateDelegate)
{
- return this._scripts[rawLocation.scriptId].createLiveLocation(rawLocation, updateDelegate);
+ return this._scripts[rawLocation.scriptId].createLiveLocation(rawLocation, updateDelegate);
},
scriptForId: function(scriptId)
function resetWorkspace(breakpointManager)
{
InspectorTest.addResult(" Resetting workspace.");
- breakpointManager._networkWorkspaceProvider.reset();
- breakpointManager._debuggerWorkspaceProvider.reset();
+ breakpointManager._networkWorkspaceBinding.reset();
+ breakpointManager._debuggerProjectDelegate.reset();
}
function breakpointAdded(event)
breakpointManager._debuggerModel._addScript(url, url);
InspectorTest.addResult(" Adding UISourceCode: " + url);
var contentProvider = new WebInspector.StaticContentProvider(WebInspector.resourceTypes.Script, "");
- var uiSourceCode = breakpointManager._networkWorkspaceProvider.addFileForURL(url, contentProvider, true);
+ var uiSourceCode = breakpointManager._networkWorkspaceBinding.addFileForURL(url, contentProvider);
uiSourceCodes[url] = uiSourceCode;
if (!doNotSetSourceMapping)
uiSourceCode.setSourceMapping(defaultMapping);
function addTemporaryUISourceCode(breakpointManager, url)
{
-
breakpointManager._debuggerModel._addScript(url, url);
InspectorTest.addResult(" Adding temporary UISourceCode: " + url);
var contentProvider = new WebInspector.StaticContentProvider(WebInspector.resourceTypes.Script, "");
- var uiSourceCode = breakpointManager._debuggerWorkspaceProvider.addUniqueFileForURL(url, contentProvider, true);
+ var path = breakpointManager._debuggerProjectDelegate.addContentProvider("", url, url, contentProvider);
+ var uiSourceCode = workspace.uiSourceCode("debugger:", path);
uiSourceCode.setSourceMapping(defaultMapping);
uiSourceCodes[url] = uiSourceCode;
return uiSourceCode;
var sourceMapping = sourceMapping || defaultMapping;
var debuggerModel = new DebuggerModelMock(sourceMapping);
- var workspace = new WebInspector.Workspace();
+ workspace = new WebInspector.Workspace();
var breakpointManager = new WebInspector.BreakpointManager(setting, debuggerModel, workspace);
- breakpointManager._networkWorkspaceProvider = new WebInspector.SimpleWorkspaceProvider(workspace, WebInspector.projectTypes.Network);
- breakpointManager._debuggerWorkspaceProvider = new WebInspector.SimpleWorkspaceProvider(workspace, WebInspector.projectTypes.Debugger);
+ breakpointManager._networkWorkspaceBinding = new WebInspector.NetworkWorkspaceBinding(workspace);
+ breakpointManager._debuggerProjectDelegate = new WebInspector.DebuggerProjectDelegate(workspace, "debugger:", WebInspector.projectTypes.Debugger);
breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.BreakpointAdded, breakpointAdded);
breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.BreakpointRemoved, breakpointRemoved);
InspectorTest.addResult(" Created breakpoints manager");
resetWorkspace(breakpointManager);
InspectorTest.addResult(" Resolving provisional breakpoint.");
addTemporaryUISourceCode(breakpointManager, "a.js");
- var eventData = { breakpointId: "a.js:10", location: { scriptId: "a.js", lineNumber: 11, columnNumber: 5 }};
+ var eventData = { breakpointId: "a.js:10", location: new WebInspector.DebuggerModel.Location(mockTarget, "a.js", 11, 5)};
breakpointManager._debuggerModel.dispatchEventToListeners(WebInspector.DebuggerModel.Events.BreakpointResolved, eventData);
addUISourceCode(breakpointManager, "a.js");
window.setBreakpointCallback = step4.bind(this);
resetWorkspace(breakpointManager);
InspectorTest.addResult(" Resolving provisional breakpoint.");
addTemporaryUISourceCode(breakpointManager, "a.js")
- var eventData = { breakpointId: "a.js:10", location: { scriptId: "a.js", lineNumber: 11, columnNumber: 5 }};
+ var eventData = { breakpointId: "a.js:10", location: new WebInspector.DebuggerModel.Location(mockTarget, "a.js", 11, 5)};
breakpointManager._debuggerModel.dispatchEventToListeners(WebInspector.DebuggerModel.Events.BreakpointResolved, eventData);
var breakpoints = breakpointManager.allBreakpoints();
InspectorTest.assertEquals(breakpoints.length, 1, "Exactly one provisional breakpoint should be registered in breakpoint manager.");
InspectorTest.addResult("\n Adding files:");
addTemporaryUISourceCode(breakpointManager, "a.js");
- var eventData = { breakpointId: "a.js:10", location: { scriptId: "a.js", lineNumber: 10, columnNumber: 5 }};
+ var eventData = { breakpointId: "a.js:10", location: new WebInspector.DebuggerModel.Location(mockTarget, "a.js", 10, 5)};
breakpointManager._debuggerModel.dispatchEventToListeners(WebInspector.DebuggerModel.Events.BreakpointResolved, eventData);
uiSourceCodeA = addUISourceCode(breakpointManager, "a.js");
uiSourceCodeB = addUISourceCode(breakpointManager, "b.js", true, true);
var uiSourceCode = addUISourceCode(breakpointManager, "a.js");
InspectorTest.addResult("\n Emulating breakpoint resolved event:");
- var eventData = { breakpointId: "a.js:10", location: { scriptId: "a.js", lineNumber: 10, columnNumber: 5 }};
+ var eventData = { breakpointId: "a.js:10", location: new WebInspector.DebuggerModel.Location(mockTarget, "a.js", 10, 5)};
breakpointManager._debuggerModel.dispatchEventToListeners(WebInspector.DebuggerModel.Events.BreakpointResolved, eventData);
InspectorTest.addResult("\n Waiting for breakpoint to be set in debugger again:");