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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sdk/RemoteObject.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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 10 matching lines...) Expand all
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
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 * @typedef {{object: ?WebInspector.RemoteObject, wasThrown: (boolean|undefined) }} 31 * @typedef {{object: ?SDK.RemoteObject, wasThrown: (boolean|undefined)}}
32 */ 32 */
33 WebInspector.CallFunctionResult; 33 SDK.CallFunctionResult;
34 34
35 /** 35 /**
36 * @unrestricted 36 * @unrestricted
37 */ 37 */
38 WebInspector.RemoteObject = class { 38 SDK.RemoteObject = class {
39 /** 39 /**
40 * This may not be an interface due to "instanceof WebInspector.RemoteObject" checks in the code. 40 * This may not be an interface due to "instanceof SDK.RemoteObject" checks in the code.
41 */ 41 */
42 42
43 /** 43 /**
44 * @param {*} value 44 * @param {*} value
45 * @return {!WebInspector.RemoteObject} 45 * @return {!SDK.RemoteObject}
46 */ 46 */
47 static fromLocalObject(value) { 47 static fromLocalObject(value) {
48 return new WebInspector.LocalJSONObject(value); 48 return new SDK.LocalJSONObject(value);
49 } 49 }
50 50
51 /** 51 /**
52 * @param {!WebInspector.RemoteObject} remoteObject 52 * @param {!SDK.RemoteObject} remoteObject
53 * @return {string} 53 * @return {string}
54 */ 54 */
55 static type(remoteObject) { 55 static type(remoteObject) {
56 if (remoteObject === null) 56 if (remoteObject === null)
57 return 'null'; 57 return 'null';
58 58
59 var type = typeof remoteObject; 59 var type = typeof remoteObject;
60 if (type !== 'object' && type !== 'function') 60 if (type !== 'object' && type !== 'function')
61 return type; 61 return type;
62 62
63 return remoteObject.type; 63 return remoteObject.type;
64 } 64 }
65 65
66 /** 66 /**
67 * @param {!WebInspector.RemoteObject|!Protocol.Runtime.RemoteObject|!Protocol .Runtime.ObjectPreview} object 67 * @param {!SDK.RemoteObject|!Protocol.Runtime.RemoteObject|!Protocol.Runtime. ObjectPreview} object
68 * @return {number} 68 * @return {number}
69 */ 69 */
70 static arrayLength(object) { 70 static arrayLength(object) {
71 if (object.subtype !== 'array' && object.subtype !== 'typedarray') 71 if (object.subtype !== 'array' && object.subtype !== 'typedarray')
72 return 0; 72 return 0;
73 var matches = object.description.match(/\[([0-9]+)\]/); 73 var matches = object.description.match(/\[([0-9]+)\]/);
74 if (!matches) 74 if (!matches)
75 return 0; 75 return 0;
76 return parseInt(matches[1], 10); 76 return parseInt(matches[1], 10);
77 } 77 }
78 78
79 /** 79 /**
80 * @param {!Protocol.Runtime.RemoteObject|!WebInspector.RemoteObject|number|st ring|boolean|undefined|null} object 80 * @param {!Protocol.Runtime.RemoteObject|!SDK.RemoteObject|number|string|bool ean|undefined|null} object
81 * @return {!Protocol.Runtime.CallArgument} 81 * @return {!Protocol.Runtime.CallArgument}
82 */ 82 */
83 static toCallArgument(object) { 83 static toCallArgument(object) {
84 var type = typeof object; 84 var type = typeof object;
85 if (type === 'undefined') 85 if (type === 'undefined')
86 return {}; 86 return {};
87 if (type === 'number') { 87 if (type === 'number') {
88 var description = String(object); 88 var description = String(object);
89 if (object === 0 && 1 / object < 0) 89 if (object === 0 && 1 / object < 0)
90 return {unserializableValue: Protocol.Runtime.UnserializableValue.Negati ve0}; 90 return {unserializableValue: Protocol.Runtime.UnserializableValue.Negati ve0};
(...skipping 18 matching lines...) Expand all
109 109
110 if (typeof object.objectId !== 'undefined') 110 if (typeof object.objectId !== 'undefined')
111 return {objectId: object.objectId}; 111 return {objectId: object.objectId};
112 if (typeof object._objectId !== 'undefined') 112 if (typeof object._objectId !== 'undefined')
113 return {objectId: object._objectId}; 113 return {objectId: object._objectId};
114 114
115 return {value: object.value}; 115 return {value: object.value};
116 } 116 }
117 117
118 /** 118 /**
119 * @param {!WebInspector.RemoteObject} object 119 * @param {!SDK.RemoteObject} object
120 * @param {function(?Array.<!WebInspector.RemoteObjectProperty>, ?Array.<!WebI nspector.RemoteObjectProperty>)} callback 120 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj ectProperty>)} callback
121 */ 121 */
122 static loadFromObjectPerProto(object, callback) { 122 static loadFromObjectPerProto(object, callback) {
123 // Combines 2 asynch calls. Doesn't rely on call-back orders (some calls may be loop-back). 123 // Combines 2 asynch calls. Doesn't rely on call-back orders (some calls may be loop-back).
124 var savedOwnProperties; 124 var savedOwnProperties;
125 var savedAccessorProperties; 125 var savedAccessorProperties;
126 var savedInternalProperties; 126 var savedInternalProperties;
127 var resultCounter = 2; 127 var resultCounter = 2;
128 128
129 function processCallback() { 129 function processCallback() {
130 if (--resultCounter) 130 if (--resultCounter)
(...skipping 19 matching lines...) Expand all
150 } 150 }
151 return callback( 151 return callback(
152 propertiesMap.valuesArray().concat(propertySymbols), 152 propertiesMap.valuesArray().concat(propertySymbols),
153 savedInternalProperties ? savedInternalProperties : null); 153 savedInternalProperties ? savedInternalProperties : null);
154 } else { 154 } else {
155 callback(null, null); 155 callback(null, null);
156 } 156 }
157 } 157 }
158 158
159 /** 159 /**
160 * @param {?Array.<!WebInspector.RemoteObjectProperty>} properties 160 * @param {?Array.<!SDK.RemoteObjectProperty>} properties
161 * @param {?Array.<!WebInspector.RemoteObjectProperty>} internalProperties 161 * @param {?Array.<!SDK.RemoteObjectProperty>} internalProperties
162 */ 162 */
163 function allAccessorPropertiesCallback(properties, internalProperties) { 163 function allAccessorPropertiesCallback(properties, internalProperties) {
164 savedAccessorProperties = properties; 164 savedAccessorProperties = properties;
165 processCallback(); 165 processCallback();
166 } 166 }
167 167
168 /** 168 /**
169 * @param {?Array.<!WebInspector.RemoteObjectProperty>} properties 169 * @param {?Array.<!SDK.RemoteObjectProperty>} properties
170 * @param {?Array.<!WebInspector.RemoteObjectProperty>} internalProperties 170 * @param {?Array.<!SDK.RemoteObjectProperty>} internalProperties
171 */ 171 */
172 function ownPropertiesCallback(properties, internalProperties) { 172 function ownPropertiesCallback(properties, internalProperties) {
173 savedOwnProperties = properties; 173 savedOwnProperties = properties;
174 savedInternalProperties = internalProperties; 174 savedInternalProperties = internalProperties;
175 processCallback(); 175 processCallback();
176 } 176 }
177 177
178 object.getAllProperties(true, allAccessorPropertiesCallback); 178 object.getAllProperties(true, allAccessorPropertiesCallback);
179 object.getOwnProperties(ownPropertiesCallback); 179 object.getOwnProperties(ownPropertiesCallback);
180 } 180 }
(...skipping 26 matching lines...) Expand all
207 } 207 }
208 208
209 /** 209 /**
210 * @return {number} 210 * @return {number}
211 */ 211 */
212 arrayLength() { 212 arrayLength() {
213 throw 'Not implemented'; 213 throw 'Not implemented';
214 } 214 }
215 215
216 /** 216 /**
217 * @param {function(?Array.<!WebInspector.RemoteObjectProperty>, ?Array.<!WebI nspector.RemoteObjectProperty>)} callback 217 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj ectProperty>)} callback
218 */ 218 */
219 getOwnProperties(callback) { 219 getOwnProperties(callback) {
220 throw 'Not implemented'; 220 throw 'Not implemented';
221 } 221 }
222 222
223 /** 223 /**
224 * @return {!Promise<!{properties: ?Array.<!WebInspector.RemoteObjectProperty> , internalProperties: ?Array.<!WebInspector.RemoteObjectProperty>}>} 224 * @return {!Promise<!{properties: ?Array.<!SDK.RemoteObjectProperty>, interna lProperties: ?Array.<!SDK.RemoteObjectProperty>}>}
225 */ 225 */
226 getOwnPropertiesPromise() { 226 getOwnPropertiesPromise() {
227 return new Promise(promiseConstructor.bind(this)); 227 return new Promise(promiseConstructor.bind(this));
228 228
229 /** 229 /**
230 * @param {function(!{properties: ?Array.<!WebInspector.RemoteObjectProperty >, internalProperties: ?Array.<!WebInspector.RemoteObjectProperty>})} success 230 * @param {function(!{properties: ?Array.<!SDK.RemoteObjectProperty>, intern alProperties: ?Array.<!SDK.RemoteObjectProperty>})} success
231 * @this {WebInspector.RemoteObject} 231 * @this {SDK.RemoteObject}
232 */ 232 */
233 function promiseConstructor(success) { 233 function promiseConstructor(success) {
234 this.getOwnProperties(getOwnPropertiesCallback.bind(null, success)); 234 this.getOwnProperties(getOwnPropertiesCallback.bind(null, success));
235 } 235 }
236 236
237 /** 237 /**
238 * @param {function(!{properties: ?Array.<!WebInspector.RemoteObjectProperty >, internalProperties: ?Array.<!WebInspector.RemoteObjectProperty>})} callback 238 * @param {function(!{properties: ?Array.<!SDK.RemoteObjectProperty>, intern alProperties: ?Array.<!SDK.RemoteObjectProperty>})} callback
239 * @param {?Array.<!WebInspector.RemoteObjectProperty>} properties 239 * @param {?Array.<!SDK.RemoteObjectProperty>} properties
240 * @param {?Array.<!WebInspector.RemoteObjectProperty>} internalProperties 240 * @param {?Array.<!SDK.RemoteObjectProperty>} internalProperties
241 */ 241 */
242 function getOwnPropertiesCallback(callback, properties, internalProperties) { 242 function getOwnPropertiesCallback(callback, properties, internalProperties) {
243 callback({properties: properties, internalProperties: internalProperties}) ; 243 callback({properties: properties, internalProperties: internalProperties}) ;
244 } 244 }
245 } 245 }
246 246
247 /** 247 /**
248 * @param {boolean} accessorPropertiesOnly 248 * @param {boolean} accessorPropertiesOnly
249 * @param {function(?Array<!WebInspector.RemoteObjectProperty>, ?Array<!WebIns pector.RemoteObjectProperty>)} callback 249 * @param {function(?Array<!SDK.RemoteObjectProperty>, ?Array<!SDK.RemoteObjec tProperty>)} callback
250 */ 250 */
251 getAllProperties(accessorPropertiesOnly, callback) { 251 getAllProperties(accessorPropertiesOnly, callback) {
252 throw 'Not implemented'; 252 throw 'Not implemented';
253 } 253 }
254 254
255 /** 255 /**
256 * @param {boolean} accessorPropertiesOnly 256 * @param {boolean} accessorPropertiesOnly
257 * @return {!Promise<!{properties: ?Array<!WebInspector.RemoteObjectProperty>, internalProperties: ?Array<!WebInspector.RemoteObjectProperty>}>} 257 * @return {!Promise<!{properties: ?Array<!SDK.RemoteObjectProperty>, internal Properties: ?Array<!SDK.RemoteObjectProperty>}>}
258 */ 258 */
259 getAllPropertiesPromise(accessorPropertiesOnly) { 259 getAllPropertiesPromise(accessorPropertiesOnly) {
260 return new Promise(promiseConstructor.bind(this)); 260 return new Promise(promiseConstructor.bind(this));
261 261
262 /** 262 /**
263 * @param {function(!{properties: ?Array<!WebInspector.RemoteObjectProperty> , internalProperties: ?Array.<!WebInspector.RemoteObjectProperty>})} success 263 * @param {function(!{properties: ?Array<!SDK.RemoteObjectProperty>, interna lProperties: ?Array.<!SDK.RemoteObjectProperty>})} success
264 * @this {WebInspector.RemoteObject} 264 * @this {SDK.RemoteObject}
265 */ 265 */
266 function promiseConstructor(success) { 266 function promiseConstructor(success) {
267 this.getAllProperties(accessorPropertiesOnly, getAllPropertiesCallback.bin d(null, success)); 267 this.getAllProperties(accessorPropertiesOnly, getAllPropertiesCallback.bin d(null, success));
268 } 268 }
269 269
270 /** 270 /**
271 * @param {function(!{properties: ?Array<!WebInspector.RemoteObjectProperty> , internalProperties: ?Array<!WebInspector.RemoteObjectProperty>})} callback 271 * @param {function(!{properties: ?Array<!SDK.RemoteObjectProperty>, interna lProperties: ?Array<!SDK.RemoteObjectProperty>})} callback
272 * @param {?Array<!WebInspector.RemoteObjectProperty>} properties 272 * @param {?Array<!SDK.RemoteObjectProperty>} properties
273 * @param {?Array<!WebInspector.RemoteObjectProperty>} internalProperties 273 * @param {?Array<!SDK.RemoteObjectProperty>} internalProperties
274 */ 274 */
275 function getAllPropertiesCallback(callback, properties, internalProperties) { 275 function getAllPropertiesCallback(callback, properties, internalProperties) {
276 callback({properties: properties, internalProperties: internalProperties}) ; 276 callback({properties: properties, internalProperties: internalProperties}) ;
277 } 277 }
278 } 278 }
279 279
280 /** 280 /**
281 * @return {!Promise<?Array<!WebInspector.EventListener>>} 281 * @return {!Promise<?Array<!SDK.EventListener>>}
282 */ 282 */
283 eventListeners() { 283 eventListeners() {
284 throw 'Not implemented'; 284 throw 'Not implemented';
285 } 285 }
286 286
287 /** 287 /**
288 * @param {!Protocol.Runtime.CallArgument} name 288 * @param {!Protocol.Runtime.CallArgument} name
289 * @param {function(string=)} callback 289 * @param {function(string=)} callback
290 */ 290 */
291 deleteProperty(name, callback) { 291 deleteProperty(name, callback) {
292 throw 'Not implemented'; 292 throw 'Not implemented';
293 } 293 }
294 294
295 /** 295 /**
296 * @param {string|!Protocol.Runtime.CallArgument} name 296 * @param {string|!Protocol.Runtime.CallArgument} name
297 * @param {string} value 297 * @param {string} value
298 * @param {function(string=)} callback 298 * @param {function(string=)} callback
299 */ 299 */
300 setPropertyValue(name, value, callback) { 300 setPropertyValue(name, value, callback) {
301 throw 'Not implemented'; 301 throw 'Not implemented';
302 } 302 }
303 303
304 /** 304 /**
305 * @param {function(this:Object, ...)} functionDeclaration 305 * @param {function(this:Object, ...)} functionDeclaration
306 * @param {!Array<!Protocol.Runtime.CallArgument>=} args 306 * @param {!Array<!Protocol.Runtime.CallArgument>=} args
307 * @param {function(?WebInspector.RemoteObject, boolean=)=} callback 307 * @param {function(?SDK.RemoteObject, boolean=)=} callback
308 */ 308 */
309 callFunction(functionDeclaration, args, callback) { 309 callFunction(functionDeclaration, args, callback) {
310 throw 'Not implemented'; 310 throw 'Not implemented';
311 } 311 }
312 312
313 /** 313 /**
314 * @param {function(this:Object, ...)} functionDeclaration 314 * @param {function(this:Object, ...)} functionDeclaration
315 * @param {!Array<!Protocol.Runtime.CallArgument>=} args 315 * @param {!Array<!Protocol.Runtime.CallArgument>=} args
316 * @return {!Promise<!WebInspector.CallFunctionResult>} 316 * @return {!Promise<!SDK.CallFunctionResult>}
317 */ 317 */
318 callFunctionPromise(functionDeclaration, args) { 318 callFunctionPromise(functionDeclaration, args) {
319 return new Promise(promiseConstructor.bind(this)); 319 return new Promise(promiseConstructor.bind(this));
320 320
321 /** 321 /**
322 * @param {function(!WebInspector.CallFunctionResult)} success 322 * @param {function(!SDK.CallFunctionResult)} success
323 * @this {WebInspector.RemoteObject} 323 * @this {SDK.RemoteObject}
324 */ 324 */
325 function promiseConstructor(success) { 325 function promiseConstructor(success) {
326 this.callFunction(functionDeclaration, args, callFunctionCallback.bind(nul l, success)); 326 this.callFunction(functionDeclaration, args, callFunctionCallback.bind(nul l, success));
327 } 327 }
328 328
329 /** 329 /**
330 * @param {function(!WebInspector.CallFunctionResult)} callback 330 * @param {function(!SDK.CallFunctionResult)} callback
331 * @param {?WebInspector.RemoteObject} object 331 * @param {?SDK.RemoteObject} object
332 * @param {boolean=} wasThrown 332 * @param {boolean=} wasThrown
333 */ 333 */
334 function callFunctionCallback(callback, object, wasThrown) { 334 function callFunctionCallback(callback, object, wasThrown) {
335 callback({object: object, wasThrown: wasThrown}); 335 callback({object: object, wasThrown: wasThrown});
336 } 336 }
337 } 337 }
338 338
339 /** 339 /**
340 * @template T 340 * @template T
341 * @param {function(this:Object, ...):T} functionDeclaration 341 * @param {function(this:Object, ...):T} functionDeclaration
342 * @param {!Array<!Protocol.Runtime.CallArgument>|undefined} args 342 * @param {!Array<!Protocol.Runtime.CallArgument>|undefined} args
343 * @param {function(T)} callback 343 * @param {function(T)} callback
344 */ 344 */
345 callFunctionJSON(functionDeclaration, args, callback) { 345 callFunctionJSON(functionDeclaration, args, callback) {
346 throw 'Not implemented'; 346 throw 'Not implemented';
347 } 347 }
348 348
349 /** 349 /**
350 * @param {function(this:Object, ...):T} functionDeclaration 350 * @param {function(this:Object, ...):T} functionDeclaration
351 * @param {!Array<!Protocol.Runtime.CallArgument>|undefined} args 351 * @param {!Array<!Protocol.Runtime.CallArgument>|undefined} args
352 * @return {!Promise<T>} 352 * @return {!Promise<T>}
353 * @template T 353 * @template T
354 */ 354 */
355 callFunctionJSONPromise(functionDeclaration, args) { 355 callFunctionJSONPromise(functionDeclaration, args) {
356 return new Promise(promiseConstructor.bind(this)); 356 return new Promise(promiseConstructor.bind(this));
357 357
358 /** 358 /**
359 * @this {WebInspector.RemoteObject} 359 * @this {SDK.RemoteObject}
360 */ 360 */
361 function promiseConstructor(success) { 361 function promiseConstructor(success) {
362 this.callFunctionJSON(functionDeclaration, args, success); 362 this.callFunctionJSON(functionDeclaration, args, success);
363 } 363 }
364 } 364 }
365 365
366 /** 366 /**
367 * @return {!WebInspector.Target} 367 * @return {!SDK.Target}
368 */ 368 */
369 target() { 369 target() {
370 throw new Error('Target-less object'); 370 throw new Error('Target-less object');
371 } 371 }
372 372
373 /** 373 /**
374 * @return {?WebInspector.DebuggerModel} 374 * @return {?SDK.DebuggerModel}
375 */ 375 */
376 debuggerModel() { 376 debuggerModel() {
377 throw new Error('DebuggerModel-less object'); 377 throw new Error('DebuggerModel-less object');
378 } 378 }
379 379
380 /** 380 /**
381 * @return {boolean} 381 * @return {boolean}
382 */ 382 */
383 isNode() { 383 isNode() {
384 return false; 384 return false;
385 } 385 }
386 }; 386 };
387 387
388 388
389 /** 389 /**
390 * @unrestricted 390 * @unrestricted
391 */ 391 */
392 WebInspector.RemoteObjectImpl = class extends WebInspector.RemoteObject { 392 SDK.RemoteObjectImpl = class extends SDK.RemoteObject {
393 /** 393 /**
394 * @param {!WebInspector.Target} target 394 * @param {!SDK.Target} target
395 * @param {string|undefined} objectId 395 * @param {string|undefined} objectId
396 * @param {string} type 396 * @param {string} type
397 * @param {string|undefined} subtype 397 * @param {string|undefined} subtype
398 * @param {*} value 398 * @param {*} value
399 * @param {!Protocol.Runtime.UnserializableValue=} unserializableValue 399 * @param {!Protocol.Runtime.UnserializableValue=} unserializableValue
400 * @param {string=} description 400 * @param {string=} description
401 * @param {!Protocol.Runtime.ObjectPreview=} preview 401 * @param {!Protocol.Runtime.ObjectPreview=} preview
402 * @param {!Protocol.Runtime.CustomPreview=} customPreview 402 * @param {!Protocol.Runtime.CustomPreview=} customPreview
403 */ 403 */
404 constructor(target, objectId, type, subtype, value, unserializableValue, descr iption, preview, customPreview) { 404 constructor(target, objectId, type, subtype, value, unserializableValue, descr iption, preview, customPreview) {
405 super(); 405 super();
406 406
407 this._target = target; 407 this._target = target;
408 this._runtimeAgent = target.runtimeAgent(); 408 this._runtimeAgent = target.runtimeAgent();
409 this._debuggerModel = WebInspector.DebuggerModel.fromTarget(target); 409 this._debuggerModel = SDK.DebuggerModel.fromTarget(target);
410 410
411 this._type = type; 411 this._type = type;
412 this._subtype = subtype; 412 this._subtype = subtype;
413 if (objectId) { 413 if (objectId) {
414 // handle 414 // handle
415 this._objectId = objectId; 415 this._objectId = objectId;
416 this._description = description; 416 this._description = description;
417 this._hasChildren = (type !== 'symbol'); 417 this._hasChildren = (type !== 'symbol');
418 this._preview = preview; 418 this._preview = preview;
419 } else { 419 } else {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 485
486 /** 486 /**
487 * @return {!Protocol.Runtime.ObjectPreview|undefined} 487 * @return {!Protocol.Runtime.ObjectPreview|undefined}
488 */ 488 */
489 get preview() { 489 get preview() {
490 return this._preview; 490 return this._preview;
491 } 491 }
492 492
493 /** 493 /**
494 * @override 494 * @override
495 * @param {function(?Array.<!WebInspector.RemoteObjectProperty>, ?Array.<!WebI nspector.RemoteObjectProperty>)} callback 495 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj ectProperty>)} callback
496 */ 496 */
497 getOwnProperties(callback) { 497 getOwnProperties(callback) {
498 this.doGetProperties(true, false, false, callback); 498 this.doGetProperties(true, false, false, callback);
499 } 499 }
500 500
501 /** 501 /**
502 * @override 502 * @override
503 * @param {boolean} accessorPropertiesOnly 503 * @param {boolean} accessorPropertiesOnly
504 * @param {function(?Array.<!WebInspector.RemoteObjectProperty>, ?Array.<!WebI nspector.RemoteObjectProperty>)} callback 504 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj ectProperty>)} callback
505 */ 505 */
506 getAllProperties(accessorPropertiesOnly, callback) { 506 getAllProperties(accessorPropertiesOnly, callback) {
507 this.doGetProperties(false, accessorPropertiesOnly, false, callback); 507 this.doGetProperties(false, accessorPropertiesOnly, false, callback);
508 } 508 }
509 509
510 /** 510 /**
511 * @override 511 * @override
512 * @return {!Promise<?Array<!WebInspector.EventListener>>} 512 * @return {!Promise<?Array<!SDK.EventListener>>}
513 */ 513 */
514 eventListeners() { 514 eventListeners() {
515 return new Promise(eventListeners.bind(this)); 515 return new Promise(eventListeners.bind(this));
516 /** 516 /**
517 * @param {function(?)} fulfill 517 * @param {function(?)} fulfill
518 * @param {function(*)} reject 518 * @param {function(*)} reject
519 * @this {WebInspector.RemoteObjectImpl} 519 * @this {SDK.RemoteObjectImpl}
520 */ 520 */
521 function eventListeners(fulfill, reject) { 521 function eventListeners(fulfill, reject) {
522 if (!this.target().hasDOMCapability()) { 522 if (!this.target().hasDOMCapability()) {
523 // TODO(kozyatinskiy): figure out how this should work for |window| when there is no DOMDebugger. 523 // TODO(kozyatinskiy): figure out how this should work for |window| when there is no DOMDebugger.
524 fulfill([]); 524 fulfill([]);
525 return; 525 return;
526 } 526 }
527 527
528 if (!this._objectId) { 528 if (!this._objectId) {
529 reject(new Error('No object id specified')); 529 reject(new Error('No object id specified'));
530 return; 530 return;
531 } 531 }
532 532
533 this.target().domdebuggerAgent().getEventListeners(this._objectId, mycallb ack.bind(this)); 533 this.target().domdebuggerAgent().getEventListeners(this._objectId, mycallb ack.bind(this));
534 534
535 /** 535 /**
536 * @this {WebInspector.RemoteObjectImpl} 536 * @this {SDK.RemoteObjectImpl}
537 * @param {?Protocol.Error} error 537 * @param {?Protocol.Error} error
538 * @param {!Array<!Protocol.DOMDebugger.EventListener>} payloads 538 * @param {!Array<!Protocol.DOMDebugger.EventListener>} payloads
539 */ 539 */
540 function mycallback(error, payloads) { 540 function mycallback(error, payloads) {
541 if (error) { 541 if (error) {
542 reject(new Error(error)); 542 reject(new Error(error));
543 return; 543 return;
544 } 544 }
545 fulfill(payloads.map(createEventListener.bind(this))); 545 fulfill(payloads.map(createEventListener.bind(this)));
546 } 546 }
547 547
548 /** 548 /**
549 * @this {WebInspector.RemoteObjectImpl} 549 * @this {SDK.RemoteObjectImpl}
550 * @param {!Protocol.DOMDebugger.EventListener} payload 550 * @param {!Protocol.DOMDebugger.EventListener} payload
551 */ 551 */
552 function createEventListener(payload) { 552 function createEventListener(payload) {
553 return new WebInspector.EventListener( 553 return new SDK.EventListener(
554 this._target, this, payload.type, payload.useCapture, payload.passiv e, payload.once, 554 this._target, this, payload.type, payload.useCapture, payload.passiv e, payload.once,
555 payload.handler ? this.target().runtimeModel.createRemoteObject(payl oad.handler) : null, 555 payload.handler ? this.target().runtimeModel.createRemoteObject(payl oad.handler) : null,
556 payload.originalHandler ? this.target().runtimeModel.createRemoteObj ect(payload.originalHandler) : null, 556 payload.originalHandler ? this.target().runtimeModel.createRemoteObj ect(payload.originalHandler) : null,
557 /** @type {!WebInspector.DebuggerModel.Location} */ (this._debuggerM odel.createRawLocationByScriptId( 557 /** @type {!SDK.DebuggerModel.Location} */ (this._debuggerModel.crea teRawLocationByScriptId(
558 payload.scriptId, payload.lineNumber, payload.columnNumber)), 558 payload.scriptId, payload.lineNumber, payload.columnNumber)),
559 payload.removeFunction ? this.target().runtimeModel.createRemoteObje ct(payload.removeFunction) : null); 559 payload.removeFunction ? this.target().runtimeModel.createRemoteObje ct(payload.removeFunction) : null);
560 } 560 }
561 } 561 }
562 } 562 }
563 563
564 /** 564 /**
565 * @param {!Array.<string>} propertyPath 565 * @param {!Array.<string>} propertyPath
566 * @param {function(?WebInspector.RemoteObject, boolean=)} callback 566 * @param {function(?SDK.RemoteObject, boolean=)} callback
567 */ 567 */
568 getProperty(propertyPath, callback) { 568 getProperty(propertyPath, callback) {
569 /** 569 /**
570 * @param {string} arrayStr 570 * @param {string} arrayStr
571 * @suppressReceiverCheck 571 * @suppressReceiverCheck
572 * @this {Object} 572 * @this {Object}
573 */ 573 */
574 function remoteFunction(arrayStr) { 574 function remoteFunction(arrayStr) {
575 var result = this; 575 var result = this;
576 var properties = JSON.parse(arrayStr); 576 var properties = JSON.parse(arrayStr);
577 for (var i = 0, n = properties.length; i < n; ++i) 577 for (var i = 0, n = properties.length; i < n; ++i)
578 result = result[properties[i]]; 578 result = result[properties[i]];
579 return result; 579 return result;
580 } 580 }
581 581
582 var args = [{value: JSON.stringify(propertyPath)}]; 582 var args = [{value: JSON.stringify(propertyPath)}];
583 this.callFunction(remoteFunction, args, callback); 583 this.callFunction(remoteFunction, args, callback);
584 } 584 }
585 585
586 /** 586 /**
587 * @param {boolean} ownProperties 587 * @param {boolean} ownProperties
588 * @param {boolean} accessorPropertiesOnly 588 * @param {boolean} accessorPropertiesOnly
589 * @param {boolean} generatePreview 589 * @param {boolean} generatePreview
590 * @param {function(?Array.<!WebInspector.RemoteObjectProperty>, ?Array.<!WebI nspector.RemoteObjectProperty>)} callback 590 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj ectProperty>)} callback
591 */ 591 */
592 doGetProperties(ownProperties, accessorPropertiesOnly, generatePreview, callba ck) { 592 doGetProperties(ownProperties, accessorPropertiesOnly, generatePreview, callba ck) {
593 if (!this._objectId) { 593 if (!this._objectId) {
594 callback(null, null); 594 callback(null, null);
595 return; 595 return;
596 } 596 }
597 597
598 /** 598 /**
599 * @param {?Protocol.Error} error 599 * @param {?Protocol.Error} error
600 * @param {!Array.<!Protocol.Runtime.PropertyDescriptor>} properties 600 * @param {!Array.<!Protocol.Runtime.PropertyDescriptor>} properties
601 * @param {!Array.<!Protocol.Runtime.InternalPropertyDescriptor>=} internalP roperties 601 * @param {!Array.<!Protocol.Runtime.InternalPropertyDescriptor>=} internalP roperties
602 * @param {?Protocol.Runtime.ExceptionDetails=} exceptionDetails 602 * @param {?Protocol.Runtime.ExceptionDetails=} exceptionDetails
603 * @this {WebInspector.RemoteObjectImpl} 603 * @this {SDK.RemoteObjectImpl}
604 */ 604 */
605 function remoteObjectBinder(error, properties, internalProperties, exception Details) { 605 function remoteObjectBinder(error, properties, internalProperties, exception Details) {
606 if (error) { 606 if (error) {
607 callback(null, null); 607 callback(null, null);
608 return; 608 return;
609 } 609 }
610 if (exceptionDetails) { 610 if (exceptionDetails) {
611 this._target.consoleModel.addMessage( 611 this._target.consoleModel.addMessage(
612 WebInspector.ConsoleMessage.fromException(this._target, exceptionDet ails, undefined, undefined, undefined)); 612 SDK.ConsoleMessage.fromException(this._target, exceptionDetails, und efined, undefined, undefined));
613 callback(null, null); 613 callback(null, null);
614 return; 614 return;
615 } 615 }
616 var result = []; 616 var result = [];
617 for (var i = 0; properties && i < properties.length; ++i) { 617 for (var i = 0; properties && i < properties.length; ++i) {
618 var property = properties[i]; 618 var property = properties[i];
619 var propertyValue = property.value ? this._target.runtimeModel.createRem oteObject(property.value) : null; 619 var propertyValue = property.value ? this._target.runtimeModel.createRem oteObject(property.value) : null;
620 var propertySymbol = property.symbol ? this._target.runtimeModel.createR emoteObject(property.symbol) : null; 620 var propertySymbol = property.symbol ? this._target.runtimeModel.createR emoteObject(property.symbol) : null;
621 var remoteProperty = new WebInspector.RemoteObjectProperty( 621 var remoteProperty = new SDK.RemoteObjectProperty(
622 property.name, propertyValue, !!property.enumerable, !!property.writ able, !!property.isOwn, 622 property.name, propertyValue, !!property.enumerable, !!property.writ able, !!property.isOwn,
623 !!property.wasThrown, propertySymbol); 623 !!property.wasThrown, propertySymbol);
624 624
625 if (typeof property.value === 'undefined') { 625 if (typeof property.value === 'undefined') {
626 if (property.get && property.get.type !== 'undefined') 626 if (property.get && property.get.type !== 'undefined')
627 remoteProperty.getter = this._target.runtimeModel.createRemoteObject (property.get); 627 remoteProperty.getter = this._target.runtimeModel.createRemoteObject (property.get);
628 if (property.set && property.set.type !== 'undefined') 628 if (property.set && property.set.type !== 'undefined')
629 remoteProperty.setter = this._target.runtimeModel.createRemoteObject (property.set); 629 remoteProperty.setter = this._target.runtimeModel.createRemoteObject (property.set);
630 } 630 }
631 631
632 result.push(remoteProperty); 632 result.push(remoteProperty);
633 } 633 }
634 var internalPropertiesResult = null; 634 var internalPropertiesResult = null;
635 if (internalProperties) { 635 if (internalProperties) {
636 internalPropertiesResult = []; 636 internalPropertiesResult = [];
637 for (var i = 0; i < internalProperties.length; i++) { 637 for (var i = 0; i < internalProperties.length; i++) {
638 var property = internalProperties[i]; 638 var property = internalProperties[i];
639 if (!property.value) 639 if (!property.value)
640 continue; 640 continue;
641 var propertyValue = this._target.runtimeModel.createRemoteObject(prope rty.value); 641 var propertyValue = this._target.runtimeModel.createRemoteObject(prope rty.value);
642 internalPropertiesResult.push( 642 internalPropertiesResult.push(
643 new WebInspector.RemoteObjectProperty(property.name, propertyValue , true, false)); 643 new SDK.RemoteObjectProperty(property.name, propertyValue, true, f alse));
644 } 644 }
645 } 645 }
646 callback(result, internalPropertiesResult); 646 callback(result, internalPropertiesResult);
647 } 647 }
648 this._runtimeAgent.getProperties( 648 this._runtimeAgent.getProperties(
649 this._objectId, ownProperties, accessorPropertiesOnly, generatePreview, remoteObjectBinder.bind(this)); 649 this._objectId, ownProperties, accessorPropertiesOnly, generatePreview, remoteObjectBinder.bind(this));
650 } 650 }
651 651
652 /** 652 /**
653 * @override 653 * @override
654 * @param {string|!Protocol.Runtime.CallArgument} name 654 * @param {string|!Protocol.Runtime.CallArgument} name
655 * @param {string} value 655 * @param {string} value
656 * @param {function(string=)} callback 656 * @param {function(string=)} callback
657 */ 657 */
658 setPropertyValue(name, value, callback) { 658 setPropertyValue(name, value, callback) {
659 if (!this._objectId) { 659 if (!this._objectId) {
660 callback('Can\'t set a property of non-object.'); 660 callback('Can\'t set a property of non-object.');
661 return; 661 return;
662 } 662 }
663 663
664 this._runtimeAgent.invoke_evaluate({expression: value, silent: true}, evalua tedCallback.bind(this)); 664 this._runtimeAgent.invoke_evaluate({expression: value, silent: true}, evalua tedCallback.bind(this));
665 665
666 /** 666 /**
667 * @param {?Protocol.Error} error 667 * @param {?Protocol.Error} error
668 * @param {!Protocol.Runtime.RemoteObject} result 668 * @param {!Protocol.Runtime.RemoteObject} result
669 * @param {!Protocol.Runtime.ExceptionDetails=} exceptionDetails 669 * @param {!Protocol.Runtime.ExceptionDetails=} exceptionDetails
670 * @this {WebInspector.RemoteObject} 670 * @this {SDK.RemoteObject}
671 */ 671 */
672 function evaluatedCallback(error, result, exceptionDetails) { 672 function evaluatedCallback(error, result, exceptionDetails) {
673 if (error || !!exceptionDetails) { 673 if (error || !!exceptionDetails) {
674 callback(error || (result.type !== 'string' ? result.description : /** @ type {string} */ (result.value))); 674 callback(error || (result.type !== 'string' ? result.description : /** @ type {string} */ (result.value)));
675 return; 675 return;
676 } 676 }
677 677
678 if (typeof name === 'string') 678 if (typeof name === 'string')
679 name = WebInspector.RemoteObject.toCallArgument(name); 679 name = SDK.RemoteObject.toCallArgument(name);
680 680
681 this.doSetObjectPropertyValue(result, name, callback); 681 this.doSetObjectPropertyValue(result, name, callback);
682 682
683 if (result.objectId) 683 if (result.objectId)
684 this._runtimeAgent.releaseObject(result.objectId); 684 this._runtimeAgent.releaseObject(result.objectId);
685 } 685 }
686 } 686 }
687 687
688 /** 688 /**
689 * @param {!Protocol.Runtime.RemoteObject} result 689 * @param {!Protocol.Runtime.RemoteObject} result
690 * @param {!Protocol.Runtime.CallArgument} name 690 * @param {!Protocol.Runtime.CallArgument} name
691 * @param {function(string=)} callback 691 * @param {function(string=)} callback
692 */ 692 */
693 doSetObjectPropertyValue(result, name, callback) { 693 doSetObjectPropertyValue(result, name, callback) {
694 // This assignment may be for a regular (data) property, and for an accessor property (with getter/setter). 694 // This assignment may be for a regular (data) property, and for an accessor property (with getter/setter).
695 // Note the sensitive matter about accessor property: the property may be ph ysically defined in some proto object, 695 // Note the sensitive matter about accessor property: the property may be ph ysically defined in some proto object,
696 // but logically it is bound to the object in question. JavaScript passes th is object to getters/setters, not the object 696 // but logically it is bound to the object in question. JavaScript passes th is object to getters/setters, not the object
697 // where property was defined; so do we. 697 // where property was defined; so do we.
698 var setPropertyValueFunction = 'function(a, b) { this[a] = b; }'; 698 var setPropertyValueFunction = 'function(a, b) { this[a] = b; }';
699 699
700 var argv = [name, WebInspector.RemoteObject.toCallArgument(result)]; 700 var argv = [name, SDK.RemoteObject.toCallArgument(result)];
701 this._runtimeAgent.callFunctionOn( 701 this._runtimeAgent.callFunctionOn(
702 this._objectId, setPropertyValueFunction, argv, true, undefined, undefin ed, undefined, undefined, 702 this._objectId, setPropertyValueFunction, argv, true, undefined, undefin ed, undefined, undefined,
703 propertySetCallback); 703 propertySetCallback);
704 704
705 /** 705 /**
706 * @param {?Protocol.Error} error 706 * @param {?Protocol.Error} error
707 * @param {!Protocol.Runtime.RemoteObject} result 707 * @param {!Protocol.Runtime.RemoteObject} result
708 * @param {!Protocol.Runtime.ExceptionDetails=} exceptionDetails 708 * @param {!Protocol.Runtime.ExceptionDetails=} exceptionDetails
709 */ 709 */
710 function propertySetCallback(error, result, exceptionDetails) { 710 function propertySetCallback(error, result, exceptionDetails) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 callback('Failed to delete property.'); 746 callback('Failed to delete property.');
747 else 747 else
748 callback(); 748 callback();
749 } 749 }
750 } 750 }
751 751
752 /** 752 /**
753 * @override 753 * @override
754 * @param {function(this:Object, ...)} functionDeclaration 754 * @param {function(this:Object, ...)} functionDeclaration
755 * @param {!Array.<!Protocol.Runtime.CallArgument>=} args 755 * @param {!Array.<!Protocol.Runtime.CallArgument>=} args
756 * @param {function(?WebInspector.RemoteObject, boolean=)=} callback 756 * @param {function(?SDK.RemoteObject, boolean=)=} callback
757 */ 757 */
758 callFunction(functionDeclaration, args, callback) { 758 callFunction(functionDeclaration, args, callback) {
759 /** 759 /**
760 * @param {?Protocol.Error} error 760 * @param {?Protocol.Error} error
761 * @param {!Protocol.Runtime.RemoteObject} result 761 * @param {!Protocol.Runtime.RemoteObject} result
762 * @param {!Protocol.Runtime.ExceptionDetails=} exceptionDetails 762 * @param {!Protocol.Runtime.ExceptionDetails=} exceptionDetails
763 * @this {WebInspector.RemoteObjectImpl} 763 * @this {SDK.RemoteObjectImpl}
764 */ 764 */
765 function mycallback(error, result, exceptionDetails) { 765 function mycallback(error, result, exceptionDetails) {
766 if (!callback) 766 if (!callback)
767 return; 767 return;
768 if (error) 768 if (error)
769 callback(null, false); 769 callback(null, false);
770 else 770 else
771 callback(this.target().runtimeModel.createRemoteObject(result), !!except ionDetails); 771 callback(this.target().runtimeModel.createRemoteObject(result), !!except ionDetails);
772 } 772 }
773 773
(...skipping 26 matching lines...) Expand all
800 if (!this._objectId) 800 if (!this._objectId)
801 return; 801 return;
802 this._runtimeAgent.releaseObject(this._objectId); 802 this._runtimeAgent.releaseObject(this._objectId);
803 } 803 }
804 804
805 /** 805 /**
806 * @override 806 * @override
807 * @return {number} 807 * @return {number}
808 */ 808 */
809 arrayLength() { 809 arrayLength() {
810 return WebInspector.RemoteObject.arrayLength(this); 810 return SDK.RemoteObject.arrayLength(this);
811 } 811 }
812 812
813 /** 813 /**
814 * @override 814 * @override
815 * @return {!WebInspector.Target} 815 * @return {!SDK.Target}
816 */ 816 */
817 target() { 817 target() {
818 return this._target; 818 return this._target;
819 } 819 }
820 820
821 /** 821 /**
822 * @override 822 * @override
823 * @return {?WebInspector.DebuggerModel} 823 * @return {?SDK.DebuggerModel}
824 */ 824 */
825 debuggerModel() { 825 debuggerModel() {
826 return this._debuggerModel; 826 return this._debuggerModel;
827 } 827 }
828 828
829 /** 829 /**
830 * @override 830 * @override
831 * @return {boolean} 831 * @return {boolean}
832 */ 832 */
833 isNode() { 833 isNode() {
834 return !!this._objectId && this.type === 'object' && this.subtype === 'node' ; 834 return !!this._objectId && this.type === 'object' && this.subtype === 'node' ;
835 } 835 }
836 }; 836 };
837 837
838 838
839 /** 839 /**
840 * @unrestricted 840 * @unrestricted
841 */ 841 */
842 WebInspector.ScopeRemoteObject = class extends WebInspector.RemoteObjectImpl { 842 SDK.ScopeRemoteObject = class extends SDK.RemoteObjectImpl {
843 /** 843 /**
844 * @param {!WebInspector.Target} target 844 * @param {!SDK.Target} target
845 * @param {string|undefined} objectId 845 * @param {string|undefined} objectId
846 * @param {!WebInspector.ScopeRef} scopeRef 846 * @param {!SDK.ScopeRef} scopeRef
847 * @param {string} type 847 * @param {string} type
848 * @param {string|undefined} subtype 848 * @param {string|undefined} subtype
849 * @param {*} value 849 * @param {*} value
850 * @param {!Protocol.Runtime.UnserializableValue=} unserializableValue 850 * @param {!Protocol.Runtime.UnserializableValue=} unserializableValue
851 * @param {string=} description 851 * @param {string=} description
852 * @param {!Protocol.Runtime.ObjectPreview=} preview 852 * @param {!Protocol.Runtime.ObjectPreview=} preview
853 */ 853 */
854 constructor(target, objectId, scopeRef, type, subtype, value, unserializableVa lue, description, preview) { 854 constructor(target, objectId, scopeRef, type, subtype, value, unserializableVa lue, description, preview) {
855 super(target, objectId, type, subtype, value, unserializableValue, descripti on, preview); 855 super(target, objectId, type, subtype, value, unserializableValue, descripti on, preview);
856 this._scopeRef = scopeRef; 856 this._scopeRef = scopeRef;
857 this._savedScopeProperties = undefined; 857 this._savedScopeProperties = undefined;
858 } 858 }
859 859
860 /** 860 /**
861 * @override 861 * @override
862 * @param {boolean} ownProperties 862 * @param {boolean} ownProperties
863 * @param {boolean} accessorPropertiesOnly 863 * @param {boolean} accessorPropertiesOnly
864 * @param {boolean} generatePreview 864 * @param {boolean} generatePreview
865 * @param {function(?Array.<!WebInspector.RemoteObjectProperty>, ?Array.<!WebI nspector.RemoteObjectProperty>)} callback 865 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj ectProperty>)} callback
866 */ 866 */
867 doGetProperties(ownProperties, accessorPropertiesOnly, generatePreview, callba ck) { 867 doGetProperties(ownProperties, accessorPropertiesOnly, generatePreview, callba ck) {
868 if (accessorPropertiesOnly) { 868 if (accessorPropertiesOnly) {
869 callback([], []); 869 callback([], []);
870 return; 870 return;
871 } 871 }
872 872
873 if (this._savedScopeProperties) { 873 if (this._savedScopeProperties) {
874 // No need to reload scope variables, as the remote object never 874 // No need to reload scope variables, as the remote object never
875 // changes its properties. If variable is updated, the properties 875 // changes its properties. If variable is updated, the properties
876 // array is patched locally. 876 // array is patched locally.
877 callback(this._savedScopeProperties.slice(), []); 877 callback(this._savedScopeProperties.slice(), []);
878 return; 878 return;
879 } 879 }
880 880
881 /** 881 /**
882 * @param {?Array.<!WebInspector.RemoteObjectProperty>} properties 882 * @param {?Array.<!SDK.RemoteObjectProperty>} properties
883 * @param {?Array.<!WebInspector.RemoteObjectProperty>} internalProperties 883 * @param {?Array.<!SDK.RemoteObjectProperty>} internalProperties
884 * @this {WebInspector.ScopeRemoteObject} 884 * @this {SDK.ScopeRemoteObject}
885 */ 885 */
886 function wrappedCallback(properties, internalProperties) { 886 function wrappedCallback(properties, internalProperties) {
887 if (this._scopeRef && Array.isArray(properties)) { 887 if (this._scopeRef && Array.isArray(properties)) {
888 this._savedScopeProperties = properties.slice(); 888 this._savedScopeProperties = properties.slice();
889 if (!this._scopeRef.callFrameId) { 889 if (!this._scopeRef.callFrameId) {
890 for (var property of this._savedScopeProperties) 890 for (var property of this._savedScopeProperties)
891 property.writable = false; 891 property.writable = false;
892 } 892 }
893 } 893 }
894 callback(properties, internalProperties); 894 callback(properties, internalProperties);
895 } 895 }
896 896
897 // Scope objects always fetch preview. 897 // Scope objects always fetch preview.
898 generatePreview = true; 898 generatePreview = true;
899 899
900 super.doGetProperties(ownProperties, accessorPropertiesOnly, generatePreview , wrappedCallback.bind(this)); 900 super.doGetProperties(ownProperties, accessorPropertiesOnly, generatePreview , wrappedCallback.bind(this));
901 } 901 }
902 902
903 /** 903 /**
904 * @override 904 * @override
905 * @param {!Protocol.Runtime.RemoteObject} result 905 * @param {!Protocol.Runtime.RemoteObject} result
906 * @param {!Protocol.Runtime.CallArgument} argumentName 906 * @param {!Protocol.Runtime.CallArgument} argumentName
907 * @param {function(string=)} callback 907 * @param {function(string=)} callback
908 */ 908 */
909 doSetObjectPropertyValue(result, argumentName, callback) { 909 doSetObjectPropertyValue(result, argumentName, callback) {
910 var name = /** @type {string} */ (argumentName.value); 910 var name = /** @type {string} */ (argumentName.value);
911 this._debuggerModel.setVariableValue( 911 this._debuggerModel.setVariableValue(
912 this._scopeRef.number, name, WebInspector.RemoteObject.toCallArgument(re sult), this._scopeRef.callFrameId, 912 this._scopeRef.number, name, SDK.RemoteObject.toCallArgument(result), th is._scopeRef.callFrameId,
913 setVariableValueCallback.bind(this)); 913 setVariableValueCallback.bind(this));
914 914
915 /** 915 /**
916 * @param {string=} error 916 * @param {string=} error
917 * @this {WebInspector.ScopeRemoteObject} 917 * @this {SDK.ScopeRemoteObject}
918 */ 918 */
919 function setVariableValueCallback(error) { 919 function setVariableValueCallback(error) {
920 if (error) { 920 if (error) {
921 callback(error); 921 callback(error);
922 return; 922 return;
923 } 923 }
924 if (this._savedScopeProperties) { 924 if (this._savedScopeProperties) {
925 for (var i = 0; i < this._savedScopeProperties.length; i++) { 925 for (var i = 0; i < this._savedScopeProperties.length; i++) {
926 if (this._savedScopeProperties[i].name === name) 926 if (this._savedScopeProperties[i].name === name)
927 this._savedScopeProperties[i].value = this._target.runtimeModel.crea teRemoteObject(result); 927 this._savedScopeProperties[i].value = this._target.runtimeModel.crea teRemoteObject(result);
928 } 928 }
929 } 929 }
930 callback(); 930 callback();
931 } 931 }
932 } 932 }
933 }; 933 };
934 934
935 /** 935 /**
936 * @unrestricted 936 * @unrestricted
937 */ 937 */
938 WebInspector.ScopeRef = class { 938 SDK.ScopeRef = class {
939 /** 939 /**
940 * @param {number} number 940 * @param {number} number
941 * @param {string=} callFrameId 941 * @param {string=} callFrameId
942 */ 942 */
943 constructor(number, callFrameId) { 943 constructor(number, callFrameId) {
944 this.number = number; 944 this.number = number;
945 this.callFrameId = callFrameId; 945 this.callFrameId = callFrameId;
946 } 946 }
947 }; 947 };
948 948
949 /** 949 /**
950 * @unrestricted 950 * @unrestricted
951 */ 951 */
952 WebInspector.RemoteObjectProperty = class { 952 SDK.RemoteObjectProperty = class {
953 /** 953 /**
954 * @param {string} name 954 * @param {string} name
955 * @param {?WebInspector.RemoteObject} value 955 * @param {?SDK.RemoteObject} value
956 * @param {boolean=} enumerable 956 * @param {boolean=} enumerable
957 * @param {boolean=} writable 957 * @param {boolean=} writable
958 * @param {boolean=} isOwn 958 * @param {boolean=} isOwn
959 * @param {boolean=} wasThrown 959 * @param {boolean=} wasThrown
960 * @param {boolean=} synthetic 960 * @param {boolean=} synthetic
961 * @param {?WebInspector.RemoteObject=} symbol 961 * @param {?SDK.RemoteObject=} symbol
962 */ 962 */
963 constructor(name, value, enumerable, writable, isOwn, wasThrown, symbol, synth etic) { 963 constructor(name, value, enumerable, writable, isOwn, wasThrown, symbol, synth etic) {
964 this.name = name; 964 this.name = name;
965 if (value !== null) 965 if (value !== null)
966 this.value = value; 966 this.value = value;
967 this.enumerable = typeof enumerable !== 'undefined' ? enumerable : true; 967 this.enumerable = typeof enumerable !== 'undefined' ? enumerable : true;
968 this.writable = typeof writable !== 'undefined' ? writable : true; 968 this.writable = typeof writable !== 'undefined' ? writable : true;
969 this.isOwn = !!isOwn; 969 this.isOwn = !!isOwn;
970 this.wasThrown = !!wasThrown; 970 this.wasThrown = !!wasThrown;
971 if (symbol) 971 if (symbol)
(...skipping 11 matching lines...) Expand all
983 983
984 // Below is a wrapper around a local object that implements the RemoteObject int erface, 984 // Below is a wrapper around a local object that implements the RemoteObject int erface,
985 // which can be used by the UI code (primarily ObjectPropertiesSection). 985 // which can be used by the UI code (primarily ObjectPropertiesSection).
986 // Note that only JSON-compliant objects are currently supported, as there's no provision 986 // Note that only JSON-compliant objects are currently supported, as there's no provision
987 // for traversing prototypes, extracting class names via constructor, handling p roperties 987 // for traversing prototypes, extracting class names via constructor, handling p roperties
988 // or functions. 988 // or functions.
989 989
990 /** 990 /**
991 * @unrestricted 991 * @unrestricted
992 */ 992 */
993 WebInspector.LocalJSONObject = class extends WebInspector.RemoteObject { 993 SDK.LocalJSONObject = class extends SDK.RemoteObject {
994 /** 994 /**
995 * @param {*} value 995 * @param {*} value
996 */ 996 */
997 constructor(value) { 997 constructor(value) {
998 super(); 998 super();
999 this._value = value; 999 this._value = value;
1000 } 1000 }
1001 1001
1002 /** 1002 /**
1003 * @override 1003 * @override
1004 * @return {string} 1004 * @return {string}
1005 */ 1005 */
1006 get description() { 1006 get description() {
1007 if (this._cachedDescription) 1007 if (this._cachedDescription)
1008 return this._cachedDescription; 1008 return this._cachedDescription;
1009 1009
1010 /** 1010 /**
1011 * @param {!WebInspector.RemoteObjectProperty} property 1011 * @param {!SDK.RemoteObjectProperty} property
1012 * @return {string} 1012 * @return {string}
1013 * @this {WebInspector.LocalJSONObject} 1013 * @this {SDK.LocalJSONObject}
1014 */ 1014 */
1015 function formatArrayItem(property) { 1015 function formatArrayItem(property) {
1016 return this._formatValue(property.value); 1016 return this._formatValue(property.value);
1017 } 1017 }
1018 1018
1019 /** 1019 /**
1020 * @param {!WebInspector.RemoteObjectProperty} property 1020 * @param {!SDK.RemoteObjectProperty} property
1021 * @return {string} 1021 * @return {string}
1022 * @this {WebInspector.LocalJSONObject} 1022 * @this {SDK.LocalJSONObject}
1023 */ 1023 */
1024 function formatObjectItem(property) { 1024 function formatObjectItem(property) {
1025 var name = property.name; 1025 var name = property.name;
1026 if (/^\s|\s$|^$|\n/.test(name)) 1026 if (/^\s|\s$|^$|\n/.test(name))
1027 name = '"' + name.replace(/\n/g, '\u21B5') + '"'; 1027 name = '"' + name.replace(/\n/g, '\u21B5') + '"';
1028 return name + ': ' + this._formatValue(property.value); 1028 return name + ': ' + this._formatValue(property.value);
1029 } 1029 }
1030 1030
1031 if (this.type === 'object') { 1031 if (this.type === 'object') {
1032 switch (this.subtype) { 1032 switch (this.subtype) {
(...skipping 10 matching lines...) Expand all
1043 this._cachedDescription = this._concatenate('{', '}', formatObjectItem .bind(this)); 1043 this._cachedDescription = this._concatenate('{', '}', formatObjectItem .bind(this));
1044 } 1044 }
1045 } else { 1045 } else {
1046 this._cachedDescription = String(this._value); 1046 this._cachedDescription = String(this._value);
1047 } 1047 }
1048 1048
1049 return this._cachedDescription; 1049 return this._cachedDescription;
1050 } 1050 }
1051 1051
1052 /** 1052 /**
1053 * @param {?WebInspector.RemoteObject} value 1053 * @param {?SDK.RemoteObject} value
1054 * @return {string} 1054 * @return {string}
1055 */ 1055 */
1056 _formatValue(value) { 1056 _formatValue(value) {
1057 if (!value) 1057 if (!value)
1058 return 'undefined'; 1058 return 'undefined';
1059 var description = value.description || ''; 1059 var description = value.description || '';
1060 if (value.type === 'string') 1060 if (value.type === 'string')
1061 return '"' + description.replace(/\n/g, '\u21B5') + '"'; 1061 return '"' + description.replace(/\n/g, '\u21B5') + '"';
1062 return description; 1062 return description;
1063 } 1063 }
1064 1064
1065 /** 1065 /**
1066 * @param {string} prefix 1066 * @param {string} prefix
1067 * @param {string} suffix 1067 * @param {string} suffix
1068 * @param {function(!WebInspector.RemoteObjectProperty)} formatProperty 1068 * @param {function(!SDK.RemoteObjectProperty)} formatProperty
1069 * @return {string} 1069 * @return {string}
1070 */ 1070 */
1071 _concatenate(prefix, suffix, formatProperty) { 1071 _concatenate(prefix, suffix, formatProperty) {
1072 var previewChars = 100; 1072 var previewChars = 100;
1073 1073
1074 var buffer = prefix; 1074 var buffer = prefix;
1075 var children = this._children(); 1075 var children = this._children();
1076 for (var i = 0; i < children.length; ++i) { 1076 for (var i = 0; i < children.length; ++i) {
1077 var itemDescription = formatProperty(children[i]); 1077 var itemDescription = formatProperty(children[i]);
1078 if (buffer.length + itemDescription.length > previewChars) { 1078 if (buffer.length + itemDescription.length > previewChars) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 * @return {boolean} 1117 * @return {boolean}
1118 */ 1118 */
1119 get hasChildren() { 1119 get hasChildren() {
1120 if ((typeof this._value !== 'object') || (this._value === null)) 1120 if ((typeof this._value !== 'object') || (this._value === null))
1121 return false; 1121 return false;
1122 return !!Object.keys(/** @type {!Object} */ (this._value)).length; 1122 return !!Object.keys(/** @type {!Object} */ (this._value)).length;
1123 } 1123 }
1124 1124
1125 /** 1125 /**
1126 * @override 1126 * @override
1127 * @param {function(?Array.<!WebInspector.RemoteObjectProperty>, ?Array.<!WebI nspector.RemoteObjectProperty>)} callback 1127 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj ectProperty>)} callback
1128 */ 1128 */
1129 getOwnProperties(callback) { 1129 getOwnProperties(callback) {
1130 callback(this._children(), null); 1130 callback(this._children(), null);
1131 } 1131 }
1132 1132
1133 /** 1133 /**
1134 * @override 1134 * @override
1135 * @param {boolean} accessorPropertiesOnly 1135 * @param {boolean} accessorPropertiesOnly
1136 * @param {function(?Array.<!WebInspector.RemoteObjectProperty>, ?Array.<!WebI nspector.RemoteObjectProperty>)} callback 1136 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj ectProperty>)} callback
1137 */ 1137 */
1138 getAllProperties(accessorPropertiesOnly, callback) { 1138 getAllProperties(accessorPropertiesOnly, callback) {
1139 if (accessorPropertiesOnly) 1139 if (accessorPropertiesOnly)
1140 callback([], null); 1140 callback([], null);
1141 else 1141 else
1142 callback(this._children(), null); 1142 callback(this._children(), null);
1143 } 1143 }
1144 1144
1145 /** 1145 /**
1146 * @return {!Array.<!WebInspector.RemoteObjectProperty>} 1146 * @return {!Array.<!SDK.RemoteObjectProperty>}
1147 */ 1147 */
1148 _children() { 1148 _children() {
1149 if (!this.hasChildren) 1149 if (!this.hasChildren)
1150 return []; 1150 return [];
1151 var value = /** @type {!Object} */ (this._value); 1151 var value = /** @type {!Object} */ (this._value);
1152 1152
1153 /** 1153 /**
1154 * @param {string} propName 1154 * @param {string} propName
1155 * @return {!WebInspector.RemoteObjectProperty} 1155 * @return {!SDK.RemoteObjectProperty}
1156 */ 1156 */
1157 function buildProperty(propName) { 1157 function buildProperty(propName) {
1158 var propValue = value[propName]; 1158 var propValue = value[propName];
1159 if (!(propValue instanceof WebInspector.RemoteObject)) 1159 if (!(propValue instanceof SDK.RemoteObject))
1160 propValue = WebInspector.RemoteObject.fromLocalObject(propValue); 1160 propValue = SDK.RemoteObject.fromLocalObject(propValue);
1161 return new WebInspector.RemoteObjectProperty(propName, propValue); 1161 return new SDK.RemoteObjectProperty(propName, propValue);
1162 } 1162 }
1163 if (!this._cachedChildren) 1163 if (!this._cachedChildren)
1164 this._cachedChildren = Object.keys(value).map(buildProperty); 1164 this._cachedChildren = Object.keys(value).map(buildProperty);
1165 return this._cachedChildren; 1165 return this._cachedChildren;
1166 } 1166 }
1167 1167
1168 /** 1168 /**
1169 * @return {boolean} 1169 * @return {boolean}
1170 */ 1170 */
1171 isError() { 1171 isError() {
1172 return false; 1172 return false;
1173 } 1173 }
1174 1174
1175 /** 1175 /**
1176 * @override 1176 * @override
1177 * @return {number} 1177 * @return {number}
1178 */ 1178 */
1179 arrayLength() { 1179 arrayLength() {
1180 return Array.isArray(this._value) ? this._value.length : 0; 1180 return Array.isArray(this._value) ? this._value.length : 0;
1181 } 1181 }
1182 1182
1183 /** 1183 /**
1184 * @override 1184 * @override
1185 * @param {function(this:Object, ...)} functionDeclaration 1185 * @param {function(this:Object, ...)} functionDeclaration
1186 * @param {!Array.<!Protocol.Runtime.CallArgument>=} args 1186 * @param {!Array.<!Protocol.Runtime.CallArgument>=} args
1187 * @param {function(?WebInspector.RemoteObject, boolean=)=} callback 1187 * @param {function(?SDK.RemoteObject, boolean=)=} callback
1188 */ 1188 */
1189 callFunction(functionDeclaration, args, callback) { 1189 callFunction(functionDeclaration, args, callback) {
1190 var target = /** @type {?Object} */ (this._value); 1190 var target = /** @type {?Object} */ (this._value);
1191 var rawArgs = args ? args.map(function(arg) { 1191 var rawArgs = args ? args.map(function(arg) {
1192 return arg.value; 1192 return arg.value;
1193 }) : 1193 }) :
1194 []; 1194 [];
1195 1195
1196 var result; 1196 var result;
1197 var wasThrown = false; 1197 var wasThrown = false;
1198 try { 1198 try {
1199 result = functionDeclaration.apply(target, rawArgs); 1199 result = functionDeclaration.apply(target, rawArgs);
1200 } catch (e) { 1200 } catch (e) {
1201 wasThrown = true; 1201 wasThrown = true;
1202 } 1202 }
1203 1203
1204 if (!callback) 1204 if (!callback)
1205 return; 1205 return;
1206 callback(WebInspector.RemoteObject.fromLocalObject(result), wasThrown); 1206 callback(SDK.RemoteObject.fromLocalObject(result), wasThrown);
1207 } 1207 }
1208 1208
1209 /** 1209 /**
1210 * @override 1210 * @override
1211 * @param {function(this:Object)} functionDeclaration 1211 * @param {function(this:Object)} functionDeclaration
1212 * @param {!Array.<!Protocol.Runtime.CallArgument>|undefined} args 1212 * @param {!Array.<!Protocol.Runtime.CallArgument>|undefined} args
1213 * @param {function(*)} callback 1213 * @param {function(*)} callback
1214 */ 1214 */
1215 callFunctionJSON(functionDeclaration, args, callback) { 1215 callFunctionJSON(functionDeclaration, args, callback) {
1216 var target = /** @type {?Object} */ (this._value); 1216 var target = /** @type {?Object} */ (this._value);
1217 var rawArgs = args ? args.map(function(arg) { 1217 var rawArgs = args ? args.map(function(arg) {
1218 return arg.value; 1218 return arg.value;
1219 }) : 1219 }) :
1220 []; 1220 [];
1221 1221
1222 var result; 1222 var result;
1223 try { 1223 try {
1224 result = functionDeclaration.apply(target, rawArgs); 1224 result = functionDeclaration.apply(target, rawArgs);
1225 } catch (e) { 1225 } catch (e) {
1226 result = null; 1226 result = null;
1227 } 1227 }
1228 1228
1229 callback(result); 1229 callback(result);
1230 } 1230 }
1231 }; 1231 };
1232 1232
1233 /** 1233 /**
1234 * @unrestricted 1234 * @unrestricted
1235 */ 1235 */
1236 WebInspector.RemoteArray = class { 1236 SDK.RemoteArray = class {
1237 /** 1237 /**
1238 * @param {!WebInspector.RemoteObject} object 1238 * @param {!SDK.RemoteObject} object
1239 */ 1239 */
1240 constructor(object) { 1240 constructor(object) {
1241 this._object = object; 1241 this._object = object;
1242 } 1242 }
1243 1243
1244 /** 1244 /**
1245 * @param {?WebInspector.RemoteObject} object 1245 * @param {?SDK.RemoteObject} object
1246 * @return {!WebInspector.RemoteArray} 1246 * @return {!SDK.RemoteArray}
1247 */ 1247 */
1248 static objectAsArray(object) { 1248 static objectAsArray(object) {
1249 if (!object || object.type !== 'object' || (object.subtype !== 'array' && ob ject.subtype !== 'typedarray')) 1249 if (!object || object.type !== 'object' || (object.subtype !== 'array' && ob ject.subtype !== 'typedarray'))
1250 throw new Error('Object is empty or not an array'); 1250 throw new Error('Object is empty or not an array');
1251 return new WebInspector.RemoteArray(object); 1251 return new SDK.RemoteArray(object);
1252 } 1252 }
1253 1253
1254 /** 1254 /**
1255 * @param {!Array<!WebInspector.RemoteObject>} objects 1255 * @param {!Array<!SDK.RemoteObject>} objects
1256 * @return {!Promise<!WebInspector.RemoteArray>} 1256 * @return {!Promise<!SDK.RemoteArray>}
1257 */ 1257 */
1258 static createFromRemoteObjects(objects) { 1258 static createFromRemoteObjects(objects) {
1259 if (!objects.length) 1259 if (!objects.length)
1260 throw new Error('Input array is empty'); 1260 throw new Error('Input array is empty');
1261 var objectArguments = []; 1261 var objectArguments = [];
1262 for (var i = 0; i < objects.length; ++i) 1262 for (var i = 0; i < objects.length; ++i)
1263 objectArguments.push(WebInspector.RemoteObject.toCallArgument(objects[i])) ; 1263 objectArguments.push(SDK.RemoteObject.toCallArgument(objects[i]));
1264 return objects[0].callFunctionPromise(createArray, objectArguments).then(ret urnRemoteArray); 1264 return objects[0].callFunctionPromise(createArray, objectArguments).then(ret urnRemoteArray);
1265 1265
1266 /** 1266 /**
1267 * @return {!Array<*>} 1267 * @return {!Array<*>}
1268 */ 1268 */
1269 function createArray() { 1269 function createArray() {
1270 if (arguments.length > 1) 1270 if (arguments.length > 1)
1271 return new Array(arguments); 1271 return new Array(arguments);
1272 return [arguments[0]]; 1272 return [arguments[0]];
1273 } 1273 }
1274 1274
1275 /** 1275 /**
1276 * @param {!WebInspector.CallFunctionResult} result 1276 * @param {!SDK.CallFunctionResult} result
1277 * @return {!WebInspector.RemoteArray} 1277 * @return {!SDK.RemoteArray}
1278 */ 1278 */
1279 function returnRemoteArray(result) { 1279 function returnRemoteArray(result) {
1280 if (result.wasThrown || !result.object) 1280 if (result.wasThrown || !result.object)
1281 throw new Error('Call function throws exceptions or returns empty value' ); 1281 throw new Error('Call function throws exceptions or returns empty value' );
1282 return WebInspector.RemoteArray.objectAsArray(result.object); 1282 return SDK.RemoteArray.objectAsArray(result.object);
1283 } 1283 }
1284 } 1284 }
1285 1285
1286 /** 1286 /**
1287 * @param {number} index 1287 * @param {number} index
1288 * @return {!Promise<!WebInspector.RemoteObject>} 1288 * @return {!Promise<!SDK.RemoteObject>}
1289 */ 1289 */
1290 at(index) { 1290 at(index) {
1291 if (index < 0 || index > this._object.arrayLength()) 1291 if (index < 0 || index > this._object.arrayLength())
1292 throw new Error('Out of range'); 1292 throw new Error('Out of range');
1293 return this._object.callFunctionPromise(at, [WebInspector.RemoteObject.toCal lArgument(index)]) 1293 return this._object.callFunctionPromise(at, [SDK.RemoteObject.toCallArgument (index)])
1294 .then(assertCallFunctionResult); 1294 .then(assertCallFunctionResult);
1295 1295
1296 /** 1296 /**
1297 * @suppressReceiverCheck 1297 * @suppressReceiverCheck
1298 * @param {number} index 1298 * @param {number} index
1299 * @return {*} 1299 * @return {*}
1300 * @this {!Object} 1300 * @this {!Object}
1301 */ 1301 */
1302 function at(index) { 1302 function at(index) {
1303 return this[index]; 1303 return this[index];
1304 } 1304 }
1305 1305
1306 /** 1306 /**
1307 * @param {!WebInspector.CallFunctionResult} result 1307 * @param {!SDK.CallFunctionResult} result
1308 * @return {!WebInspector.RemoteObject} 1308 * @return {!SDK.RemoteObject}
1309 */ 1309 */
1310 function assertCallFunctionResult(result) { 1310 function assertCallFunctionResult(result) {
1311 if (result.wasThrown || !result.object) 1311 if (result.wasThrown || !result.object)
1312 throw new Error('Exception in callFunction or result value is empty'); 1312 throw new Error('Exception in callFunction or result value is empty');
1313 return result.object; 1313 return result.object;
1314 } 1314 }
1315 } 1315 }
1316 1316
1317 /** 1317 /**
1318 * @return {number} 1318 * @return {number}
1319 */ 1319 */
1320 length() { 1320 length() {
1321 return this._object.arrayLength(); 1321 return this._object.arrayLength();
1322 } 1322 }
1323 1323
1324 /** 1324 /**
1325 * @param {function(!WebInspector.RemoteObject):!Promise<T>} func 1325 * @param {function(!SDK.RemoteObject):!Promise<T>} func
1326 * @return {!Promise<!Array<T>>} 1326 * @return {!Promise<!Array<T>>}
1327 * @template T 1327 * @template T
1328 */ 1328 */
1329 map(func) { 1329 map(func) {
1330 var promises = []; 1330 var promises = [];
1331 for (var i = 0; i < this.length(); ++i) 1331 for (var i = 0; i < this.length(); ++i)
1332 promises.push(this.at(i).then(func)); 1332 promises.push(this.at(i).then(func));
1333 return Promise.all(promises); 1333 return Promise.all(promises);
1334 } 1334 }
1335 1335
1336 /** 1336 /**
1337 * @return {!WebInspector.RemoteObject} 1337 * @return {!SDK.RemoteObject}
1338 */ 1338 */
1339 object() { 1339 object() {
1340 return this._object; 1340 return this._object;
1341 } 1341 }
1342 }; 1342 };
1343 1343
1344 1344
1345 /** 1345 /**
1346 * @unrestricted 1346 * @unrestricted
1347 */ 1347 */
1348 WebInspector.RemoteFunction = class { 1348 SDK.RemoteFunction = class {
1349 /** 1349 /**
1350 * @param {!WebInspector.RemoteObject} object 1350 * @param {!SDK.RemoteObject} object
1351 */ 1351 */
1352 constructor(object) { 1352 constructor(object) {
1353 this._object = object; 1353 this._object = object;
1354 } 1354 }
1355 1355
1356 /** 1356 /**
1357 * @param {?WebInspector.RemoteObject} object 1357 * @param {?SDK.RemoteObject} object
1358 * @return {!WebInspector.RemoteFunction} 1358 * @return {!SDK.RemoteFunction}
1359 */ 1359 */
1360 static objectAsFunction(object) { 1360 static objectAsFunction(object) {
1361 if (!object || object.type !== 'function') 1361 if (!object || object.type !== 'function')
1362 throw new Error('Object is empty or not a function'); 1362 throw new Error('Object is empty or not a function');
1363 return new WebInspector.RemoteFunction(object); 1363 return new SDK.RemoteFunction(object);
1364 } 1364 }
1365 1365
1366 /** 1366 /**
1367 * @return {!Promise<!WebInspector.RemoteObject>} 1367 * @return {!Promise<!SDK.RemoteObject>}
1368 */ 1368 */
1369 targetFunction() { 1369 targetFunction() {
1370 return this._object.getOwnPropertiesPromise().then(targetFunction.bind(this) ); 1370 return this._object.getOwnPropertiesPromise().then(targetFunction.bind(this) );
1371 1371
1372 /** 1372 /**
1373 * @param {!{properties: ?Array<!WebInspector.RemoteObjectProperty>, interna lProperties: ?Array<!WebInspector.RemoteObjectProperty>}} ownProperties 1373 * @param {!{properties: ?Array<!SDK.RemoteObjectProperty>, internalProperti es: ?Array<!SDK.RemoteObjectProperty>}} ownProperties
1374 * @return {!WebInspector.RemoteObject} 1374 * @return {!SDK.RemoteObject}
1375 * @this {WebInspector.RemoteFunction} 1375 * @this {SDK.RemoteFunction}
1376 */ 1376 */
1377 function targetFunction(ownProperties) { 1377 function targetFunction(ownProperties) {
1378 if (!ownProperties.internalProperties) 1378 if (!ownProperties.internalProperties)
1379 return this._object; 1379 return this._object;
1380 var internalProperties = ownProperties.internalProperties; 1380 var internalProperties = ownProperties.internalProperties;
1381 for (var property of internalProperties) { 1381 for (var property of internalProperties) {
1382 if (property.name === '[[TargetFunction]]') 1382 if (property.name === '[[TargetFunction]]')
1383 return property.value; 1383 return property.value;
1384 } 1384 }
1385 return this._object; 1385 return this._object;
1386 } 1386 }
1387 } 1387 }
1388 1388
1389 /** 1389 /**
1390 * @return {!Promise<?WebInspector.DebuggerModel.FunctionDetails>} 1390 * @return {!Promise<?SDK.DebuggerModel.FunctionDetails>}
1391 */ 1391 */
1392 targetFunctionDetails() { 1392 targetFunctionDetails() {
1393 return this.targetFunction().then(functionDetails.bind(this)); 1393 return this.targetFunction().then(functionDetails.bind(this));
1394 1394
1395 /** 1395 /**
1396 * @param {!WebInspector.RemoteObject} targetFunction 1396 * @param {!SDK.RemoteObject} targetFunction
1397 * @return {!Promise<?WebInspector.DebuggerModel.FunctionDetails>} 1397 * @return {!Promise<?SDK.DebuggerModel.FunctionDetails>}
1398 * @this {WebInspector.RemoteFunction} 1398 * @this {SDK.RemoteFunction}
1399 */ 1399 */
1400 function functionDetails(targetFunction) { 1400 function functionDetails(targetFunction) {
1401 var boundReleaseFunctionDetails = 1401 var boundReleaseFunctionDetails =
1402 releaseTargetFunction.bind(null, this._object !== targetFunction ? tar getFunction : null); 1402 releaseTargetFunction.bind(null, this._object !== targetFunction ? tar getFunction : null);
1403 return targetFunction.debuggerModel().functionDetailsPromise(targetFunctio n).then(boundReleaseFunctionDetails); 1403 return targetFunction.debuggerModel().functionDetailsPromise(targetFunctio n).then(boundReleaseFunctionDetails);
1404 } 1404 }
1405 1405
1406 /** 1406 /**
1407 * @param {?WebInspector.RemoteObject} targetFunction 1407 * @param {?SDK.RemoteObject} targetFunction
1408 * @param {?WebInspector.DebuggerModel.FunctionDetails} functionDetails 1408 * @param {?SDK.DebuggerModel.FunctionDetails} functionDetails
1409 * @return {?WebInspector.DebuggerModel.FunctionDetails} 1409 * @return {?SDK.DebuggerModel.FunctionDetails}
1410 */ 1410 */
1411 function releaseTargetFunction(targetFunction, functionDetails) { 1411 function releaseTargetFunction(targetFunction, functionDetails) {
1412 if (targetFunction) 1412 if (targetFunction)
1413 targetFunction.release(); 1413 targetFunction.release();
1414 return functionDetails; 1414 return functionDetails;
1415 } 1415 }
1416 } 1416 }
1417 1417
1418 /** 1418 /**
1419 * @return {!WebInspector.RemoteObject} 1419 * @return {!SDK.RemoteObject}
1420 */ 1420 */
1421 object() { 1421 object() {
1422 return this._object; 1422 return this._object;
1423 } 1423 }
1424 }; 1424 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698