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 { |
9 var defaultMapping = { | 9 var defaultMapping = { |
10 rawLocationToUILocation: function(rawLocation) | 10 rawLocationToUILocation: function(rawLocation) |
(...skipping 14 matching lines...) Expand all Loading... |
25 } | 25 } |
26 }; | 26 }; |
27 target.defaultMapping = defaultMapping; | 27 target.defaultMapping = defaultMapping; |
28 } | 28 } |
29 | 29 |
30 InspectorTest.dumpTarget = function(targetAware) | 30 InspectorTest.dumpTarget = function(targetAware) |
31 { | 31 { |
32 return InspectorTest.dumpTargetIds ? "target " + targetAware.target().id()
+ " " : ""; | 32 return InspectorTest.dumpTargetIds ? "target " + targetAware.target().id()
+ " " : ""; |
33 } | 33 } |
34 | 34 |
35 InspectorTest.DebuggerModelMock = function(target) | 35 InspectorTest.DebuggerModelMock = class extends WebInspector.SDKModel { |
36 { | 36 constructor(target) |
37 WebInspector.SDKModel.call(this, WebInspector.DebuggerModel, target); | 37 { |
38 this._breakpointResolvedEventTarget = new WebInspector.Object(); | 38 super(WebInspector.DebuggerModel, target); |
39 this._scripts = {}; | 39 this._breakpointResolvedEventTarget = new WebInspector.Object(); |
40 this._breakpoints = {}; | 40 this._scripts = {}; |
41 this._debuggerWorkspaceBinding = InspectorTest.testDebuggerWorkspaceBinding; | 41 this._breakpoints = {}; |
42 } | 42 this._debuggerWorkspaceBinding = InspectorTest.testDebuggerWorkspaceBind
ing; |
| 43 } |
43 | 44 |
44 InspectorTest.DebuggerModelMock.prototype = { | 45 target() |
45 target: function() | |
46 { | 46 { |
47 return this._target; | 47 return this._target; |
48 }, | 48 } |
49 | 49 |
50 _targetDisposed: function() { }, | 50 _targetDisposed() { } |
51 | 51 |
52 debuggerEnabled: function() | 52 debuggerEnabled() |
53 { | 53 { |
54 return true; | 54 return true; |
55 }, | 55 } |
56 | 56 |
57 scriptsForSourceURL: function(url) | 57 scriptsForSourceURL(url) |
58 { | 58 { |
59 var script = this._scriptForURL(url); | 59 var script = this._scriptForURL(url); |
60 return script ? [script] : []; | 60 return script ? [script] : []; |
61 }, | 61 } |
62 | 62 |
63 _addScript: function(scriptId, url) | 63 _addScript(scriptId, url) |
64 { | 64 { |
65 var script = new WebInspector.Script(this, scriptId, url); | 65 var script = new WebInspector.Script(this, scriptId, url); |
66 this._scripts[scriptId] = script; | 66 this._scripts[scriptId] = script; |
67 this._debuggerWorkspaceBinding._targetToData.get(this._target)._parsedSc
riptSource({data: script}); | 67 this._debuggerWorkspaceBinding._targetToData.get(this._target)._parsedSc
riptSource({data: script}); |
68 }, | 68 } |
69 | 69 |
70 _registerScript: function(script) | 70 _registerScript(script) |
71 { | 71 { |
72 this._scripts[script.scriptId] = script; | 72 this._scripts[script.scriptId] = script; |
73 this._debuggerWorkspaceBinding._targetToData.get(this._target)._parsedSc
riptSource({data: script}); | 73 this._debuggerWorkspaceBinding._targetToData.get(this._target)._parsedSc
riptSource({data: script}); |
74 }, | 74 } |
75 | 75 |
76 _scriptForURL: function(url) | 76 _scriptForURL(url) |
77 { | 77 { |
78 for (var scriptId in this._scripts) { | 78 for (var scriptId in this._scripts) { |
79 var script = this._scripts[scriptId]; | 79 var script = this._scripts[scriptId]; |
80 if (script.sourceURL === url) | 80 if (script.sourceURL === url) |
81 return script; | 81 return script; |
82 } | 82 } |
83 }, | 83 } |
84 | 84 |
85 _scheduleSetBeakpointCallback: function(callback, breakpointId, locations) | 85 _scheduleSetBeakpointCallback(callback, breakpointId, locations) |
86 { | 86 { |
87 setTimeout(innerCallback.bind(this), 0); | 87 setTimeout(innerCallback.bind(this), 0); |
88 | 88 |
89 function innerCallback() | 89 function innerCallback() |
90 { | 90 { |
91 if (callback) | 91 if (callback) |
92 callback(breakpointId, locations); | 92 callback(breakpointId, locations); |
93 if (window.setBreakpointCallback) { | 93 if (window.setBreakpointCallback) { |
94 var savedCallback = window.setBreakpointCallback; | 94 var savedCallback = window.setBreakpointCallback; |
95 delete window.setBreakpointCallback; | 95 delete window.setBreakpointCallback; |
96 savedCallback(); | 96 savedCallback(); |
97 } | 97 } |
98 } | 98 } |
99 }, | 99 } |
100 | 100 |
101 createRawLocation: function(script, line, column) | 101 createRawLocation(script, line, column) |
102 { | 102 { |
103 return new WebInspector.DebuggerModel.Location(this, script.scriptId, li
ne, column); | 103 return new WebInspector.DebuggerModel.Location(this, script.scriptId, li
ne, column); |
104 }, | 104 } |
105 | 105 |
106 setBreakpointByURL: function(url, lineNumber, columnNumber, condition, callb
ack) | 106 setBreakpointByURL(url, lineNumber, columnNumber, condition, callback) |
107 { | 107 { |
108 InspectorTest.addResult(" " + InspectorTest.dumpTarget(this) + "debug
gerModel.setBreakpoint(" + [url, lineNumber, condition].join(":") + ")"); | 108 InspectorTest.addResult(" " + InspectorTest.dumpTarget(this) + "debug
gerModel.setBreakpoint(" + [url, lineNumber, condition].join(":") + ")"); |
109 | 109 |
110 var breakpointId = url + ":" + lineNumber; | 110 var breakpointId = url + ":" + lineNumber; |
111 if (this._breakpoints[breakpointId]) { | 111 if (this._breakpoints[breakpointId]) { |
112 this._scheduleSetBeakpointCallback(callback, null); | 112 this._scheduleSetBeakpointCallback(callback, null); |
113 return; | 113 return; |
114 } | 114 } |
115 this._breakpoints[breakpointId] = true; | 115 this._breakpoints[breakpointId] = true; |
116 | 116 |
117 if (lineNumber >= 2000) { | 117 if (lineNumber >= 2000) { |
118 this._scheduleSetBeakpointCallback(callback, breakpointId, []); | 118 this._scheduleSetBeakpointCallback(callback, breakpointId, []); |
119 return; | 119 return; |
120 } | 120 } |
121 if (lineNumber >= 1000) { | 121 if (lineNumber >= 1000) { |
122 var shiftedLocation = new WebInspector.DebuggerModel.Location(this,
url, lineNumber + 10, columnNumber); | 122 var shiftedLocation = new WebInspector.DebuggerModel.Location(this,
url, lineNumber + 10, columnNumber); |
123 this._scheduleSetBeakpointCallback(callback, breakpointId, [shiftedL
ocation]); | 123 this._scheduleSetBeakpointCallback(callback, breakpointId, [shiftedL
ocation]); |
124 return; | 124 return; |
125 } | 125 } |
126 | 126 |
127 var locations = []; | 127 var locations = []; |
128 var script = this._scriptForURL(url); | 128 var script = this._scriptForURL(url); |
129 if (script) { | 129 if (script) { |
130 var location = new WebInspector.DebuggerModel.Location(this, script.
scriptId, lineNumber, 0); | 130 var location = new WebInspector.DebuggerModel.Location(this, script.
scriptId, lineNumber, 0); |
131 locations.push(location); | 131 locations.push(location); |
132 } | 132 } |
133 | 133 |
134 this._scheduleSetBeakpointCallback(callback, breakpointId, locations); | 134 this._scheduleSetBeakpointCallback(callback, breakpointId, locations); |
135 }, | 135 } |
136 | 136 |
137 removeBreakpoint: function(breakpointId, callback) | 137 removeBreakpoint(breakpointId, callback) |
138 { | 138 { |
139 InspectorTest.addResult(" " + InspectorTest.dumpTarget(this) + "debug
gerModel.removeBreakpoint(" + breakpointId + ")"); | 139 InspectorTest.addResult(" " + InspectorTest.dumpTarget(this) + "debug
gerModel.removeBreakpoint(" + breakpointId + ")"); |
140 delete this._breakpoints[breakpointId]; | 140 delete this._breakpoints[breakpointId]; |
141 if (callback) | 141 if (callback) |
142 setTimeout(callback, 0); | 142 setTimeout(callback, 0); |
143 }, | 143 } |
144 | 144 |
145 setBreakpointsActive: function() { }, | 145 setBreakpointsActive() { } |
146 | 146 |
147 scriptForId: function(scriptId) | 147 scriptForId(scriptId) |
148 { | 148 { |
149 return this._scripts[scriptId]; | 149 return this._scripts[scriptId]; |
150 }, | 150 } |
151 | 151 |
152 reset: function() | 152 reset() |
153 { | 153 { |
154 InspectorTest.addResult(" Resetting debugger."); | 154 InspectorTest.addResult(" Resetting debugger."); |
155 this._scripts = {}; | 155 this._scripts = {}; |
156 this._debuggerWorkspaceBinding._reset(this._target); | 156 this._debuggerWorkspaceBinding._reset(this._target); |
157 }, | 157 } |
158 | 158 |
159 pushSourceMapping: function(sourceMapping) | 159 pushSourceMapping(sourceMapping) |
160 { | 160 { |
161 for (var scriptId in this._scripts) | 161 for (var scriptId in this._scripts) |
162 this._debuggerWorkspaceBinding.pushSourceMapping(this._scripts[scrip
tId], sourceMapping); | 162 this._debuggerWorkspaceBinding.pushSourceMapping(this._scripts[scrip
tId], sourceMapping); |
163 }, | 163 } |
164 | 164 |
165 disableSourceMapping: function(sourceMapping) | 165 disableSourceMapping(sourceMapping) |
166 { | 166 { |
167 sourceMapping._disabled = true; | 167 sourceMapping._disabled = true; |
168 for (var scriptId in this._scripts) | 168 for (var scriptId in this._scripts) |
169 this._debuggerWorkspaceBinding.updateLocations(this._scripts[scriptI
d]); | 169 this._debuggerWorkspaceBinding.updateLocations(this._scripts[scriptI
d]); |
170 }, | 170 } |
171 | 171 |
172 addBreakpointListener: function(breakpointId, listener, thisObject) | 172 addBreakpointListener(breakpointId, listener, thisObject) |
173 { | 173 { |
174 this._breakpointResolvedEventTarget.addEventListener(breakpointId, liste
ner, thisObject) | 174 this._breakpointResolvedEventTarget.addEventListener(breakpointId, liste
ner, thisObject) |
175 }, | 175 } |
176 | 176 |
177 removeBreakpointListener: function(breakpointId, listener, thisObject) | 177 removeBreakpointListener(breakpointId, listener, thisObject) |
178 { | 178 { |
179 this._breakpointResolvedEventTarget.removeEventListener(breakpointId, li
stener, thisObject); | 179 this._breakpointResolvedEventTarget.removeEventListener(breakpointId, li
stener, thisObject); |
180 }, | 180 } |
181 | 181 |
182 _breakpointResolved: function(breakpointId, location) | 182 _breakpointResolved(breakpointId, location) |
183 { | 183 { |
184 this._breakpointResolvedEventTarget.dispatchEventToListeners(breakpointI
d, location); | 184 this._breakpointResolvedEventTarget.dispatchEventToListeners(breakpointI
d, location); |
185 }, | 185 } |
186 | 186 }; |
187 __proto__: WebInspector.Object.prototype | |
188 } | |
189 | 187 |
190 InspectorTest.setupLiveLocationSniffers = function() | 188 InspectorTest.setupLiveLocationSniffers = function() |
191 { | 189 { |
192 InspectorTest.addSniffer(WebInspector.DebuggerWorkspaceBinding.prototype, "c
reateLiveLocation", function(rawLocation) | 190 InspectorTest.addSniffer(WebInspector.DebuggerWorkspaceBinding.prototype, "c
reateLiveLocation", function(rawLocation) |
193 { | 191 { |
194 InspectorTest.addResult(" Location created: " + InspectorTest.dumpTar
get(rawLocation) + rawLocation.scriptId + ":" + rawLocation.lineNumber); | 192 InspectorTest.addResult(" Location created: " + InspectorTest.dumpTar
get(rawLocation) + rawLocation.scriptId + ":" + rawLocation.lineNumber); |
195 }, true); | 193 }, true); |
196 InspectorTest.addSniffer(WebInspector.DebuggerWorkspaceBinding.Location.prot
otype, "dispose", function() | 194 InspectorTest.addSniffer(WebInspector.DebuggerWorkspaceBinding.Location.prot
otype, "dispose", function() |
197 { | 195 { |
198 InspectorTest.addResult(" Location disposed: " + InspectorTest.dumpTa
rget(this._rawLocation) + this._rawLocation.scriptId + ":" + this._rawLocation.l
ineNumber); | 196 InspectorTest.addResult(" Location disposed: " + InspectorTest.dumpTa
rget(this._rawLocation) + this._rawLocation.scriptId + ":" + this._rawLocation.l
ineNumber); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 } | 379 } |
382 | 380 |
383 function finish() | 381 function finish() |
384 { | 382 { |
385 InspectorTest.dumpBreakpointLocations(breakpointManager); | 383 InspectorTest.dumpBreakpointLocations(breakpointManager); |
386 next(); | 384 next(); |
387 } | 385 } |
388 } | 386 } |
389 | 387 |
390 } | 388 } |
OLD | NEW |