OLD | NEW |
1 var initialize_BreakpointManagerTest = function() { | 1 var initialize_BreakpointManagerTest = function() { |
2 | 2 |
3 InspectorTest.uiSourceCodes = {}; | 3 InspectorTest.uiSourceCodes = {}; |
4 | 4 |
| 5 InspectorTest.dumpTargetIds = false; |
| 6 |
5 InspectorTest.initializeDefaultMappingOnTarget = function (target) { | 7 InspectorTest.initializeDefaultMappingOnTarget = function (target) { |
6 var defaultMapping = { | 8 var defaultMapping = { |
7 rawLocationToUILocation: function(rawLocation) | 9 rawLocationToUILocation: function(rawLocation) |
8 { | 10 { |
9 return InspectorTest.uiSourceCodes[rawLocation.scriptId].uiLocation(
rawLocation.lineNumber, 0); | 11 return InspectorTest.uiSourceCodes[rawLocation.scriptId].uiLocation(
rawLocation.lineNumber, 0); |
10 }, | 12 }, |
11 | 13 |
12 uiLocationToRawLocation: function(uiSourceCode, lineNumber) | 14 uiLocationToRawLocation: function(uiSourceCode, lineNumber) |
13 { | 15 { |
14 if (!InspectorTest.uiSourceCodes[uiSourceCode.url]) | 16 if (!InspectorTest.uiSourceCodes[uiSourceCode.url]) |
15 return null; | 17 return null; |
16 return new WebInspector.DebuggerModel.Location(target, uiSourceCode.
url, lineNumber, 0); | 18 return new WebInspector.DebuggerModel.Location(target, uiSourceCode.
url, lineNumber, 0); |
17 }, | 19 }, |
18 | 20 |
19 isIdentity: function() | 21 isIdentity: function() |
20 { | 22 { |
21 return true; | 23 return true; |
22 } | 24 } |
23 }; | 25 }; |
24 | 26 |
25 target.defaultMapping = defaultMapping; | 27 target.defaultMapping = defaultMapping; |
26 } | 28 } |
27 | 29 |
| 30 InspectorTest.createMockTarget = function(targetManager, id) |
| 31 { |
| 32 var target = { |
| 33 id: function() |
| 34 { |
| 35 return id; |
| 36 } |
| 37 }; |
| 38 InspectorTest.initializeDefaultMappingOnTarget(target); |
| 39 return target; |
| 40 } |
| 41 |
| 42 InspectorTest.dumpTarget = function(targetAware) |
| 43 { |
| 44 return InspectorTest.dumpTargetIds ? "target " + targetAware.target().id()
+ " " : ""; |
| 45 } |
| 46 |
28 InspectorTest.DebuggerModelMock = function (target, sourceMapping) | 47 InspectorTest.DebuggerModelMock = function (target, sourceMapping) |
29 { | 48 { |
30 target.debuggerModel = this; | 49 target.debuggerModel = this; |
31 this._target = target; | 50 this._target = target; |
32 this._breakpointResolvedEventTarget = new WebInspector.Object(); | 51 this._breakpointResolvedEventTarget = new WebInspector.Object(); |
33 this._scripts = {}; | 52 this._scripts = {}; |
34 this._sourceMapping = sourceMapping; | 53 this._sourceMapping = sourceMapping; |
35 this._breakpoints = {}; | 54 this._breakpoints = {}; |
36 } | 55 } |
37 | 56 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 if (window.setBreakpointCallback) { | 91 if (window.setBreakpointCallback) { |
73 var savedCallback = window.setBreakpointCallback; | 92 var savedCallback = window.setBreakpointCallback; |
74 delete window.setBreakpointCallback; | 93 delete window.setBreakpointCallback; |
75 savedCallback(); | 94 savedCallback(); |
76 } | 95 } |
77 } | 96 } |
78 }, | 97 }, |
79 | 98 |
80 setBreakpointByURL: function(url, lineNumber, columnNumber, condition, callb
ack) | 99 setBreakpointByURL: function(url, lineNumber, columnNumber, condition, callb
ack) |
81 { | 100 { |
82 InspectorTest.addResult(" debuggerModel.setBreakpoint(" + [url, lineN
umber, condition].join(":") + ")"); | 101 InspectorTest.addResult(" " + InspectorTest.dumpTarget(this) + "debug
gerModel.setBreakpoint(" + [url, lineNumber, condition].join(":") + ")"); |
83 | 102 |
84 var breakpointId = url + ":" + lineNumber; | 103 var breakpointId = url + ":" + lineNumber; |
85 if (this._breakpoints[breakpointId]) { | 104 if (this._breakpoints[breakpointId]) { |
86 this._scheduleSetBeakpointCallback(callback, null); | 105 this._scheduleSetBeakpointCallback(callback, null); |
87 return; | 106 return; |
88 } | 107 } |
89 this._breakpoints[breakpointId] = true; | 108 this._breakpoints[breakpointId] = true; |
90 | 109 |
91 var locations = []; | 110 var locations = []; |
92 var script = this._scriptForURL(url); | 111 var script = this._scriptForURL(url); |
93 if (script) { | 112 if (script) { |
94 var location = new WebInspector.DebuggerModel.Location(this._target,
script.scriptId, lineNumber, 0); | 113 var location = new WebInspector.DebuggerModel.Location(this._target,
script.scriptId, lineNumber, 0); |
95 locations.push(location); | 114 locations.push(location); |
96 } | 115 } |
97 | 116 |
98 this._scheduleSetBeakpointCallback(callback, breakpointId, locations); | 117 this._scheduleSetBeakpointCallback(callback, breakpointId, locations); |
99 }, | 118 }, |
100 | 119 |
101 setBreakpointByScriptLocation: function(location, condition, callback) | 120 setBreakpointByScriptLocation: function(location, condition, callback) |
102 { | 121 { |
103 InspectorTest.addResult(" debuggerModel.setBreakpoint(" + [location.s
criptId, location.lineNumber, condition].join(":") + ")"); | 122 InspectorTest.addResult(" " + InspectorTest.dumpTarget(this) + "debug
gerModel.setBreakpoint(" + [location.scriptId, location.lineNumber, condition].j
oin(":") + ")"); |
104 | 123 |
105 var breakpointId = location.scriptId + ":" + location.lineNumber; | 124 var breakpointId = location.scriptId + ":" + location.lineNumber; |
106 if (this._breakpoints[breakpointId]) { | 125 if (this._breakpoints[breakpointId]) { |
107 this._scheduleSetBeakpointCallback(callback, null); | 126 this._scheduleSetBeakpointCallback(callback, null); |
108 return; | 127 return; |
109 } | 128 } |
110 this._breakpoints[breakpointId] = true; | 129 this._breakpoints[breakpointId] = true; |
111 | 130 |
112 if (location.lineNumber >= 2000) { | 131 if (location.lineNumber >= 2000) { |
113 this._scheduleSetBeakpointCallback(callback, breakpointId, []); | 132 this._scheduleSetBeakpointCallback(callback, breakpointId, []); |
114 return; | 133 return; |
115 } | 134 } |
116 if (location.lineNumber >= 1000) { | 135 if (location.lineNumber >= 1000) { |
117 var shiftedLocation = new WebInspector.DebuggerModel.Location(this._
target, location.scriptId, location.lineNumber + 10, location.columnNumber); | 136 var shiftedLocation = new WebInspector.DebuggerModel.Location(this._
target, location.scriptId, location.lineNumber + 10, location.columnNumber); |
118 this._scheduleSetBeakpointCallback(callback, breakpointId, [shiftedL
ocation]); | 137 this._scheduleSetBeakpointCallback(callback, breakpointId, [shiftedL
ocation]); |
119 return; | 138 return; |
120 } | 139 } |
121 | 140 |
122 this._scheduleSetBeakpointCallback(callback, breakpointId, [WebInspector
.DebuggerModel.Location.fromPayload(this._target, location)]); | 141 this._scheduleSetBeakpointCallback(callback, breakpointId, [WebInspector
.DebuggerModel.Location.fromPayload(this._target, location)]); |
123 }, | 142 }, |
124 | 143 |
125 removeBreakpoint: function(breakpointId, callback) | 144 removeBreakpoint: function(breakpointId, callback) |
126 { | 145 { |
127 InspectorTest.addResult(" debuggerModel.removeBreakpoint(" + breakpoi
ntId + ")"); | 146 InspectorTest.addResult(" " + InspectorTest.dumpTarget(this) + "debug
gerModel.removeBreakpoint(" + breakpointId + ")"); |
128 delete this._breakpoints[breakpointId]; | 147 delete this._breakpoints[breakpointId]; |
129 if (callback) | 148 if (callback) |
130 callback(); | 149 callback(); |
131 }, | 150 }, |
132 | 151 |
133 setBreakpointsActive: function() { }, | 152 setBreakpointsActive: function() { }, |
134 | 153 |
135 createLiveLocation: function(rawLocation, updateDelegate) | 154 createLiveLocation: function(rawLocation, updateDelegate) |
136 { | 155 { |
137 return this._scripts[rawLocation.scriptId].createLiveLocation(rawLocatio
n, updateDelegate); | 156 return this._scripts[rawLocation.scriptId].createLiveLocation(rawLocatio
n, updateDelegate); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 { | 194 { |
176 this._breakpointResolvedEventTarget.dispatchEventToListeners(breakpointI
d, location); | 195 this._breakpointResolvedEventTarget.dispatchEventToListeners(breakpointI
d, location); |
177 } | 196 } |
178 } | 197 } |
179 InspectorTest.DebuggerModelMock.prototype.__proto__ = WebInspector.Object.protot
ype; | 198 InspectorTest.DebuggerModelMock.prototype.__proto__ = WebInspector.Object.protot
ype; |
180 | 199 |
181 InspectorTest.setupLiveLocationSniffers = function() | 200 InspectorTest.setupLiveLocationSniffers = function() |
182 { | 201 { |
183 InspectorTest.addSniffer(WebInspector.Script.prototype, "createLiveLocation"
, function(rawLocation) | 202 InspectorTest.addSniffer(WebInspector.Script.prototype, "createLiveLocation"
, function(rawLocation) |
184 { | 203 { |
185 InspectorTest.addResult(" Location created: " + rawLocation.scriptId
+ ":" + rawLocation.lineNumber); | 204 InspectorTest.addResult(" Location created: " + InspectorTest.dumpTar
get(rawLocation) + rawLocation.scriptId + ":" + rawLocation.lineNumber); |
186 }, true); | 205 }, true); |
187 InspectorTest.addSniffer(WebInspector.Script.Location.prototype, "dispose",
function() | 206 InspectorTest.addSniffer(WebInspector.Script.Location.prototype, "dispose",
function() |
188 { | 207 { |
189 InspectorTest.addResult(" Location disposed: " + this._rawLocation.sc
riptId + ":" + this._rawLocation.lineNumber); | 208 InspectorTest.addResult(" Location disposed: " + InspectorTest.dumpTa
rget(this._rawLocation) + this._rawLocation.scriptId + ":" + this._rawLocation.l
ineNumber); |
190 }, true); | 209 }, true); |
191 } | 210 } |
192 | 211 |
193 InspectorTest.addUISourceCode = function(target, breakpointManager, url, doNotSe
tSourceMapping, doNotAddScript) | 212 InspectorTest.addUISourceCode = function(target, breakpointManager, url, doNotSe
tSourceMapping, doNotAddScript) |
194 { | 213 { |
195 if (!doNotAddScript) | 214 if (!doNotAddScript) |
196 target.debuggerModel._addScript(url, url); | 215 target.debuggerModel._addScript(url, url); |
197 InspectorTest.addResult(" Adding UISourceCode: " + url); | 216 InspectorTest.addResult(" Adding UISourceCode: " + url); |
198 var contentProvider = new WebInspector.StaticContentProvider(WebInspector.re
sourceTypes.Script, ""); | 217 var contentProvider = new WebInspector.StaticContentProvider(WebInspector.re
sourceTypes.Script, ""); |
199 var uiSourceCode = breakpointManager._networkWorkspaceBinding.addFileForURL(
url, contentProvider); | 218 var uiSourceCode = breakpointManager._networkWorkspaceBinding.addFileForURL(
url, contentProvider); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 { | 323 { |
305 InspectorTest.dumpBreakpointLocations(breakpointManager); | 324 InspectorTest.dumpBreakpointLocations(breakpointManager); |
306 next(); | 325 next(); |
307 } | 326 } |
308 | 327 |
309 InspectorTest.dumpBreakpointLocations(breakpointManager); | 328 InspectorTest.dumpBreakpointLocations(breakpointManager); |
310 InspectorTest.resetBreakpointManager(breakpointManager, finish); | 329 InspectorTest.resetBreakpointManager(breakpointManager, finish); |
311 } | 330 } |
312 | 331 |
313 } | 332 } |
OLD | NEW |