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; | 5 InspectorTest.dumpTargetIds = false; |
6 | 6 |
7 InspectorTest.initializeDefaultMappingOnTarget = function (target) { | 7 InspectorTest.initializeDefaultMappingOnTarget = function(target) |
8 { | |
8 var defaultMapping = { | 9 var defaultMapping = { |
9 rawLocationToUILocation: function(rawLocation) | 10 rawLocationToUILocation: function(rawLocation) |
10 { | 11 { |
11 return InspectorTest.uiSourceCodes[rawLocation.scriptId].uiLocation( rawLocation.lineNumber, 0); | 12 return InspectorTest.uiSourceCodes[rawLocation.scriptId].uiLocation( rawLocation.lineNumber, 0); |
12 }, | 13 }, |
13 | 14 |
14 uiLocationToRawLocation: function(uiSourceCode, lineNumber) | 15 uiLocationToRawLocation: function(uiSourceCode, lineNumber) |
15 { | 16 { |
16 if (!InspectorTest.uiSourceCodes[uiSourceCode.url]) | 17 if (!InspectorTest.uiSourceCodes[uiSourceCode.url]) |
17 return null; | 18 return null; |
18 return new WebInspector.DebuggerModel.Location(target, uiSourceCode. url, lineNumber, 0); | 19 return new WebInspector.DebuggerModel.Location(target, uiSourceCode. url, lineNumber, 0); |
19 }, | 20 }, |
20 | 21 |
21 isIdentity: function() | 22 isIdentity: function() |
22 { | 23 { |
23 return true; | 24 return true; |
24 } | 25 } |
25 }; | 26 }; |
26 | |
27 target.defaultMapping = defaultMapping; | 27 target.defaultMapping = defaultMapping; |
28 } | 28 } |
29 | 29 |
30 InspectorTest.createMockTarget = function(targetManager, id) | 30 InspectorTest.createMockTarget = function(id) |
31 { | 31 { |
32 var target = { | 32 var target = { |
33 id: function() | 33 id: function() |
34 { | 34 { |
35 return id; | 35 return id; |
36 }, | 36 }, |
37 | 37 |
38 addEventListener: function() { }, | 38 addEventListener: function() { }, |
39 removeEventListener: function() { }, | 39 removeEventListener: function() { }, |
40 dispose: function() { } | 40 dispose: function() { }, |
41 isDetached: function() { return !!this.detached; } | |
41 }; | 42 }; |
43 target._modelByConstructor = new Map(); | |
42 InspectorTest.initializeDefaultMappingOnTarget(target); | 44 InspectorTest.initializeDefaultMappingOnTarget(target); |
45 target.debuggerModel = new InspectorTest.DebuggerModelMock(target, target.de faultMapping, InspectorTest.testDebuggerWorkspaceBinding); | |
46 target.debuggerModel._target = target; | |
43 return target; | 47 return target; |
44 } | 48 } |
45 | 49 |
46 InspectorTest.dumpTarget = function(targetAware) | 50 InspectorTest.dumpTarget = function(targetAware) |
47 { | 51 { |
48 return InspectorTest.dumpTargetIds ? "target " + targetAware.target().id() + " " : ""; | 52 return InspectorTest.dumpTargetIds ? "target " + targetAware.target().id() + " " : ""; |
49 } | 53 } |
50 | 54 |
51 InspectorTest.DebuggerModelMock = function(target, sourceMapping) | 55 InspectorTest.DebuggerModelMock = function(target, sourceMapping, debuggerWorksp aceBinding) |
52 { | 56 { |
53 target.debuggerModel = this; | 57 WebInspector.SDKModel.call(this, WebInspector.DebuggerModel, target); |
54 this._target = target; | |
55 this._breakpointResolvedEventTarget = new WebInspector.Object(); | 58 this._breakpointResolvedEventTarget = new WebInspector.Object(); |
56 this._scripts = {}; | 59 this._scripts = {}; |
57 this._sourceMapping = sourceMapping; | 60 this._sourceMapping = sourceMapping; |
58 this._breakpoints = {}; | 61 this._breakpoints = {}; |
62 this._debuggerWorkspaceBinding = InspectorTest.testDebuggerWorkspaceBinding; | |
59 } | 63 } |
60 | 64 |
61 InspectorTest.DebuggerModelMock.prototype = { | 65 InspectorTest.DebuggerModelMock.prototype = { |
62 target: function() | 66 target: function() |
63 { | 67 { |
64 return this._target; | 68 return this._target; |
65 }, | 69 }, |
66 | 70 |
67 debuggerEnabled: function() | 71 debuggerEnabled: function() |
68 { | 72 { |
69 return true; | 73 return true; |
70 }, | 74 }, |
71 | 75 |
76 scriptsForSourceURL: function(url) | |
77 { | |
78 var script = this._scriptForURL(url); | |
79 return script ? [script] : []; | |
80 }, | |
81 | |
72 _addScript: function(scriptId, url) | 82 _addScript: function(scriptId, url) |
73 { | 83 { |
74 this._scripts[scriptId] = new WebInspector.Script(this._target, scriptId , url); | 84 var script = new WebInspector.Script(this._target, scriptId, url); |
75 this._scripts[scriptId].pushSourceMapping(this._sourceMapping); | 85 this._scripts[scriptId] = script; |
86 this._debuggerWorkspaceBinding._targetToData.get(this._target)._parsedSc riptSource({data: script}); | |
87 }, | |
88 | |
89 _registerScript: function(script) | |
90 { | |
91 this._scripts[script.scriptId] = script; | |
92 this._debuggerWorkspaceBinding._targetToData.get(this._target)._parsedSc riptSource({data: script}); | |
76 }, | 93 }, |
77 | 94 |
78 _scriptForURL: function(url) | 95 _scriptForURL: function(url) |
79 { | 96 { |
80 for (var scriptId in this._scripts) { | 97 for (var scriptId in this._scripts) { |
81 var script = this._scripts[scriptId]; | 98 var script = this._scripts[scriptId]; |
82 if (script.sourceURL === url) | 99 if (script.sourceURL === url) |
83 return script; | 100 return script; |
84 } | 101 } |
85 }, | 102 }, |
86 | 103 |
87 _scheduleSetBeakpointCallback: function(callback, breakpointId, locations) | 104 _scheduleSetBeakpointCallback: function(callback, breakpointId, locations) |
88 { | 105 { |
89 setTimeout(innerCallback.bind(this), 0); | 106 setTimeout(innerCallback.bind(this), 0); |
90 | 107 |
91 function innerCallback() | 108 function innerCallback() |
92 { | 109 { |
93 if (callback) | 110 if (callback) |
94 callback(breakpointId, locations); | 111 callback(breakpointId, locations); |
95 if (window.setBreakpointCallback) { | 112 if (window.setBreakpointCallback) { |
96 var savedCallback = window.setBreakpointCallback; | 113 var savedCallback = window.setBreakpointCallback; |
97 delete window.setBreakpointCallback; | 114 delete window.setBreakpointCallback; |
98 savedCallback(); | 115 savedCallback(); |
99 } | 116 } |
100 } | 117 } |
101 }, | 118 }, |
102 | 119 |
103 rawLocationToUILocation: function(rawLocation) | 120 createRawLocation: function(script, line, column) |
104 { | 121 { |
105 return this._scripts[rawLocation.scriptId].rawLocationToUILocation(rawLo cation.lineNumber, rawLocation.columnNumber); | 122 return new WebInspector.DebuggerModel.Location(this.target(), script.scr iptId, line, column); |
106 }, | 123 }, |
107 | 124 |
108 setBreakpointByURL: function(url, lineNumber, columnNumber, condition, callb ack) | 125 setBreakpointByURL: function(url, lineNumber, columnNumber, condition, callb ack) |
109 { | 126 { |
110 InspectorTest.addResult(" " + InspectorTest.dumpTarget(this) + "debug gerModel.setBreakpoint(" + [url, lineNumber, condition].join(":") + ")"); | 127 InspectorTest.addResult(" " + InspectorTest.dumpTarget(this) + "debug gerModel.setBreakpoint(" + [url, lineNumber, condition].join(":") + ")"); |
111 | 128 |
112 var breakpointId = url + ":" + lineNumber; | 129 var breakpointId = url + ":" + lineNumber; |
113 if (this._breakpoints[breakpointId]) { | 130 if (this._breakpoints[breakpointId]) { |
114 this._scheduleSetBeakpointCallback(callback, null); | 131 this._scheduleSetBeakpointCallback(callback, null); |
115 return; | 132 return; |
(...skipping 23 matching lines...) Expand all Loading... | |
139 removeBreakpoint: function(breakpointId, callback) | 156 removeBreakpoint: function(breakpointId, callback) |
140 { | 157 { |
141 InspectorTest.addResult(" " + InspectorTest.dumpTarget(this) + "debug gerModel.removeBreakpoint(" + breakpointId + ")"); | 158 InspectorTest.addResult(" " + InspectorTest.dumpTarget(this) + "debug gerModel.removeBreakpoint(" + breakpointId + ")"); |
142 delete this._breakpoints[breakpointId]; | 159 delete this._breakpoints[breakpointId]; |
143 if (callback) | 160 if (callback) |
144 setTimeout(callback, 0); | 161 setTimeout(callback, 0); |
145 }, | 162 }, |
146 | 163 |
147 setBreakpointsActive: function() { }, | 164 setBreakpointsActive: function() { }, |
148 | 165 |
149 createLiveLocation: function(rawLocation, updateDelegate) | |
150 { | |
151 return this._scripts[rawLocation.scriptId].createLiveLocation(rawLocatio n, updateDelegate); | |
152 }, | |
153 | |
154 scriptForId: function(scriptId) | 166 scriptForId: function(scriptId) |
155 { | 167 { |
156 return this._scripts[scriptId]; | 168 return this._scripts[scriptId]; |
157 }, | 169 }, |
158 | 170 |
159 reset: function() | 171 reset: function() |
160 { | 172 { |
161 InspectorTest.addResult(" Resetting debugger."); | 173 InspectorTest.addResult(" Resetting debugger."); |
162 this._scripts = {}; | 174 this._scripts = {}; |
175 this._debuggerWorkspaceBinding._reset(this._target); | |
163 }, | 176 }, |
164 | 177 |
165 pushSourceMapping: function(sourceMapping) | 178 pushSourceMapping: function(sourceMapping) |
166 { | 179 { |
167 for (var scriptId in this._scripts) | 180 for (var scriptId in this._scripts) |
168 this._scripts[scriptId].pushSourceMapping(sourceMapping); | 181 this._debuggerWorkspaceBinding.pushSourceMapping(this._scripts[scrip tId], sourceMapping); |
169 }, | 182 }, |
170 | 183 |
171 disableSourceMapping: function(sourceMapping) | 184 disableSourceMapping: function(sourceMapping) |
172 { | 185 { |
173 sourceMapping._disabled = true; | 186 sourceMapping._disabled = true; |
174 for (var scriptId in this._scripts) | 187 for (var scriptId in this._scripts) |
175 this._scripts[scriptId].updateLocations(); | 188 this._debuggerWorkspaceBinding.updateLocations(this._scripts[scriptI d]); |
176 }, | 189 }, |
177 | 190 |
178 addBreakpointListener: function(breakpointId, listener, thisObject) | 191 addBreakpointListener: function(breakpointId, listener, thisObject) |
179 { | 192 { |
180 this._breakpointResolvedEventTarget.addEventListener(breakpointId, liste ner, thisObject) | 193 this._breakpointResolvedEventTarget.addEventListener(breakpointId, liste ner, thisObject) |
181 }, | 194 }, |
182 | 195 |
183 removeBreakpointListener: function(breakpointId, listener, thisObject) | 196 removeBreakpointListener: function(breakpointId, listener, thisObject) |
184 { | 197 { |
185 this._breakpointResolvedEventTarget.removeEventListener(breakpointId, li stener, thisObject); | 198 this._breakpointResolvedEventTarget.removeEventListener(breakpointId, li stener, thisObject); |
186 }, | 199 }, |
187 | 200 |
188 _breakpointResolved: function(breakpointId, location) | 201 _breakpointResolved: function(breakpointId, location) |
189 { | 202 { |
190 this._breakpointResolvedEventTarget.dispatchEventToListeners(breakpointI d, location); | 203 this._breakpointResolvedEventTarget.dispatchEventToListeners(breakpointI d, location); |
191 }, | 204 }, |
192 | 205 |
193 __proto__: WebInspector.Object.prototype | 206 __proto__: WebInspector.Object.prototype |
194 } | 207 } |
195 | 208 |
196 InspectorTest.setupLiveLocationSniffers = function() | 209 InspectorTest.setupLiveLocationSniffers = function() |
197 { | 210 { |
198 InspectorTest.addSniffer(WebInspector.DebuggerWorkspaceBinding.prototype, "c reateLiveLocation", function(rawLocation) | 211 InspectorTest.addSniffer(WebInspector.DebuggerWorkspaceBinding.prototype, "c reateLiveLocation", function(rawLocation) |
199 { | 212 { |
200 InspectorTest.addResult(" Location created: " + InspectorTest.dumpTar get(rawLocation) + rawLocation.scriptId + ":" + rawLocation.lineNumber); | 213 InspectorTest.addResult(" Location created: " + InspectorTest.dumpTar get(rawLocation) + rawLocation.scriptId + ":" + rawLocation.lineNumber); |
201 }, true); | 214 }, true); |
202 InspectorTest.addSniffer(WebInspector.Script.Location.prototype, "dispose", function() | 215 InspectorTest.addSniffer(WebInspector.DebuggerWorkspaceBinding.Location.prot otype, "dispose", function() |
203 { | 216 { |
204 InspectorTest.addResult(" Location disposed: " + InspectorTest.dumpTa rget(this._rawLocation) + this._rawLocation.scriptId + ":" + this._rawLocation.l ineNumber); | 217 InspectorTest.addResult(" Location disposed: " + InspectorTest.dumpTa rget(this._rawLocation) + this._rawLocation.scriptId + ":" + this._rawLocation.l ineNumber); |
205 }, true); | 218 }, true); |
206 } | 219 } |
207 | 220 |
208 InspectorTest.addScript = function(target, breakpointManager, url) | 221 InspectorTest.addScript = function(target, breakpointManager, url) |
209 { | 222 { |
210 target.debuggerModel._addScript(url, url); | 223 target.debuggerModel._addScript(url, url); |
211 InspectorTest.addResult(" Adding script: " + url); | 224 InspectorTest.addResult(" Adding script: " + url); |
212 var contentProvider = new WebInspector.StaticContentProvider(WebInspector.re sourceTypes.Script, ""); | 225 var uiSourceCodes = breakpointManager._workspace.uiSourceCodesForProjectType (WebInspector.projectTypes.Debugger); |
213 var path = breakpointManager._debuggerProjectDelegate.addContentProvider("", url, url, contentProvider); | 226 for (var i = 0; i < uiSourceCodes.length; ++i) { |
214 var uiSourceCode = breakpointManager._workspace.uiSourceCode("debugger:", pa th); | 227 var uiSourceCode = uiSourceCodes[i]; |
215 uiSourceCode.setSourceMappingForTarget(target, target.defaultMapping); | 228 if (uiSourceCode.url === url) { |
216 InspectorTest.uiSourceCodes[url] = uiSourceCode; | 229 uiSourceCode.setSourceMappingForTarget(target, breakpointManager.def aultMapping); |
217 return uiSourceCode; | 230 InspectorTest.uiSourceCodes[url] = uiSourceCode; |
231 return uiSourceCode; | |
232 } | |
233 } | |
218 } | 234 } |
219 | 235 |
220 InspectorTest.addUISourceCode = function(target, breakpointManager, url, doNotSe tSourceMapping, doNotAddScript) | 236 InspectorTest.addUISourceCode = function(target, breakpointManager, url, doNotSe tSourceMapping, doNotAddScript) |
221 { | 237 { |
222 if (!doNotAddScript) | 238 if (!doNotAddScript) |
223 InspectorTest.addScript(target, breakpointManager, url); | 239 InspectorTest.addScript(target, breakpointManager, url); |
224 InspectorTest.addResult(" Adding UISourceCode: " + url); | 240 InspectorTest.addResult(" Adding UISourceCode: " + url); |
225 var contentProvider = new WebInspector.StaticContentProvider(WebInspector.re sourceTypes.Script, ""); | 241 var contentProvider = new WebInspector.StaticContentProvider(WebInspector.re sourceTypes.Script, ""); |
226 var uiSourceCode = breakpointManager._networkWorkspaceBinding.addFileForURL( url, contentProvider); | 242 var dwb = breakpointManager._debuggerWorkspaceBinding; |
vsevik
2014/08/04 09:05:15
I would avoid such an abbreviation.
apavlov
2014/08/04 10:04:34
Done.
| |
243 var uiSourceCode = dwb._networkWorkspaceBinding.addFileForURL(url, contentPr ovider); | |
227 InspectorTest.uiSourceCodes[url] = uiSourceCode; | 244 InspectorTest.uiSourceCodes[url] = uiSourceCode; |
228 if (!doNotSetSourceMapping) { | 245 if (!doNotSetSourceMapping) { |
229 uiSourceCode.setSourceMappingForTarget(target, target.defaultMapping); | 246 uiSourceCode.setSourceMappingForTarget(target, breakpointManager.default Mapping); |
230 target.debuggerModel.scriptForId(url).updateLocations(); | 247 breakpointManager._debuggerWorkspaceBinding.updateLocations(target.debug gerModel.scriptForId(url)); |
231 } | 248 } |
232 return uiSourceCode; | 249 return uiSourceCode; |
233 } | 250 } |
234 | 251 |
235 InspectorTest.createBreakpointManager = function(targetManager, persistentBreakp oints) | 252 InspectorTest.createBreakpointManager = function(targetManager, debuggerWorkspac eBinding, persistentBreakpoints) |
236 { | 253 { |
237 InspectorTest._pendingBreakpointUpdates = 0; | 254 InspectorTest._pendingBreakpointUpdates = 0; |
238 InspectorTest.addSniffer(WebInspector.BreakpointManager.TargetBreakpoint.pro totype, "_updateInDebugger", updateInDebugger, true); | 255 InspectorTest.addSniffer(WebInspector.BreakpointManager.TargetBreakpoint.pro totype, "_updateInDebugger", updateInDebugger, true); |
239 InspectorTest.addSniffer(WebInspector.BreakpointManager.TargetBreakpoint.pro totype, "_didUpdateInDebugger", didUpdateInDebugger, true); | 256 InspectorTest.addSniffer(WebInspector.BreakpointManager.TargetBreakpoint.pro totype, "_didUpdateInDebugger", didUpdateInDebugger, true); |
240 | 257 |
241 function updateInDebugger() | 258 function updateInDebugger() |
242 { | 259 { |
243 InspectorTest._pendingBreakpointUpdates++; | 260 InspectorTest._pendingBreakpointUpdates++; |
244 } | 261 } |
245 | 262 |
(...skipping 15 matching lines...) Expand all Loading... | |
261 var uiLocation = event.data.uiLocation; | 278 var uiLocation = event.data.uiLocation; |
262 InspectorTest.addResult(" breakpointAdded(" + [uiLocation.uiSourceCod e.originURL(), uiLocation.lineNumber, uiLocation.columnNumber, breakpoint.condit ion(), breakpoint.enabled()].join(", ") + ")"); | 279 InspectorTest.addResult(" breakpointAdded(" + [uiLocation.uiSourceCod e.originURL(), uiLocation.lineNumber, uiLocation.columnNumber, breakpoint.condit ion(), breakpoint.enabled()].join(", ") + ")"); |
263 } | 280 } |
264 | 281 |
265 function breakpointRemoved(event) | 282 function breakpointRemoved(event) |
266 { | 283 { |
267 var uiLocation = event.data.uiLocation; | 284 var uiLocation = event.data.uiLocation; |
268 InspectorTest.addResult(" breakpointRemoved(" + [uiLocation.uiSourceC ode.originURL(), uiLocation.lineNumber, uiLocation.columnNumber].join(", ") + ") "); | 285 InspectorTest.addResult(" breakpointRemoved(" + [uiLocation.uiSourceC ode.originURL(), uiLocation.lineNumber, uiLocation.columnNumber].join(", ") + ") "); |
269 } | 286 } |
270 var targets = targetManager.targets(); | 287 var targets = targetManager.targets(); |
271 for (var i = 0; i < targets.length; ++i) | 288 var mappingForManager; |
272 new InspectorTest.DebuggerModelMock(targets[i], targets[i].defaultMappin g); | 289 for (var i = 0; i < targets.length; ++i) { |
290 InspectorTest.initializeDefaultMappingOnTarget(targets[i]); | |
291 if (!mappingForManager) | |
292 mappingForManager = targets[i].defaultMapping; | |
293 var model = new InspectorTest.DebuggerModelMock(targets[i], targets[i].d efaultMapping, debuggerWorkspaceBinding); | |
294 targets[i].debuggerModel = model; | |
295 } | |
273 | 296 |
274 var workspace = new WebInspector.Workspace(); | 297 var breakpointManager = new WebInspector.BreakpointManager(setting, debugger WorkspaceBinding._workspace, targetManager, debuggerWorkspaceBinding); |
275 var breakpointManager = new WebInspector.BreakpointManager(setting, workspac e, targetManager); | 298 breakpointManager.defaultMapping = mappingForManager; |
276 breakpointManager._networkWorkspaceBinding = new WebInspector.NetworkWorkspa ceBinding(workspace); | |
277 breakpointManager._debuggerProjectDelegate = new WebInspector.DebuggerProjec tDelegate(workspace, "debugger:", WebInspector.projectTypes.Debugger); | |
278 breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.Bre akpointAdded, breakpointAdded); | 299 breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.Bre akpointAdded, breakpointAdded); |
279 breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.Bre akpointRemoved, breakpointRemoved); | 300 breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.Bre akpointRemoved, breakpointRemoved); |
280 InspectorTest.addResult(" Created breakpoints manager"); | 301 InspectorTest.addResult(" Created breakpoints manager"); |
281 InspectorTest.dumpBreakpointStorage(breakpointManager); | 302 InspectorTest.dumpBreakpointStorage(breakpointManager); |
282 return breakpointManager; | 303 return breakpointManager; |
283 } | 304 } |
284 | 305 |
285 InspectorTest.setBreakpoint = function(breakpointManager, uiSourceCode, lineNumb er, columnNumber, condition, enabled, setBreakpointCallback) | 306 InspectorTest.setBreakpoint = function(breakpointManager, uiSourceCode, lineNumb er, columnNumber, condition, enabled, setBreakpointCallback) |
286 { | 307 { |
287 InspectorTest.addResult(" Setting breakpoint at " + uiSourceCode.originURL( ) + ":" + lineNumber + ":" + columnNumber + " enabled:" + enabled + " condition: " + condition); | 308 InspectorTest.addResult(" Setting breakpoint at " + uiSourceCode.originURL( ) + ":" + lineNumber + ":" + columnNumber + " enabled:" + enabled + " condition: " + condition); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
378 } | 399 } |
379 | 400 |
380 function finish() | 401 function finish() |
381 { | 402 { |
382 InspectorTest.dumpBreakpointLocations(breakpointManager); | 403 InspectorTest.dumpBreakpointLocations(breakpointManager); |
383 next(); | 404 next(); |
384 } | 405 } |
385 } | 406 } |
386 | 407 |
387 } | 408 } |
OLD | NEW |