Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sdk/DebuggerModel.js

Issue 2493373002: DevTools: rename WebInspector into modules. (Closed)
Patch Set: for bots Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 /** 31 /**
32 * @unrestricted 32 * @unrestricted
33 */ 33 */
34 WebInspector.DebuggerModel = class extends WebInspector.SDKModel { 34 SDK.DebuggerModel = class extends SDK.SDKModel {
35 /** 35 /**
36 * @param {!WebInspector.Target} target 36 * @param {!SDK.Target} target
37 */ 37 */
38 constructor(target) { 38 constructor(target) {
39 super(WebInspector.DebuggerModel, target); 39 super(SDK.DebuggerModel, target);
40 40
41 target.registerDebuggerDispatcher(new WebInspector.DebuggerDispatcher(this)) ; 41 target.registerDebuggerDispatcher(new SDK.DebuggerDispatcher(this));
42 this._agent = target.debuggerAgent(); 42 this._agent = target.debuggerAgent();
43 43
44 /** @type {?WebInspector.DebuggerPausedDetails} */ 44 /** @type {?SDK.DebuggerPausedDetails} */
45 this._debuggerPausedDetails = null; 45 this._debuggerPausedDetails = null;
46 /** @type {!Object.<string, !WebInspector.Script>} */ 46 /** @type {!Object.<string, !SDK.Script>} */
47 this._scripts = {}; 47 this._scripts = {};
48 /** @type {!Map.<string, !Array.<!WebInspector.Script>>} */ 48 /** @type {!Map.<string, !Array.<!SDK.Script>>} */
49 this._scriptsBySourceURL = new Map(); 49 this._scriptsBySourceURL = new Map();
50 50
51 /** @type {!WebInspector.Object} */ 51 /** @type {!Common.Object} */
52 this._breakpointResolvedEventTarget = new WebInspector.Object(); 52 this._breakpointResolvedEventTarget = new Common.Object();
53 53
54 this._isPausing = false; 54 this._isPausing = false;
55 WebInspector.moduleSetting('pauseOnExceptionEnabled').addChangeListener(this ._pauseOnExceptionStateChanged, this); 55 Common.moduleSetting('pauseOnExceptionEnabled').addChangeListener(this._paus eOnExceptionStateChanged, this);
56 WebInspector.moduleSetting('pauseOnCaughtException').addChangeListener(this. _pauseOnExceptionStateChanged, this); 56 Common.moduleSetting('pauseOnCaughtException').addChangeListener(this._pause OnExceptionStateChanged, this);
57 WebInspector.moduleSetting('enableAsyncStackTraces').addChangeListener(this. asyncStackTracesStateChanged, this); 57 Common.moduleSetting('enableAsyncStackTraces').addChangeListener(this.asyncS tackTracesStateChanged, this);
58 58
59 /** @type {!Map<string, string>} */ 59 /** @type {!Map<string, string>} */
60 this._fileURLToNodeJSPath = new Map(); 60 this._fileURLToNodeJSPath = new Map();
61 this.enableDebugger(); 61 this.enableDebugger();
62 } 62 }
63 63
64 /** 64 /**
65 * @return {!Array<!WebInspector.DebuggerModel>} 65 * @return {!Array<!SDK.DebuggerModel>}
66 */ 66 */
67 static instances() { 67 static instances() {
68 var result = []; 68 var result = [];
69 for (var target of WebInspector.targetManager.targets()) { 69 for (var target of SDK.targetManager.targets()) {
70 var debuggerModel = WebInspector.DebuggerModel.fromTarget(target); 70 var debuggerModel = SDK.DebuggerModel.fromTarget(target);
71 if (debuggerModel) 71 if (debuggerModel)
72 result.push(debuggerModel); 72 result.push(debuggerModel);
73 } 73 }
74 return result; 74 return result;
75 } 75 }
76 76
77 /** 77 /**
78 * @param {?WebInspector.Target} target 78 * @param {?SDK.Target} target
79 * @return {?WebInspector.DebuggerModel} 79 * @return {?SDK.DebuggerModel}
80 */ 80 */
81 static fromTarget(target) { 81 static fromTarget(target) {
82 if (!target || !target.hasJSCapability()) 82 if (!target || !target.hasJSCapability())
83 return null; 83 return null;
84 return /** @type {?WebInspector.DebuggerModel} */ (target.model(WebInspector .DebuggerModel)); 84 return /** @type {?SDK.DebuggerModel} */ (target.model(SDK.DebuggerModel));
85 } 85 }
86 86
87 /** 87 /**
88 * @return {boolean} 88 * @return {boolean}
89 */ 89 */
90 debuggerEnabled() { 90 debuggerEnabled() {
91 return !!this._debuggerEnabled; 91 return !!this._debuggerEnabled;
92 } 92 }
93 93
94 /** 94 /**
95 * @param {function()=} callback 95 * @param {function()=} callback
96 */ 96 */
97 enableDebugger(callback) { 97 enableDebugger(callback) {
98 if (this._debuggerEnabled) { 98 if (this._debuggerEnabled) {
99 if (callback) 99 if (callback)
100 callback(); 100 callback();
101 return; 101 return;
102 } 102 }
103 this._agent.enable(callback); 103 this._agent.enable(callback);
104 this._debuggerEnabled = true; 104 this._debuggerEnabled = true;
105 this._pauseOnExceptionStateChanged(); 105 this._pauseOnExceptionStateChanged();
106 this.asyncStackTracesStateChanged(); 106 this.asyncStackTracesStateChanged();
107 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.DebuggerWasE nabled); 107 this.dispatchEventToListeners(SDK.DebuggerModel.Events.DebuggerWasEnabled);
108 } 108 }
109 109
110 /** 110 /**
111 * @param {function()=} callback 111 * @param {function()=} callback
112 */ 112 */
113 disableDebugger(callback) { 113 disableDebugger(callback) {
114 if (!this._debuggerEnabled) { 114 if (!this._debuggerEnabled) {
115 if (callback) 115 if (callback)
116 callback(); 116 callback();
117 return; 117 return;
118 } 118 }
119 119
120 this._agent.disable(callback); 120 this._agent.disable(callback);
121 this._debuggerEnabled = false; 121 this._debuggerEnabled = false;
122 this._isPausing = false; 122 this._isPausing = false;
123 this.asyncStackTracesStateChanged(); 123 this.asyncStackTracesStateChanged();
124 this.globalObjectCleared(); 124 this.globalObjectCleared();
125 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.DebuggerWasD isabled); 125 this.dispatchEventToListeners(SDK.DebuggerModel.Events.DebuggerWasDisabled);
126 } 126 }
127 127
128 /** 128 /**
129 * @param {boolean} skip 129 * @param {boolean} skip
130 */ 130 */
131 _skipAllPauses(skip) { 131 _skipAllPauses(skip) {
132 if (this._skipAllPausesTimeout) { 132 if (this._skipAllPausesTimeout) {
133 clearTimeout(this._skipAllPausesTimeout); 133 clearTimeout(this._skipAllPausesTimeout);
134 delete this._skipAllPausesTimeout; 134 delete this._skipAllPausesTimeout;
135 } 135 }
136 this._agent.setSkipAllPauses(skip); 136 this._agent.setSkipAllPauses(skip);
137 } 137 }
138 138
139 /** 139 /**
140 * @param {number} timeout 140 * @param {number} timeout
141 */ 141 */
142 skipAllPausesUntilReloadOrTimeout(timeout) { 142 skipAllPausesUntilReloadOrTimeout(timeout) {
143 if (this._skipAllPausesTimeout) 143 if (this._skipAllPausesTimeout)
144 clearTimeout(this._skipAllPausesTimeout); 144 clearTimeout(this._skipAllPausesTimeout);
145 this._agent.setSkipAllPauses(true); 145 this._agent.setSkipAllPauses(true);
146 // If reload happens before the timeout, the flag will be already unset and the timeout callback won't change anything. 146 // If reload happens before the timeout, the flag will be already unset and the timeout callback won't change anything.
147 this._skipAllPausesTimeout = setTimeout(this._skipAllPauses.bind(this, false ), timeout); 147 this._skipAllPausesTimeout = setTimeout(this._skipAllPauses.bind(this, false ), timeout);
148 } 148 }
149 149
150 _pauseOnExceptionStateChanged() { 150 _pauseOnExceptionStateChanged() {
151 var state; 151 var state;
152 if (!WebInspector.moduleSetting('pauseOnExceptionEnabled').get()) { 152 if (!Common.moduleSetting('pauseOnExceptionEnabled').get()) {
153 state = WebInspector.DebuggerModel.PauseOnExceptionsState.DontPauseOnExcep tions; 153 state = SDK.DebuggerModel.PauseOnExceptionsState.DontPauseOnExceptions;
154 } else if (WebInspector.moduleSetting('pauseOnCaughtException').get()) { 154 } else if (Common.moduleSetting('pauseOnCaughtException').get()) {
155 state = WebInspector.DebuggerModel.PauseOnExceptionsState.PauseOnAllExcept ions; 155 state = SDK.DebuggerModel.PauseOnExceptionsState.PauseOnAllExceptions;
156 } else { 156 } else {
157 state = WebInspector.DebuggerModel.PauseOnExceptionsState.PauseOnUncaughtE xceptions; 157 state = SDK.DebuggerModel.PauseOnExceptionsState.PauseOnUncaughtExceptions ;
158 } 158 }
159 this._agent.setPauseOnExceptions(state); 159 this._agent.setPauseOnExceptions(state);
160 } 160 }
161 161
162 asyncStackTracesStateChanged() { 162 asyncStackTracesStateChanged() {
163 const maxAsyncStackChainDepth = 4; 163 const maxAsyncStackChainDepth = 4;
164 var enabled = WebInspector.moduleSetting('enableAsyncStackTraces').get() && this._debuggerEnabled; 164 var enabled = Common.moduleSetting('enableAsyncStackTraces').get() && this._ debuggerEnabled;
165 this._agent.setAsyncCallStackDepth(enabled ? maxAsyncStackChainDepth : 0); 165 this._agent.setAsyncCallStackDepth(enabled ? maxAsyncStackChainDepth : 0);
166 } 166 }
167 167
168 stepInto() { 168 stepInto() {
169 this._agent.stepInto(); 169 this._agent.stepInto();
170 } 170 }
171 171
172 stepOver() { 172 stepOver() {
173 this._agent.stepOver(); 173 this._agent.stepOver();
174 } 174 }
(...skipping 18 matching lines...) Expand all
193 */ 193 */
194 setBreakpointsActive(active) { 194 setBreakpointsActive(active) {
195 this._agent.setBreakpointsActive(active); 195 this._agent.setBreakpointsActive(active);
196 } 196 }
197 197
198 /** 198 /**
199 * @param {string} url 199 * @param {string} url
200 * @param {number} lineNumber 200 * @param {number} lineNumber
201 * @param {number=} columnNumber 201 * @param {number=} columnNumber
202 * @param {string=} condition 202 * @param {string=} condition
203 * @param {function(?Protocol.Debugger.BreakpointId, !Array.<!WebInspector.Deb uggerModel.Location>)=} callback 203 * @param {function(?Protocol.Debugger.BreakpointId, !Array.<!SDK.DebuggerMode l.Location>)=} callback
204 */ 204 */
205 setBreakpointByURL(url, lineNumber, columnNumber, condition, callback) { 205 setBreakpointByURL(url, lineNumber, columnNumber, condition, callback) {
206 // Convert file url to node-js path. 206 // Convert file url to node-js path.
207 if (this.target().isNodeJS() && this._fileURLToNodeJSPath.has(url)) 207 if (this.target().isNodeJS() && this._fileURLToNodeJSPath.has(url))
208 url = this._fileURLToNodeJSPath.get(url); 208 url = this._fileURLToNodeJSPath.get(url);
209 // Adjust column if needed. 209 // Adjust column if needed.
210 var minColumnNumber = 0; 210 var minColumnNumber = 0;
211 var scripts = this._scriptsBySourceURL.get(url) || []; 211 var scripts = this._scriptsBySourceURL.get(url) || [];
212 for (var i = 0, l = scripts.length; i < l; ++i) { 212 for (var i = 0, l = scripts.length; i < l; ++i) {
213 var script = scripts[i]; 213 var script = scripts[i];
214 if (lineNumber === script.lineOffset) 214 if (lineNumber === script.lineOffset)
215 minColumnNumber = minColumnNumber ? Math.min(minColumnNumber, script.col umnOffset) : script.columnOffset; 215 minColumnNumber = minColumnNumber ? Math.min(minColumnNumber, script.col umnOffset) : script.columnOffset;
216 } 216 }
217 columnNumber = Math.max(columnNumber, minColumnNumber); 217 columnNumber = Math.max(columnNumber, minColumnNumber);
218 218
219 var target = this.target(); 219 var target = this.target();
220 /** 220 /**
221 * @param {?Protocol.Error} error 221 * @param {?Protocol.Error} error
222 * @param {!Protocol.Debugger.BreakpointId} breakpointId 222 * @param {!Protocol.Debugger.BreakpointId} breakpointId
223 * @param {!Array.<!Protocol.Debugger.Location>} locations 223 * @param {!Array.<!Protocol.Debugger.Location>} locations
224 * @this {WebInspector.DebuggerModel} 224 * @this {SDK.DebuggerModel}
225 */ 225 */
226 function didSetBreakpoint(error, breakpointId, locations) { 226 function didSetBreakpoint(error, breakpointId, locations) {
227 if (callback) { 227 if (callback) {
228 var rawLocations = locations ? 228 var rawLocations = locations ?
229 locations.map( 229 locations.map(
230 WebInspector.DebuggerModel.Location.fromPayload.bind(WebInspecto r.DebuggerModel.Location, this)) : 230 SDK.DebuggerModel.Location.fromPayload.bind(SDK.DebuggerModel.Lo cation, this)) :
231 []; 231 [];
232 callback(error ? null : breakpointId, rawLocations); 232 callback(error ? null : breakpointId, rawLocations);
233 } 233 }
234 } 234 }
235 this._agent.setBreakpointByUrl(lineNumber, url, undefined, columnNumber, con dition, didSetBreakpoint.bind(this)); 235 this._agent.setBreakpointByUrl(lineNumber, url, undefined, columnNumber, con dition, didSetBreakpoint.bind(this));
236 } 236 }
237 237
238 /** 238 /**
239 * @param {!WebInspector.DebuggerModel.Location} rawLocation 239 * @param {!SDK.DebuggerModel.Location} rawLocation
240 * @param {string} condition 240 * @param {string} condition
241 * @param {function(?Protocol.Debugger.BreakpointId, !Array.<!WebInspector.Deb uggerModel.Location>)=} callback 241 * @param {function(?Protocol.Debugger.BreakpointId, !Array.<!SDK.DebuggerMode l.Location>)=} callback
242 */ 242 */
243 setBreakpointBySourceId(rawLocation, condition, callback) { 243 setBreakpointBySourceId(rawLocation, condition, callback) {
244 var target = this.target(); 244 var target = this.target();
245 245
246 /** 246 /**
247 * @this {WebInspector.DebuggerModel} 247 * @this {SDK.DebuggerModel}
248 * @param {?Protocol.Error} error 248 * @param {?Protocol.Error} error
249 * @param {!Protocol.Debugger.BreakpointId} breakpointId 249 * @param {!Protocol.Debugger.BreakpointId} breakpointId
250 * @param {!Protocol.Debugger.Location} actualLocation 250 * @param {!Protocol.Debugger.Location} actualLocation
251 */ 251 */
252 function didSetBreakpoint(error, breakpointId, actualLocation) { 252 function didSetBreakpoint(error, breakpointId, actualLocation) {
253 if (callback) { 253 if (callback) {
254 if (error || !actualLocation) { 254 if (error || !actualLocation) {
255 callback(null, []); 255 callback(null, []);
256 return; 256 return;
257 } 257 }
258 callback(breakpointId, [WebInspector.DebuggerModel.Location.fromPayload( this, actualLocation)]); 258 callback(breakpointId, [SDK.DebuggerModel.Location.fromPayload(this, act ualLocation)]);
259 } 259 }
260 } 260 }
261 this._agent.setBreakpoint(rawLocation.payload(), condition, didSetBreakpoint .bind(this)); 261 this._agent.setBreakpoint(rawLocation.payload(), condition, didSetBreakpoint .bind(this));
262 } 262 }
263 263
264 /** 264 /**
265 * @param {!Protocol.Debugger.BreakpointId} breakpointId 265 * @param {!Protocol.Debugger.BreakpointId} breakpointId
266 * @param {function()=} callback 266 * @param {function()=} callback
267 */ 267 */
268 removeBreakpoint(breakpointId, callback) { 268 removeBreakpoint(breakpointId, callback) {
269 this._agent.removeBreakpoint(breakpointId, innerCallback); 269 this._agent.removeBreakpoint(breakpointId, innerCallback);
270 270
271 /** 271 /**
272 * @param {?Protocol.Error} error 272 * @param {?Protocol.Error} error
273 */ 273 */
274 function innerCallback(error) { 274 function innerCallback(error) {
275 if (error) 275 if (error)
276 console.error('Failed to remove breakpoint: ' + error); 276 console.error('Failed to remove breakpoint: ' + error);
277 if (callback) 277 if (callback)
278 callback(); 278 callback();
279 } 279 }
280 } 280 }
281 281
282 /** 282 /**
283 * @param {!WebInspector.DebuggerModel.Location} startLocation 283 * @param {!SDK.DebuggerModel.Location} startLocation
284 * @param {!WebInspector.DebuggerModel.Location} endLocation 284 * @param {!SDK.DebuggerModel.Location} endLocation
285 * @return {!Promise<!Array<!WebInspector.DebuggerModel.Location>>} 285 * @return {!Promise<!Array<!SDK.DebuggerModel.Location>>}
286 */ 286 */
287 getPossibleBreakpoints(startLocation, endLocation) { 287 getPossibleBreakpoints(startLocation, endLocation) {
288 var fulfill; 288 var fulfill;
289 var promise = new Promise(resolve => fulfill = resolve); 289 var promise = new Promise(resolve => fulfill = resolve);
290 this._agent.getPossibleBreakpoints(startLocation.payload(), endLocation.payl oad(), checkErrorAndReturn.bind(this)); 290 this._agent.getPossibleBreakpoints(startLocation.payload(), endLocation.payl oad(), checkErrorAndReturn.bind(this));
291 return promise; 291 return promise;
292 292
293 /** 293 /**
294 * @this {!WebInspector.DebuggerModel} 294 * @this {!SDK.DebuggerModel}
295 * @param {?Protocol.Error} error 295 * @param {?Protocol.Error} error
296 * @param {?Array<!Protocol.Debugger.Location>} locations 296 * @param {?Array<!Protocol.Debugger.Location>} locations
297 */ 297 */
298 function checkErrorAndReturn(error, locations) { 298 function checkErrorAndReturn(error, locations) {
299 if (error || !locations) { 299 if (error || !locations) {
300 fulfill([]); 300 fulfill([]);
301 return; 301 return;
302 } 302 }
303 fulfill(locations.map(location => WebInspector.DebuggerModel.Location.from Payload(this, location))); 303 fulfill(locations.map(location => SDK.DebuggerModel.Location.fromPayload(t his, location)));
304 } 304 }
305 } 305 }
306 306
307 /** 307 /**
308 * @param {!Protocol.Debugger.BreakpointId} breakpointId 308 * @param {!Protocol.Debugger.BreakpointId} breakpointId
309 * @param {!Protocol.Debugger.Location} location 309 * @param {!Protocol.Debugger.Location} location
310 */ 310 */
311 _breakpointResolved(breakpointId, location) { 311 _breakpointResolved(breakpointId, location) {
312 this._breakpointResolvedEventTarget.dispatchEventToListeners( 312 this._breakpointResolvedEventTarget.dispatchEventToListeners(
313 breakpointId, WebInspector.DebuggerModel.Location.fromPayload(this, loca tion)); 313 breakpointId, SDK.DebuggerModel.Location.fromPayload(this, location));
314 } 314 }
315 315
316 globalObjectCleared() { 316 globalObjectCleared() {
317 this._setDebuggerPausedDetails(null); 317 this._setDebuggerPausedDetails(null);
318 this._reset(); 318 this._reset();
319 // TODO(dgozman): move clients to ExecutionContextDestroyed/ScriptCollected events. 319 // TODO(dgozman): move clients to ExecutionContextDestroyed/ScriptCollected events.
320 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.GlobalObject Cleared); 320 this.dispatchEventToListeners(SDK.DebuggerModel.Events.GlobalObjectCleared);
321 } 321 }
322 322
323 _reset() { 323 _reset() {
324 this._scripts = {}; 324 this._scripts = {};
325 this._scriptsBySourceURL.clear(); 325 this._scriptsBySourceURL.clear();
326 } 326 }
327 327
328 /** 328 /**
329 * @return {!Object.<string, !WebInspector.Script>} 329 * @return {!Object.<string, !SDK.Script>}
330 */ 330 */
331 get scripts() { 331 get scripts() {
332 return this._scripts; 332 return this._scripts;
333 } 333 }
334 334
335 /** 335 /**
336 * @param {!Protocol.Runtime.ScriptId} scriptId 336 * @param {!Protocol.Runtime.ScriptId} scriptId
337 * @return {?WebInspector.Script} 337 * @return {?SDK.Script}
338 */ 338 */
339 scriptForId(scriptId) { 339 scriptForId(scriptId) {
340 return this._scripts[scriptId] || null; 340 return this._scripts[scriptId] || null;
341 } 341 }
342 342
343 /** 343 /**
344 * @return {!Array.<!WebInspector.Script>} 344 * @return {!Array.<!SDK.Script>}
345 */ 345 */
346 scriptsForSourceURL(sourceURL) { 346 scriptsForSourceURL(sourceURL) {
347 if (!sourceURL) 347 if (!sourceURL)
348 return []; 348 return [];
349 return this._scriptsBySourceURL.get(sourceURL) || []; 349 return this._scriptsBySourceURL.get(sourceURL) || [];
350 } 350 }
351 351
352 /** 352 /**
353 * @param {!Protocol.Runtime.ScriptId} scriptId 353 * @param {!Protocol.Runtime.ScriptId} scriptId
354 * @param {string} newSource 354 * @param {string} newSource
(...skipping 29 matching lines...) Expand all
384 } 384 }
385 385
386 if (!error && callFrames && callFrames.length) 386 if (!error && callFrames && callFrames.length)
387 this._pausedScript( 387 this._pausedScript(
388 callFrames, this._debuggerPausedDetails.reason, this._debuggerPausedDe tails.auxData, 388 callFrames, this._debuggerPausedDetails.reason, this._debuggerPausedDe tails.auxData,
389 this._debuggerPausedDetails.breakpointIds, asyncStackTrace); 389 this._debuggerPausedDetails.breakpointIds, asyncStackTrace);
390 callback(error, exceptionDetails); 390 callback(error, exceptionDetails);
391 } 391 }
392 392
393 /** 393 /**
394 * @return {?Array.<!WebInspector.DebuggerModel.CallFrame>} 394 * @return {?Array.<!SDK.DebuggerModel.CallFrame>}
395 */ 395 */
396 get callFrames() { 396 get callFrames() {
397 return this._debuggerPausedDetails ? this._debuggerPausedDetails.callFrames : null; 397 return this._debuggerPausedDetails ? this._debuggerPausedDetails.callFrames : null;
398 } 398 }
399 399
400 /** 400 /**
401 * @return {?WebInspector.DebuggerPausedDetails} 401 * @return {?SDK.DebuggerPausedDetails}
402 */ 402 */
403 debuggerPausedDetails() { 403 debuggerPausedDetails() {
404 return this._debuggerPausedDetails; 404 return this._debuggerPausedDetails;
405 } 405 }
406 406
407 /** 407 /**
408 * @param {?WebInspector.DebuggerPausedDetails} debuggerPausedDetails 408 * @param {?SDK.DebuggerPausedDetails} debuggerPausedDetails
409 * @return {boolean} 409 * @return {boolean}
410 */ 410 */
411 _setDebuggerPausedDetails(debuggerPausedDetails) { 411 _setDebuggerPausedDetails(debuggerPausedDetails) {
412 this._isPausing = false; 412 this._isPausing = false;
413 this._debuggerPausedDetails = debuggerPausedDetails; 413 this._debuggerPausedDetails = debuggerPausedDetails;
414 if (this._debuggerPausedDetails) { 414 if (this._debuggerPausedDetails) {
415 if (Runtime.experiments.isEnabled('emptySourceMapAutoStepping')) { 415 if (Runtime.experiments.isEnabled('emptySourceMapAutoStepping')) {
416 if (this.dispatchEventToListeners( 416 if (this.dispatchEventToListeners(
417 WebInspector.DebuggerModel.Events.BeforeDebuggerPaused, this._de buggerPausedDetails)) { 417 SDK.DebuggerModel.Events.BeforeDebuggerPaused, this._debuggerPau sedDetails)) {
418 return false; 418 return false;
419 } 419 }
420 } 420 }
421 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.DebuggerPa used, this._debuggerPausedDetails); 421 this.dispatchEventToListeners(SDK.DebuggerModel.Events.DebuggerPaused, thi s._debuggerPausedDetails);
422 } 422 }
423 if (debuggerPausedDetails) 423 if (debuggerPausedDetails)
424 this.setSelectedCallFrame(debuggerPausedDetails.callFrames[0]); 424 this.setSelectedCallFrame(debuggerPausedDetails.callFrames[0]);
425 else 425 else
426 this.setSelectedCallFrame(null); 426 this.setSelectedCallFrame(null);
427 return true; 427 return true;
428 } 428 }
429 429
430 /** 430 /**
431 * @param {!Array.<!Protocol.Debugger.CallFrame>} callFrames 431 * @param {!Array.<!Protocol.Debugger.CallFrame>} callFrames
432 * @param {string} reason 432 * @param {string} reason
433 * @param {!Object|undefined} auxData 433 * @param {!Object|undefined} auxData
434 * @param {!Array.<string>} breakpointIds 434 * @param {!Array.<string>} breakpointIds
435 * @param {!Protocol.Runtime.StackTrace=} asyncStackTrace 435 * @param {!Protocol.Runtime.StackTrace=} asyncStackTrace
436 */ 436 */
437 _pausedScript(callFrames, reason, auxData, breakpointIds, asyncStackTrace) { 437 _pausedScript(callFrames, reason, auxData, breakpointIds, asyncStackTrace) {
438 var pausedDetails = 438 var pausedDetails =
439 new WebInspector.DebuggerPausedDetails(this, callFrames, reason, auxData , breakpointIds, asyncStackTrace); 439 new SDK.DebuggerPausedDetails(this, callFrames, reason, auxData, breakpo intIds, asyncStackTrace);
440 if (this._setDebuggerPausedDetails(pausedDetails)) { 440 if (this._setDebuggerPausedDetails(pausedDetails)) {
441 if (this._pendingLiveEditCallback) { 441 if (this._pendingLiveEditCallback) {
442 var callback = this._pendingLiveEditCallback; 442 var callback = this._pendingLiveEditCallback;
443 delete this._pendingLiveEditCallback; 443 delete this._pendingLiveEditCallback;
444 callback(); 444 callback();
445 } 445 }
446 } else { 446 } else {
447 this._agent.stepInto(); 447 this._agent.stepInto();
448 } 448 }
449 } 449 }
450 450
451 _resumedScript() { 451 _resumedScript() {
452 this._setDebuggerPausedDetails(null); 452 this._setDebuggerPausedDetails(null);
453 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.DebuggerResu med); 453 this.dispatchEventToListeners(SDK.DebuggerModel.Events.DebuggerResumed);
454 } 454 }
455 455
456 /** 456 /**
457 * @param {!Protocol.Runtime.ScriptId} scriptId 457 * @param {!Protocol.Runtime.ScriptId} scriptId
458 * @param {string} sourceURL 458 * @param {string} sourceURL
459 * @param {number} startLine 459 * @param {number} startLine
460 * @param {number} startColumn 460 * @param {number} startColumn
461 * @param {number} endLine 461 * @param {number} endLine
462 * @param {number} endColumn 462 * @param {number} endColumn
463 * @param {!Protocol.Runtime.ExecutionContextId} executionContextId 463 * @param {!Protocol.Runtime.ExecutionContextId} executionContextId
464 * @param {string} hash 464 * @param {string} hash
465 * @param {*|undefined} executionContextAuxData 465 * @param {*|undefined} executionContextAuxData
466 * @param {boolean} isLiveEdit 466 * @param {boolean} isLiveEdit
467 * @param {string=} sourceMapURL 467 * @param {string=} sourceMapURL
468 * @param {boolean=} hasSourceURL 468 * @param {boolean=} hasSourceURL
469 * @param {boolean=} hasSyntaxError 469 * @param {boolean=} hasSyntaxError
470 * @return {!WebInspector.Script} 470 * @return {!SDK.Script}
471 */ 471 */
472 _parsedScriptSource( 472 _parsedScriptSource(
473 scriptId, 473 scriptId,
474 sourceURL, 474 sourceURL,
475 startLine, 475 startLine,
476 startColumn, 476 startColumn,
477 endLine, 477 endLine,
478 endColumn, 478 endColumn,
479 executionContextId, 479 executionContextId,
480 hash, 480 hash,
481 executionContextAuxData, 481 executionContextAuxData,
482 isLiveEdit, 482 isLiveEdit,
483 sourceMapURL, 483 sourceMapURL,
484 hasSourceURL, 484 hasSourceURL,
485 hasSyntaxError) { 485 hasSyntaxError) {
486 var isContentScript = false; 486 var isContentScript = false;
487 if (executionContextAuxData && ('isDefault' in executionContextAuxData)) 487 if (executionContextAuxData && ('isDefault' in executionContextAuxData))
488 isContentScript = !executionContextAuxData['isDefault']; 488 isContentScript = !executionContextAuxData['isDefault'];
489 // Support file URL for node.js. 489 // Support file URL for node.js.
490 if (this.target().isNodeJS() && sourceURL && sourceURL.startsWith('/')) { 490 if (this.target().isNodeJS() && sourceURL && sourceURL.startsWith('/')) {
491 var nodeJSPath = sourceURL; 491 var nodeJSPath = sourceURL;
492 sourceURL = WebInspector.ParsedURL.platformPathToURL(nodeJSPath); 492 sourceURL = Common.ParsedURL.platformPathToURL(nodeJSPath);
493 this._fileURLToNodeJSPath.set(sourceURL, nodeJSPath); 493 this._fileURLToNodeJSPath.set(sourceURL, nodeJSPath);
494 } 494 }
495 var script = new WebInspector.Script( 495 var script = new SDK.Script(
496 this, scriptId, sourceURL, startLine, startColumn, endLine, endColumn, e xecutionContextId, hash, 496 this, scriptId, sourceURL, startLine, startColumn, endLine, endColumn, e xecutionContextId, hash,
497 isContentScript, isLiveEdit, sourceMapURL, hasSourceURL); 497 isContentScript, isLiveEdit, sourceMapURL, hasSourceURL);
498 this._registerScript(script); 498 this._registerScript(script);
499 if (!hasSyntaxError) 499 if (!hasSyntaxError)
500 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.ParsedScri ptSource, script); 500 this.dispatchEventToListeners(SDK.DebuggerModel.Events.ParsedScriptSource, script);
501 else 501 else
502 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.FailedToPa rseScriptSource, script); 502 this.dispatchEventToListeners(SDK.DebuggerModel.Events.FailedToParseScript Source, script);
503 return script; 503 return script;
504 } 504 }
505 505
506 /** 506 /**
507 * @param {!WebInspector.Script} script 507 * @param {!SDK.Script} script
508 */ 508 */
509 _registerScript(script) { 509 _registerScript(script) {
510 this._scripts[script.scriptId] = script; 510 this._scripts[script.scriptId] = script;
511 if (script.isAnonymousScript()) 511 if (script.isAnonymousScript())
512 return; 512 return;
513 513
514 var scripts = this._scriptsBySourceURL.get(script.sourceURL); 514 var scripts = this._scriptsBySourceURL.get(script.sourceURL);
515 if (!scripts) { 515 if (!scripts) {
516 scripts = []; 516 scripts = [];
517 this._scriptsBySourceURL.set(script.sourceURL, scripts); 517 this._scriptsBySourceURL.set(script.sourceURL, scripts);
518 } 518 }
519 scripts.push(script); 519 scripts.push(script);
520 } 520 }
521 521
522 /** 522 /**
523 * @param {!WebInspector.Script} script 523 * @param {!SDK.Script} script
524 * @param {number} lineNumber 524 * @param {number} lineNumber
525 * @param {number} columnNumber 525 * @param {number} columnNumber
526 * @return {?WebInspector.DebuggerModel.Location} 526 * @return {?SDK.DebuggerModel.Location}
527 */ 527 */
528 createRawLocation(script, lineNumber, columnNumber) { 528 createRawLocation(script, lineNumber, columnNumber) {
529 if (script.sourceURL) 529 if (script.sourceURL)
530 return this.createRawLocationByURL(script.sourceURL, lineNumber, columnNum ber); 530 return this.createRawLocationByURL(script.sourceURL, lineNumber, columnNum ber);
531 return new WebInspector.DebuggerModel.Location(this, script.scriptId, lineNu mber, columnNumber); 531 return new SDK.DebuggerModel.Location(this, script.scriptId, lineNumber, col umnNumber);
532 } 532 }
533 533
534 /** 534 /**
535 * @param {string} sourceURL 535 * @param {string} sourceURL
536 * @param {number} lineNumber 536 * @param {number} lineNumber
537 * @param {number} columnNumber 537 * @param {number} columnNumber
538 * @return {?WebInspector.DebuggerModel.Location} 538 * @return {?SDK.DebuggerModel.Location}
539 */ 539 */
540 createRawLocationByURL(sourceURL, lineNumber, columnNumber) { 540 createRawLocationByURL(sourceURL, lineNumber, columnNumber) {
541 var closestScript = null; 541 var closestScript = null;
542 var scripts = this._scriptsBySourceURL.get(sourceURL) || []; 542 var scripts = this._scriptsBySourceURL.get(sourceURL) || [];
543 for (var i = 0, l = scripts.length; i < l; ++i) { 543 for (var i = 0, l = scripts.length; i < l; ++i) {
544 var script = scripts[i]; 544 var script = scripts[i];
545 if (!closestScript) 545 if (!closestScript)
546 closestScript = script; 546 closestScript = script;
547 if (script.lineOffset > lineNumber || (script.lineOffset === lineNumber && script.columnOffset > columnNumber)) 547 if (script.lineOffset > lineNumber || (script.lineOffset === lineNumber && script.columnOffset > columnNumber))
548 continue; 548 continue;
549 if (script.endLine < lineNumber || (script.endLine === lineNumber && scrip t.endColumn <= columnNumber)) 549 if (script.endLine < lineNumber || (script.endLine === lineNumber && scrip t.endColumn <= columnNumber))
550 continue; 550 continue;
551 closestScript = script; 551 closestScript = script;
552 break; 552 break;
553 } 553 }
554 return closestScript ? 554 return closestScript ?
555 new WebInspector.DebuggerModel.Location(this, closestScript.scriptId, li neNumber, columnNumber) : 555 new SDK.DebuggerModel.Location(this, closestScript.scriptId, lineNumber, columnNumber) :
556 null; 556 null;
557 } 557 }
558 558
559 /** 559 /**
560 * @param {!Protocol.Runtime.ScriptId} scriptId 560 * @param {!Protocol.Runtime.ScriptId} scriptId
561 * @param {number} lineNumber 561 * @param {number} lineNumber
562 * @param {number} columnNumber 562 * @param {number} columnNumber
563 * @return {?WebInspector.DebuggerModel.Location} 563 * @return {?SDK.DebuggerModel.Location}
564 */ 564 */
565 createRawLocationByScriptId(scriptId, lineNumber, columnNumber) { 565 createRawLocationByScriptId(scriptId, lineNumber, columnNumber) {
566 var script = this.scriptForId(scriptId); 566 var script = this.scriptForId(scriptId);
567 return script ? this.createRawLocation(script, lineNumber, columnNumber) : n ull; 567 return script ? this.createRawLocation(script, lineNumber, columnNumber) : n ull;
568 } 568 }
569 569
570 /** 570 /**
571 * @param {!Protocol.Runtime.StackTrace} stackTrace 571 * @param {!Protocol.Runtime.StackTrace} stackTrace
572 * @return {!Array<!WebInspector.DebuggerModel.Location>} 572 * @return {!Array<!SDK.DebuggerModel.Location>}
573 */ 573 */
574 createRawLocationsByStackTrace(stackTrace) { 574 createRawLocationsByStackTrace(stackTrace) {
575 var frames = []; 575 var frames = [];
576 while (stackTrace) { 576 while (stackTrace) {
577 for (var frame of stackTrace.callFrames) 577 for (var frame of stackTrace.callFrames)
578 frames.push(frame); 578 frames.push(frame);
579 stackTrace = stackTrace.parent; 579 stackTrace = stackTrace.parent;
580 } 580 }
581 581
582 var rawLocations = []; 582 var rawLocations = [];
(...skipping 13 matching lines...) Expand all
596 } 596 }
597 597
598 /** 598 /**
599 * @return {boolean} 599 * @return {boolean}
600 */ 600 */
601 isPausing() { 601 isPausing() {
602 return this._isPausing; 602 return this._isPausing;
603 } 603 }
604 604
605 /** 605 /**
606 * @param {?WebInspector.DebuggerModel.CallFrame} callFrame 606 * @param {?SDK.DebuggerModel.CallFrame} callFrame
607 */ 607 */
608 setSelectedCallFrame(callFrame) { 608 setSelectedCallFrame(callFrame) {
609 this._selectedCallFrame = callFrame; 609 this._selectedCallFrame = callFrame;
610 if (!this._selectedCallFrame) 610 if (!this._selectedCallFrame)
611 return; 611 return;
612 612
613 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.CallFrameSel ected, callFrame); 613 this.dispatchEventToListeners(SDK.DebuggerModel.Events.CallFrameSelected, ca llFrame);
614 } 614 }
615 615
616 /** 616 /**
617 * @return {?WebInspector.DebuggerModel.CallFrame} 617 * @return {?SDK.DebuggerModel.CallFrame}
618 */ 618 */
619 selectedCallFrame() { 619 selectedCallFrame() {
620 return this._selectedCallFrame; 620 return this._selectedCallFrame;
621 } 621 }
622 622
623 /** 623 /**
624 * @param {string} code 624 * @param {string} code
625 * @param {string} objectGroup 625 * @param {string} objectGroup
626 * @param {boolean} includeCommandLineAPI 626 * @param {boolean} includeCommandLineAPI
627 * @param {boolean} silent 627 * @param {boolean} silent
628 * @param {boolean} returnByValue 628 * @param {boolean} returnByValue
629 * @param {boolean} generatePreview 629 * @param {boolean} generatePreview
630 * @param {function(?WebInspector.RemoteObject, !Protocol.Runtime.ExceptionDet ails=)} callback 630 * @param {function(?SDK.RemoteObject, !Protocol.Runtime.ExceptionDetails=)} c allback
631 */ 631 */
632 evaluateOnSelectedCallFrame( 632 evaluateOnSelectedCallFrame(
633 code, 633 code,
634 objectGroup, 634 objectGroup,
635 includeCommandLineAPI, 635 includeCommandLineAPI,
636 silent, 636 silent,
637 returnByValue, 637 returnByValue,
638 generatePreview, 638 generatePreview,
639 callback) { 639 callback) {
640 /** 640 /**
641 * @param {?Protocol.Runtime.RemoteObject} result 641 * @param {?Protocol.Runtime.RemoteObject} result
642 * @param {!Protocol.Runtime.ExceptionDetails=} exceptionDetails 642 * @param {!Protocol.Runtime.ExceptionDetails=} exceptionDetails
643 * @this {WebInspector.DebuggerModel} 643 * @this {SDK.DebuggerModel}
644 */ 644 */
645 function didEvaluate(result, exceptionDetails) { 645 function didEvaluate(result, exceptionDetails) {
646 if (!result) 646 if (!result)
647 callback(null); 647 callback(null);
648 else 648 else
649 callback(this.target().runtimeModel.createRemoteObject(result), exceptio nDetails); 649 callback(this.target().runtimeModel.createRemoteObject(result), exceptio nDetails);
650 } 650 }
651 651
652 this.selectedCallFrame().evaluate( 652 this.selectedCallFrame().evaluate(
653 code, objectGroup, includeCommandLineAPI, silent, returnByValue, generat ePreview, didEvaluate.bind(this)); 653 code, objectGroup, includeCommandLineAPI, silent, returnByValue, generat ePreview, didEvaluate.bind(this));
654 } 654 }
655 655
656 /** 656 /**
657 * @param {!WebInspector.RemoteObject} remoteObject 657 * @param {!SDK.RemoteObject} remoteObject
658 * @return {!Promise<?WebInspector.DebuggerModel.FunctionDetails>} 658 * @return {!Promise<?SDK.DebuggerModel.FunctionDetails>}
659 */ 659 */
660 functionDetailsPromise(remoteObject) { 660 functionDetailsPromise(remoteObject) {
661 return remoteObject.getAllPropertiesPromise(/* accessorPropertiesOnly */ fal se).then(buildDetails.bind(this)); 661 return remoteObject.getAllPropertiesPromise(/* accessorPropertiesOnly */ fal se).then(buildDetails.bind(this));
662 662
663 /** 663 /**
664 * @param {!{properties: ?Array.<!WebInspector.RemoteObjectProperty>, intern alProperties: ?Array.<!WebInspector.RemoteObjectProperty>}} response 664 * @param {!{properties: ?Array.<!SDK.RemoteObjectProperty>, internalPropert ies: ?Array.<!SDK.RemoteObjectProperty>}} response
665 * @return {?WebInspector.DebuggerModel.FunctionDetails} 665 * @return {?SDK.DebuggerModel.FunctionDetails}
666 * @this {!WebInspector.DebuggerModel} 666 * @this {!SDK.DebuggerModel}
667 */ 667 */
668 function buildDetails(response) { 668 function buildDetails(response) {
669 if (!response) 669 if (!response)
670 return null; 670 return null;
671 var location = null; 671 var location = null;
672 if (response.internalProperties) { 672 if (response.internalProperties) {
673 for (var prop of response.internalProperties) { 673 for (var prop of response.internalProperties) {
674 if (prop.name === '[[FunctionLocation]]') 674 if (prop.name === '[[FunctionLocation]]')
675 location = prop.value; 675 location = prop.value;
676 } 676 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 callback(error); 714 callback(error);
715 return; 715 return;
716 } 716 }
717 if (callback) 717 if (callback)
718 callback(); 718 callback();
719 } 719 }
720 } 720 }
721 721
722 /** 722 /**
723 * @param {!Protocol.Debugger.BreakpointId} breakpointId 723 * @param {!Protocol.Debugger.BreakpointId} breakpointId
724 * @param {function(!WebInspector.Event)} listener 724 * @param {function(!Common.Event)} listener
725 * @param {!Object=} thisObject 725 * @param {!Object=} thisObject
726 */ 726 */
727 addBreakpointListener(breakpointId, listener, thisObject) { 727 addBreakpointListener(breakpointId, listener, thisObject) {
728 this._breakpointResolvedEventTarget.addEventListener(breakpointId, listener, thisObject); 728 this._breakpointResolvedEventTarget.addEventListener(breakpointId, listener, thisObject);
729 } 729 }
730 730
731 /** 731 /**
732 * @param {!Protocol.Debugger.BreakpointId} breakpointId 732 * @param {!Protocol.Debugger.BreakpointId} breakpointId
733 * @param {function(!WebInspector.Event)} listener 733 * @param {function(!Common.Event)} listener
734 * @param {!Object=} thisObject 734 * @param {!Object=} thisObject
735 */ 735 */
736 removeBreakpointListener(breakpointId, listener, thisObject) { 736 removeBreakpointListener(breakpointId, listener, thisObject) {
737 this._breakpointResolvedEventTarget.removeEventListener(breakpointId, listen er, thisObject); 737 this._breakpointResolvedEventTarget.removeEventListener(breakpointId, listen er, thisObject);
738 } 738 }
739 739
740 /** 740 /**
741 * @param {!Array<string>} patterns 741 * @param {!Array<string>} patterns
742 * @return {!Promise<boolean>} 742 * @return {!Promise<boolean>}
743 */ 743 */
(...skipping 10 matching lines...) Expand all
754 if (error) 754 if (error)
755 console.error(error); 755 console.error(error);
756 callback(!error); 756 callback(!error);
757 } 757 }
758 } 758 }
759 759
760 /** 760 /**
761 * @override 761 * @override
762 */ 762 */
763 dispose() { 763 dispose() {
764 WebInspector.moduleSetting('pauseOnExceptionEnabled') 764 Common.moduleSetting('pauseOnExceptionEnabled')
765 .removeChangeListener(this._pauseOnExceptionStateChanged, this); 765 .removeChangeListener(this._pauseOnExceptionStateChanged, this);
766 WebInspector.moduleSetting('pauseOnCaughtException').removeChangeListener(th is._pauseOnExceptionStateChanged, this); 766 Common.moduleSetting('pauseOnCaughtException').removeChangeListener(this._pa useOnExceptionStateChanged, this);
767 WebInspector.moduleSetting('enableAsyncStackTraces').removeChangeListener(th is.asyncStackTracesStateChanged, this); 767 Common.moduleSetting('enableAsyncStackTraces').removeChangeListener(this.asy ncStackTracesStateChanged, this);
768 } 768 }
769 769
770 /** 770 /**
771 * @override 771 * @override
772 * @return {!Promise} 772 * @return {!Promise}
773 */ 773 */
774 suspendModel() { 774 suspendModel() {
775 return new Promise(promiseBody.bind(this)); 775 return new Promise(promiseBody.bind(this));
776 776
777 /** 777 /**
778 * @param {function()} fulfill 778 * @param {function()} fulfill
779 * @this {WebInspector.DebuggerModel} 779 * @this {SDK.DebuggerModel}
780 */ 780 */
781 function promiseBody(fulfill) { 781 function promiseBody(fulfill) {
782 this.disableDebugger(fulfill); 782 this.disableDebugger(fulfill);
783 } 783 }
784 } 784 }
785 785
786 /** 786 /**
787 * @override 787 * @override
788 * @return {!Promise} 788 * @return {!Promise}
789 */ 789 */
790 resumeModel() { 790 resumeModel() {
791 return new Promise(promiseBody.bind(this)); 791 return new Promise(promiseBody.bind(this));
792 792
793 /** 793 /**
794 * @param {function()} fulfill 794 * @param {function()} fulfill
795 * @this {WebInspector.DebuggerModel} 795 * @this {SDK.DebuggerModel}
796 */ 796 */
797 function promiseBody(fulfill) { 797 function promiseBody(fulfill) {
798 this.enableDebugger(fulfill); 798 this.enableDebugger(fulfill);
799 } 799 }
800 } 800 }
801 }; 801 };
802 802
803 /** @typedef {{location: ?WebInspector.DebuggerModel.Location, functionName: str ing}} */ 803 /** @typedef {{location: ?SDK.DebuggerModel.Location, functionName: string}} */
804 WebInspector.DebuggerModel.FunctionDetails; 804 SDK.DebuggerModel.FunctionDetails;
805 805
806 /** 806 /**
807 * Keep these in sync with WebCore::V8Debugger 807 * Keep these in sync with WebCore::V8Debugger
808 * 808 *
809 * @enum {string} 809 * @enum {string}
810 */ 810 */
811 WebInspector.DebuggerModel.PauseOnExceptionsState = { 811 SDK.DebuggerModel.PauseOnExceptionsState = {
812 DontPauseOnExceptions: 'none', 812 DontPauseOnExceptions: 'none',
813 PauseOnAllExceptions: 'all', 813 PauseOnAllExceptions: 'all',
814 PauseOnUncaughtExceptions: 'uncaught' 814 PauseOnUncaughtExceptions: 'uncaught'
815 }; 815 };
816 816
817 /** @enum {symbol} */ 817 /** @enum {symbol} */
818 WebInspector.DebuggerModel.Events = { 818 SDK.DebuggerModel.Events = {
819 DebuggerWasEnabled: Symbol('DebuggerWasEnabled'), 819 DebuggerWasEnabled: Symbol('DebuggerWasEnabled'),
820 DebuggerWasDisabled: Symbol('DebuggerWasDisabled'), 820 DebuggerWasDisabled: Symbol('DebuggerWasDisabled'),
821 BeforeDebuggerPaused: Symbol('BeforeDebuggerPaused'), 821 BeforeDebuggerPaused: Symbol('BeforeDebuggerPaused'),
822 DebuggerPaused: Symbol('DebuggerPaused'), 822 DebuggerPaused: Symbol('DebuggerPaused'),
823 DebuggerResumed: Symbol('DebuggerResumed'), 823 DebuggerResumed: Symbol('DebuggerResumed'),
824 ParsedScriptSource: Symbol('ParsedScriptSource'), 824 ParsedScriptSource: Symbol('ParsedScriptSource'),
825 FailedToParseScriptSource: Symbol('FailedToParseScriptSource'), 825 FailedToParseScriptSource: Symbol('FailedToParseScriptSource'),
826 GlobalObjectCleared: Symbol('GlobalObjectCleared'), 826 GlobalObjectCleared: Symbol('GlobalObjectCleared'),
827 CallFrameSelected: Symbol('CallFrameSelected'), 827 CallFrameSelected: Symbol('CallFrameSelected'),
828 ConsoleCommandEvaluatedInSelectedCallFrame: Symbol('ConsoleCommandEvaluatedInS electedCallFrame') 828 ConsoleCommandEvaluatedInSelectedCallFrame: Symbol('ConsoleCommandEvaluatedInS electedCallFrame')
829 }; 829 };
830 830
831 /** @enum {string} */ 831 /** @enum {string} */
832 WebInspector.DebuggerModel.BreakReason = { 832 SDK.DebuggerModel.BreakReason = {
833 DOM: 'DOM', 833 DOM: 'DOM',
834 EventListener: 'EventListener', 834 EventListener: 'EventListener',
835 XHR: 'XHR', 835 XHR: 'XHR',
836 Exception: 'exception', 836 Exception: 'exception',
837 PromiseRejection: 'promiseRejection', 837 PromiseRejection: 'promiseRejection',
838 Assert: 'assert', 838 Assert: 'assert',
839 DebugCommand: 'debugCommand', 839 DebugCommand: 'debugCommand',
840 Other: 'other' 840 Other: 'other'
841 }; 841 };
842 842
843 WebInspector.DebuggerEventTypes = { 843 SDK.DebuggerEventTypes = {
844 JavaScriptPause: 0, 844 JavaScriptPause: 0,
845 JavaScriptBreakpoint: 1, 845 JavaScriptBreakpoint: 1,
846 NativeBreakpoint: 2 846 NativeBreakpoint: 2
847 }; 847 };
848 848
849 /** 849 /**
850 * @implements {Protocol.DebuggerDispatcher} 850 * @implements {Protocol.DebuggerDispatcher}
851 * @unrestricted 851 * @unrestricted
852 */ 852 */
853 WebInspector.DebuggerDispatcher = class { 853 SDK.DebuggerDispatcher = class {
854 /** 854 /**
855 * @param {!WebInspector.DebuggerModel} debuggerModel 855 * @param {!SDK.DebuggerModel} debuggerModel
856 */ 856 */
857 constructor(debuggerModel) { 857 constructor(debuggerModel) {
858 this._debuggerModel = debuggerModel; 858 this._debuggerModel = debuggerModel;
859 } 859 }
860 860
861 /** 861 /**
862 * @override 862 * @override
863 * @param {!Array.<!Protocol.Debugger.CallFrame>} callFrames 863 * @param {!Array.<!Protocol.Debugger.CallFrame>} callFrames
864 * @param {string} reason 864 * @param {string} reason
865 * @param {!Object=} auxData 865 * @param {!Object=} auxData
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 * @param {!Protocol.Debugger.Location} location 947 * @param {!Protocol.Debugger.Location} location
948 */ 948 */
949 breakpointResolved(breakpointId, location) { 949 breakpointResolved(breakpointId, location) {
950 this._debuggerModel._breakpointResolved(breakpointId, location); 950 this._debuggerModel._breakpointResolved(breakpointId, location);
951 } 951 }
952 }; 952 };
953 953
954 /** 954 /**
955 * @unrestricted 955 * @unrestricted
956 */ 956 */
957 WebInspector.DebuggerModel.Location = class extends WebInspector.SDKObject { 957 SDK.DebuggerModel.Location = class extends SDK.SDKObject {
958 /** 958 /**
959 * @param {!WebInspector.DebuggerModel} debuggerModel 959 * @param {!SDK.DebuggerModel} debuggerModel
960 * @param {string} scriptId 960 * @param {string} scriptId
961 * @param {number} lineNumber 961 * @param {number} lineNumber
962 * @param {number=} columnNumber 962 * @param {number=} columnNumber
963 */ 963 */
964 constructor(debuggerModel, scriptId, lineNumber, columnNumber) { 964 constructor(debuggerModel, scriptId, lineNumber, columnNumber) {
965 super(debuggerModel.target()); 965 super(debuggerModel.target());
966 this._debuggerModel = debuggerModel; 966 this._debuggerModel = debuggerModel;
967 this.scriptId = scriptId; 967 this.scriptId = scriptId;
968 this.lineNumber = lineNumber; 968 this.lineNumber = lineNumber;
969 this.columnNumber = columnNumber || 0; 969 this.columnNumber = columnNumber || 0;
970 } 970 }
971 971
972 /** 972 /**
973 * @param {!WebInspector.DebuggerModel} debuggerModel 973 * @param {!SDK.DebuggerModel} debuggerModel
974 * @param {!Protocol.Debugger.Location} payload 974 * @param {!Protocol.Debugger.Location} payload
975 * @return {!WebInspector.DebuggerModel.Location} 975 * @return {!SDK.DebuggerModel.Location}
976 */ 976 */
977 static fromPayload(debuggerModel, payload) { 977 static fromPayload(debuggerModel, payload) {
978 return new WebInspector.DebuggerModel.Location( 978 return new SDK.DebuggerModel.Location(
979 debuggerModel, payload.scriptId, payload.lineNumber, payload.columnNumbe r); 979 debuggerModel, payload.scriptId, payload.lineNumber, payload.columnNumbe r);
980 } 980 }
981 981
982 /** 982 /**
983 * @return {!Protocol.Debugger.Location} 983 * @return {!Protocol.Debugger.Location}
984 */ 984 */
985 payload() { 985 payload() {
986 return {scriptId: this.scriptId, lineNumber: this.lineNumber, columnNumber: this.columnNumber}; 986 return {scriptId: this.scriptId, lineNumber: this.lineNumber, columnNumber: this.columnNumber};
987 } 987 }
988 988
989 /** 989 /**
990 * @return {?WebInspector.Script} 990 * @return {?SDK.Script}
991 */ 991 */
992 script() { 992 script() {
993 return this._debuggerModel.scriptForId(this.scriptId); 993 return this._debuggerModel.scriptForId(this.scriptId);
994 } 994 }
995 995
996 continueToLocation() { 996 continueToLocation() {
997 this._debuggerModel._agent.continueToLocation(this.payload()); 997 this._debuggerModel._agent.continueToLocation(this.payload());
998 } 998 }
999 999
1000 /** 1000 /**
1001 * @return {string} 1001 * @return {string}
1002 */ 1002 */
1003 id() { 1003 id() {
1004 return this.target().id() + ':' + this.scriptId + ':' + this.lineNumber + ': ' + this.columnNumber; 1004 return this.target().id() + ':' + this.scriptId + ':' + this.lineNumber + ': ' + this.columnNumber;
1005 } 1005 }
1006 }; 1006 };
1007 1007
1008 1008
1009 /** 1009 /**
1010 * @unrestricted 1010 * @unrestricted
1011 */ 1011 */
1012 WebInspector.DebuggerModel.CallFrame = class extends WebInspector.SDKObject { 1012 SDK.DebuggerModel.CallFrame = class extends SDK.SDKObject {
1013 /** 1013 /**
1014 * @param {!WebInspector.DebuggerModel} debuggerModel 1014 * @param {!SDK.DebuggerModel} debuggerModel
1015 * @param {!WebInspector.Script} script 1015 * @param {!SDK.Script} script
1016 * @param {!Protocol.Debugger.CallFrame} payload 1016 * @param {!Protocol.Debugger.CallFrame} payload
1017 */ 1017 */
1018 constructor(debuggerModel, script, payload) { 1018 constructor(debuggerModel, script, payload) {
1019 var target = debuggerModel.target(); 1019 var target = debuggerModel.target();
1020 super(target); 1020 super(target);
1021 this.debuggerModel = debuggerModel; 1021 this.debuggerModel = debuggerModel;
1022 this._debuggerAgent = debuggerModel._agent; 1022 this._debuggerAgent = debuggerModel._agent;
1023 this._script = script; 1023 this._script = script;
1024 this._payload = payload; 1024 this._payload = payload;
1025 this._location = WebInspector.DebuggerModel.Location.fromPayload(debuggerMod el, payload.location); 1025 this._location = SDK.DebuggerModel.Location.fromPayload(debuggerModel, paylo ad.location);
1026 this._scopeChain = []; 1026 this._scopeChain = [];
1027 this._localScope = null; 1027 this._localScope = null;
1028 for (var i = 0; i < payload.scopeChain.length; ++i) { 1028 for (var i = 0; i < payload.scopeChain.length; ++i) {
1029 var scope = new WebInspector.DebuggerModel.Scope(this, i); 1029 var scope = new SDK.DebuggerModel.Scope(this, i);
1030 this._scopeChain.push(scope); 1030 this._scopeChain.push(scope);
1031 if (scope.type() === Protocol.Debugger.ScopeType.Local) 1031 if (scope.type() === Protocol.Debugger.ScopeType.Local)
1032 this._localScope = scope; 1032 this._localScope = scope;
1033 } 1033 }
1034 if (payload.functionLocation) 1034 if (payload.functionLocation)
1035 this._functionLocation = WebInspector.DebuggerModel.Location.fromPayload(d ebuggerModel, payload.functionLocation); 1035 this._functionLocation = SDK.DebuggerModel.Location.fromPayload(debuggerMo del, payload.functionLocation);
1036 } 1036 }
1037 1037
1038 /** 1038 /**
1039 * @param {!WebInspector.DebuggerModel} debuggerModel 1039 * @param {!SDK.DebuggerModel} debuggerModel
1040 * @param {!Array.<!Protocol.Debugger.CallFrame>} callFrames 1040 * @param {!Array.<!Protocol.Debugger.CallFrame>} callFrames
1041 * @return {!Array.<!WebInspector.DebuggerModel.CallFrame>} 1041 * @return {!Array.<!SDK.DebuggerModel.CallFrame>}
1042 */ 1042 */
1043 static fromPayloadArray(debuggerModel, callFrames) { 1043 static fromPayloadArray(debuggerModel, callFrames) {
1044 var result = []; 1044 var result = [];
1045 for (var i = 0; i < callFrames.length; ++i) { 1045 for (var i = 0; i < callFrames.length; ++i) {
1046 var callFrame = callFrames[i]; 1046 var callFrame = callFrames[i];
1047 var script = debuggerModel.scriptForId(callFrame.location.scriptId); 1047 var script = debuggerModel.scriptForId(callFrame.location.scriptId);
1048 if (script) 1048 if (script)
1049 result.push(new WebInspector.DebuggerModel.CallFrame(debuggerModel, scri pt, callFrame)); 1049 result.push(new SDK.DebuggerModel.CallFrame(debuggerModel, script, callF rame));
1050 } 1050 }
1051 return result; 1051 return result;
1052 } 1052 }
1053 1053
1054 /** 1054 /**
1055 * @return {!WebInspector.Script} 1055 * @return {!SDK.Script}
1056 */ 1056 */
1057 get script() { 1057 get script() {
1058 return this._script; 1058 return this._script;
1059 } 1059 }
1060 1060
1061 /** 1061 /**
1062 * @return {string} 1062 * @return {string}
1063 */ 1063 */
1064 get id() { 1064 get id() {
1065 return this._payload.callFrameId; 1065 return this._payload.callFrameId;
1066 } 1066 }
1067 1067
1068 /** 1068 /**
1069 * @return {!Array.<!WebInspector.DebuggerModel.Scope>} 1069 * @return {!Array.<!SDK.DebuggerModel.Scope>}
1070 */ 1070 */
1071 scopeChain() { 1071 scopeChain() {
1072 return this._scopeChain; 1072 return this._scopeChain;
1073 } 1073 }
1074 1074
1075 /** 1075 /**
1076 * @return {?WebInspector.DebuggerModel.Scope} 1076 * @return {?SDK.DebuggerModel.Scope}
1077 */ 1077 */
1078 localScope() { 1078 localScope() {
1079 return this._localScope; 1079 return this._localScope;
1080 } 1080 }
1081 1081
1082 /** 1082 /**
1083 * @return {?WebInspector.RemoteObject} 1083 * @return {?SDK.RemoteObject}
1084 */ 1084 */
1085 thisObject() { 1085 thisObject() {
1086 return this._payload.this ? this.target().runtimeModel.createRemoteObject(th is._payload.this) : null; 1086 return this._payload.this ? this.target().runtimeModel.createRemoteObject(th is._payload.this) : null;
1087 } 1087 }
1088 1088
1089 /** 1089 /**
1090 * @return {?WebInspector.RemoteObject} 1090 * @return {?SDK.RemoteObject}
1091 */ 1091 */
1092 returnValue() { 1092 returnValue() {
1093 return this._payload.returnValue ? this.target().runtimeModel.createRemoteOb ject(this._payload.returnValue) : null; 1093 return this._payload.returnValue ? this.target().runtimeModel.createRemoteOb ject(this._payload.returnValue) : null;
1094 } 1094 }
1095 1095
1096 /** 1096 /**
1097 * @return {string} 1097 * @return {string}
1098 */ 1098 */
1099 get functionName() { 1099 get functionName() {
1100 return this._payload.functionName; 1100 return this._payload.functionName;
1101 } 1101 }
1102 1102
1103 /** 1103 /**
1104 * @return {!WebInspector.DebuggerModel.Location} 1104 * @return {!SDK.DebuggerModel.Location}
1105 */ 1105 */
1106 location() { 1106 location() {
1107 return this._location; 1107 return this._location;
1108 } 1108 }
1109 1109
1110 /** 1110 /**
1111 * @return {?WebInspector.DebuggerModel.Location} 1111 * @return {?SDK.DebuggerModel.Location}
1112 */ 1112 */
1113 functionLocation() { 1113 functionLocation() {
1114 return this._functionLocation || null; 1114 return this._functionLocation || null;
1115 } 1115 }
1116 1116
1117 /** 1117 /**
1118 * @param {string} code 1118 * @param {string} code
1119 * @param {string} objectGroup 1119 * @param {string} objectGroup
1120 * @param {boolean} includeCommandLineAPI 1120 * @param {boolean} includeCommandLineAPI
1121 * @param {boolean} silent 1121 * @param {boolean} silent
(...skipping 21 matching lines...) Expand all
1143 } 1143 }
1144 1144
1145 /** 1145 /**
1146 * @param {function(?Protocol.Error=)=} callback 1146 * @param {function(?Protocol.Error=)=} callback
1147 */ 1147 */
1148 restart(callback) { 1148 restart(callback) {
1149 /** 1149 /**
1150 * @param {?Protocol.Error} error 1150 * @param {?Protocol.Error} error
1151 * @param {!Array.<!Protocol.Debugger.CallFrame>=} callFrames 1151 * @param {!Array.<!Protocol.Debugger.CallFrame>=} callFrames
1152 * @param {!Protocol.Runtime.StackTrace=} asyncStackTrace 1152 * @param {!Protocol.Runtime.StackTrace=} asyncStackTrace
1153 * @this {WebInspector.DebuggerModel.CallFrame} 1153 * @this {SDK.DebuggerModel.CallFrame}
1154 */ 1154 */
1155 function protocolCallback(error, callFrames, asyncStackTrace) { 1155 function protocolCallback(error, callFrames, asyncStackTrace) {
1156 if (!error) 1156 if (!error)
1157 this.debuggerModel.stepInto(); 1157 this.debuggerModel.stepInto();
1158 if (callback) 1158 if (callback)
1159 callback(error); 1159 callback(error);
1160 } 1160 }
1161 this._debuggerAgent.restartFrame(this._payload.callFrameId, protocolCallback .bind(this)); 1161 this._debuggerAgent.restartFrame(this._payload.callFrameId, protocolCallback .bind(this));
1162 } 1162 }
1163 1163
(...skipping 17 matching lines...) Expand all
1181 var object = scope.object(); 1181 var object = scope.object();
1182 object.getAllProperties(false, propertiesCollected); 1182 object.getAllProperties(false, propertiesCollected);
1183 } 1183 }
1184 } 1184 }
1185 }; 1185 };
1186 1186
1187 1187
1188 /** 1188 /**
1189 * @unrestricted 1189 * @unrestricted
1190 */ 1190 */
1191 WebInspector.DebuggerModel.Scope = class { 1191 SDK.DebuggerModel.Scope = class {
1192 /** 1192 /**
1193 * @param {!WebInspector.DebuggerModel.CallFrame} callFrame 1193 * @param {!SDK.DebuggerModel.CallFrame} callFrame
1194 * @param {number} ordinal 1194 * @param {number} ordinal
1195 */ 1195 */
1196 constructor(callFrame, ordinal) { 1196 constructor(callFrame, ordinal) {
1197 this._callFrame = callFrame; 1197 this._callFrame = callFrame;
1198 this._payload = callFrame._payload.scopeChain[ordinal]; 1198 this._payload = callFrame._payload.scopeChain[ordinal];
1199 this._type = this._payload.type; 1199 this._type = this._payload.type;
1200 this._name = this._payload.name; 1200 this._name = this._payload.name;
1201 this._ordinal = ordinal; 1201 this._ordinal = ordinal;
1202 this._startLocation = this._payload.startLocation ? 1202 this._startLocation = this._payload.startLocation ?
1203 WebInspector.DebuggerModel.Location.fromPayload(callFrame.debuggerModel, this._payload.startLocation) : 1203 SDK.DebuggerModel.Location.fromPayload(callFrame.debuggerModel, this._pa yload.startLocation) :
1204 null; 1204 null;
1205 this._endLocation = this._payload.endLocation ? 1205 this._endLocation = this._payload.endLocation ?
1206 WebInspector.DebuggerModel.Location.fromPayload(callFrame.debuggerModel, this._payload.endLocation) : 1206 SDK.DebuggerModel.Location.fromPayload(callFrame.debuggerModel, this._pa yload.endLocation) :
1207 null; 1207 null;
1208 } 1208 }
1209 1209
1210 /** 1210 /**
1211 * @return {!WebInspector.DebuggerModel.CallFrame} 1211 * @return {!SDK.DebuggerModel.CallFrame}
1212 */ 1212 */
1213 callFrame() { 1213 callFrame() {
1214 return this._callFrame; 1214 return this._callFrame;
1215 } 1215 }
1216 1216
1217 /** 1217 /**
1218 * @return {string} 1218 * @return {string}
1219 */ 1219 */
1220 type() { 1220 type() {
1221 return this._type; 1221 return this._type;
1222 } 1222 }
1223 1223
1224 /** 1224 /**
1225 * @return {string|undefined} 1225 * @return {string|undefined}
1226 */ 1226 */
1227 name() { 1227 name() {
1228 return this._name; 1228 return this._name;
1229 } 1229 }
1230 1230
1231 /** 1231 /**
1232 * @return {?WebInspector.DebuggerModel.Location} 1232 * @return {?SDK.DebuggerModel.Location}
1233 */ 1233 */
1234 startLocation() { 1234 startLocation() {
1235 return this._startLocation; 1235 return this._startLocation;
1236 } 1236 }
1237 1237
1238 /** 1238 /**
1239 * @return {?WebInspector.DebuggerModel.Location} 1239 * @return {?SDK.DebuggerModel.Location}
1240 */ 1240 */
1241 endLocation() { 1241 endLocation() {
1242 return this._endLocation; 1242 return this._endLocation;
1243 } 1243 }
1244 1244
1245 /** 1245 /**
1246 * @return {!WebInspector.RemoteObject} 1246 * @return {!SDK.RemoteObject}
1247 */ 1247 */
1248 object() { 1248 object() {
1249 if (this._object) 1249 if (this._object)
1250 return this._object; 1250 return this._object;
1251 var runtimeModel = this._callFrame.target().runtimeModel; 1251 var runtimeModel = this._callFrame.target().runtimeModel;
1252 1252
1253 var declarativeScope = this._type !== Protocol.Debugger.ScopeType.With && th is._type !== Protocol.Debugger.ScopeType.Global; 1253 var declarativeScope = this._type !== Protocol.Debugger.ScopeType.With && th is._type !== Protocol.Debugger.ScopeType.Global;
1254 if (declarativeScope) 1254 if (declarativeScope)
1255 this._object = runtimeModel.createScopeRemoteObject( 1255 this._object = runtimeModel.createScopeRemoteObject(
1256 this._payload.object, new WebInspector.ScopeRef(this._ordinal, this._c allFrame.id)); 1256 this._payload.object, new SDK.ScopeRef(this._ordinal, this._callFrame. id));
1257 else 1257 else
1258 this._object = runtimeModel.createRemoteObject(this._payload.object); 1258 this._object = runtimeModel.createRemoteObject(this._payload.object);
1259 1259
1260 return this._object; 1260 return this._object;
1261 } 1261 }
1262 1262
1263 /** 1263 /**
1264 * @return {string} 1264 * @return {string}
1265 */ 1265 */
1266 description() { 1266 description() {
1267 var declarativeScope = this._type !== Protocol.Debugger.ScopeType.With && th is._type !== Protocol.Debugger.ScopeType.Global; 1267 var declarativeScope = this._type !== Protocol.Debugger.ScopeType.With && th is._type !== Protocol.Debugger.ScopeType.Global;
1268 return declarativeScope ? '' : (this._payload.object.description || ''); 1268 return declarativeScope ? '' : (this._payload.object.description || '');
1269 } 1269 }
1270 }; 1270 };
1271 1271
1272 /** 1272 /**
1273 * @unrestricted 1273 * @unrestricted
1274 */ 1274 */
1275 WebInspector.DebuggerPausedDetails = class extends WebInspector.SDKObject { 1275 SDK.DebuggerPausedDetails = class extends SDK.SDKObject {
1276 /** 1276 /**
1277 * @param {!WebInspector.DebuggerModel} debuggerModel 1277 * @param {!SDK.DebuggerModel} debuggerModel
1278 * @param {!Array.<!Protocol.Debugger.CallFrame>} callFrames 1278 * @param {!Array.<!Protocol.Debugger.CallFrame>} callFrames
1279 * @param {string} reason 1279 * @param {string} reason
1280 * @param {!Object|undefined} auxData 1280 * @param {!Object|undefined} auxData
1281 * @param {!Array.<string>} breakpointIds 1281 * @param {!Array.<string>} breakpointIds
1282 * @param {!Protocol.Runtime.StackTrace=} asyncStackTrace 1282 * @param {!Protocol.Runtime.StackTrace=} asyncStackTrace
1283 */ 1283 */
1284 constructor(debuggerModel, callFrames, reason, auxData, breakpointIds, asyncSt ackTrace) { 1284 constructor(debuggerModel, callFrames, reason, auxData, breakpointIds, asyncSt ackTrace) {
1285 super(debuggerModel.target()); 1285 super(debuggerModel.target());
1286 this.debuggerModel = debuggerModel; 1286 this.debuggerModel = debuggerModel;
1287 this.callFrames = WebInspector.DebuggerModel.CallFrame.fromPayloadArray(debu ggerModel, callFrames); 1287 this.callFrames = SDK.DebuggerModel.CallFrame.fromPayloadArray(debuggerModel , callFrames);
1288 this.reason = reason; 1288 this.reason = reason;
1289 this.auxData = auxData; 1289 this.auxData = auxData;
1290 this.breakpointIds = breakpointIds; 1290 this.breakpointIds = breakpointIds;
1291 if (asyncStackTrace) 1291 if (asyncStackTrace)
1292 this.asyncStackTrace = this._cleanRedundantFrames(asyncStackTrace); 1292 this.asyncStackTrace = this._cleanRedundantFrames(asyncStackTrace);
1293 } 1293 }
1294 1294
1295 /** 1295 /**
1296 * @return {?WebInspector.RemoteObject} 1296 * @return {?SDK.RemoteObject}
1297 */ 1297 */
1298 exception() { 1298 exception() {
1299 if (this.reason !== WebInspector.DebuggerModel.BreakReason.Exception && 1299 if (this.reason !== SDK.DebuggerModel.BreakReason.Exception &&
1300 this.reason !== WebInspector.DebuggerModel.BreakReason.PromiseRejection) 1300 this.reason !== SDK.DebuggerModel.BreakReason.PromiseRejection)
1301 return null; 1301 return null;
1302 return this.target().runtimeModel.createRemoteObject(/** @type {!Protocol.Ru ntime.RemoteObject} */ (this.auxData)); 1302 return this.target().runtimeModel.createRemoteObject(/** @type {!Protocol.Ru ntime.RemoteObject} */ (this.auxData));
1303 } 1303 }
1304 1304
1305 /** 1305 /**
1306 * @param {!Protocol.Runtime.StackTrace} asyncStackTrace 1306 * @param {!Protocol.Runtime.StackTrace} asyncStackTrace
1307 * @return {!Protocol.Runtime.StackTrace} 1307 * @return {!Protocol.Runtime.StackTrace}
1308 */ 1308 */
1309 _cleanRedundantFrames(asyncStackTrace) { 1309 _cleanRedundantFrames(asyncStackTrace) {
1310 var stack = asyncStackTrace; 1310 var stack = asyncStackTrace;
1311 var previous = null; 1311 var previous = null;
1312 while (stack) { 1312 while (stack) {
1313 if (stack.description === 'async function' && stack.callFrames.length) 1313 if (stack.description === 'async function' && stack.callFrames.length)
1314 stack.callFrames.shift(); 1314 stack.callFrames.shift();
1315 if (previous && !stack.callFrames.length) 1315 if (previous && !stack.callFrames.length)
1316 previous.parent = stack.parent; 1316 previous.parent = stack.parent;
1317 else 1317 else
1318 previous = stack; 1318 previous = stack;
1319 stack = stack.parent; 1319 stack = stack.parent;
1320 } 1320 }
1321 return asyncStackTrace; 1321 return asyncStackTrace;
1322 } 1322 }
1323 }; 1323 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698