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

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

Issue 2752403002: [DevTools] Migrate usages of Target to RuntimeModel where makes sense (Closed)
Patch Set: review comments addressed Created 3 years, 9 months 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 14 matching lines...) Expand all
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: ?SDK.RemoteObject, wasThrown: (boolean|undefined)}} 31 * @typedef {{object: ?SDK.RemoteObject, wasThrown: (boolean|undefined)}}
32 */ 32 */
33 SDK.CallFunctionResult; 33 SDK.CallFunctionResult;
34 34
35 /**
36 * @unrestricted
37 */
38 SDK.RemoteObject = class { 35 SDK.RemoteObject = class {
39 /** 36 /**
40 * This may not be an interface due to "instanceof SDK.RemoteObject" checks in the code. 37 * This may not be an interface due to "instanceof SDK.RemoteObject" checks in the code.
41 */ 38 */
42 39
43 /** 40 /**
44 * @param {*} value 41 * @param {*} value
45 * @return {!SDK.RemoteObject} 42 * @return {!SDK.RemoteObject}
46 */ 43 */
47 static fromLocalObject(value) { 44 static fromLocalObject(value) {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 return {value: object}; 117 return {value: object};
121 } 118 }
122 if (type === 'string' || type === 'boolean') 119 if (type === 'string' || type === 'boolean')
123 return {value: object}; 120 return {value: object};
124 121
125 if (!object) 122 if (!object)
126 return {value: null}; 123 return {value: null};
127 124
128 if (typeof object.unserializableValue !== 'undefined') 125 if (typeof object.unserializableValue !== 'undefined')
129 return {unserializableValue: object.unserializableValue}; 126 return {unserializableValue: object.unserializableValue};
130 if (typeof object._unserializableValue !== 'undefined') 127 if (object instanceof SDK.RemoteObjectImpl && typeof object._unserializableV alue !== 'undefined')
131 return {unserializableValue: object._unserializableValue}; 128 return {unserializableValue: object._unserializableValue};
132 129
133 if (typeof object.objectId !== 'undefined') 130 if (typeof object.objectId !== 'undefined')
134 return {objectId: object.objectId}; 131 return {objectId: object.objectId};
135 if (typeof object._objectId !== 'undefined')
136 return {objectId: object._objectId};
137 132
138 return {value: object.value}; 133 return {value: object.value};
139 } 134 }
140 135
141 /** 136 /**
142 * @param {!SDK.RemoteObject} object 137 * @param {!SDK.RemoteObject} object
143 * @param {boolean} generatePreview 138 * @param {boolean} generatePreview
144 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj ectProperty>)} callback 139 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj ectProperty>)} callback
145 */ 140 */
146 static loadFromObjectPerProto(object, generatePreview, callback) { 141 static loadFromObjectPerProto(object, generatePreview, callback) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 object.getOwnProperties(generatePreview, ownPropertiesCallback); 198 object.getOwnProperties(generatePreview, ownPropertiesCallback);
204 } 199 }
205 200
206 /** 201 /**
207 * @return {?Protocol.Runtime.CustomPreview} 202 * @return {?Protocol.Runtime.CustomPreview}
208 */ 203 */
209 customPreview() { 204 customPreview() {
210 return null; 205 return null;
211 } 206 }
212 207
208 /** @return {!Protocol.Runtime.RemoteObjectId|undefined} */
209 get objectId() {
210 return 'Not implemented';
211 }
212
213 /** @return {string} */ 213 /** @return {string} */
214 get type() { 214 get type() {
215 throw 'Not implemented'; 215 throw 'Not implemented';
216 } 216 }
217 217
218 /** @return {string|undefined} */ 218 /** @return {string|undefined} */
219 get subtype() { 219 get subtype() {
220 throw 'Not implemented'; 220 throw 'Not implemented';
221 } 221 }
222 222
223 /** @return {*} */
224 get value() {
225 throw 'Not implemented';
226 }
227
223 /** @return {string|undefined} */ 228 /** @return {string|undefined} */
224 get description() { 229 get description() {
225 throw 'Not implemented'; 230 throw 'Not implemented';
226 } 231 }
227 232
228 /** @return {boolean} */ 233 /** @return {boolean} */
229 get hasChildren() { 234 get hasChildren() {
230 throw 'Not implemented'; 235 throw 'Not implemented';
231 } 236 }
232 237
233 /** 238 /**
239 * @return {!Protocol.Runtime.ObjectPreview|undefined}
240 */
241 get preview() {
242 return undefined;
243 }
244
245 /**
234 * @return {number} 246 * @return {number}
235 */ 247 */
236 arrayLength() { 248 arrayLength() {
237 throw 'Not implemented'; 249 throw 'Not implemented';
238 } 250 }
239 251
240 /** 252 /**
241 * @param {boolean} generatePreview 253 * @param {boolean} generatePreview
242 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj ectProperty>)} callback 254 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj ectProperty>)} callback
243 */ 255 */
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 * @param {function(!{properties: ?Array<!SDK.RemoteObjectProperty>, interna lProperties: ?Array<!SDK.RemoteObjectProperty>})} callback 311 * @param {function(!{properties: ?Array<!SDK.RemoteObjectProperty>, interna lProperties: ?Array<!SDK.RemoteObjectProperty>})} callback
300 * @param {?Array<!SDK.RemoteObjectProperty>} properties 312 * @param {?Array<!SDK.RemoteObjectProperty>} properties
301 * @param {?Array<!SDK.RemoteObjectProperty>} internalProperties 313 * @param {?Array<!SDK.RemoteObjectProperty>} internalProperties
302 */ 314 */
303 function getAllPropertiesCallback(callback, properties, internalProperties) { 315 function getAllPropertiesCallback(callback, properties, internalProperties) {
304 callback({properties: properties, internalProperties: internalProperties}) ; 316 callback({properties: properties, internalProperties: internalProperties}) ;
305 } 317 }
306 } 318 }
307 319
308 /** 320 /**
321 * @param {!Array.<string>} propertyPath
322 * @param {function(?SDK.RemoteObject, boolean=)} callback
323 */
324 getProperty(propertyPath, callback) {
325 throw 'Not implemented';
326 }
327
328 /**
309 * @return {!Promise<?Array<!SDK.EventListener>>} 329 * @return {!Promise<?Array<!SDK.EventListener>>}
310 */ 330 */
311 eventListeners() { 331 eventListeners() {
312 throw 'Not implemented'; 332 throw 'Not implemented';
313 } 333 }
314 334
315 /** 335 /**
316 * @param {!Protocol.Runtime.CallArgument} name 336 * @param {!Protocol.Runtime.CallArgument} name
317 * @param {function(string=)} callback 337 * @param {function(string=)} callback
318 */ 338 */
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 return new Promise(promiseConstructor.bind(this)); 404 return new Promise(promiseConstructor.bind(this));
385 405
386 /** 406 /**
387 * @this {SDK.RemoteObject} 407 * @this {SDK.RemoteObject}
388 */ 408 */
389 function promiseConstructor(success) { 409 function promiseConstructor(success) {
390 this.callFunctionJSON(functionDeclaration, args, success); 410 this.callFunctionJSON(functionDeclaration, args, success);
391 } 411 }
392 } 412 }
393 413
394 /** 414 release() {
395 * @return {!SDK.Target}
396 */
397 target() {
398 throw new Error('Target-less object');
399 } 415 }
400 416
401 /** 417 /**
402 * @return {?SDK.DebuggerModel} 418 * @return {!SDK.DebuggerModel}
403 */ 419 */
404 debuggerModel() { 420 debuggerModel() {
405 throw new Error('DebuggerModel-less object'); 421 throw new Error('DebuggerModel-less object');
406 } 422 }
407 423
408 /** 424 /**
425 * @return {!SDK.RuntimeModel}
426 */
427 runtimeModel() {
428 throw new Error('RuntimeModel-less object');
429 }
430
431 /**
409 * @return {boolean} 432 * @return {boolean}
410 */ 433 */
411 isNode() { 434 isNode() {
412 return false; 435 return false;
413 } 436 }
414 }; 437 };
415 438
416 439
417 /**
418 * @unrestricted
419 */
420 SDK.RemoteObjectImpl = class extends SDK.RemoteObject { 440 SDK.RemoteObjectImpl = class extends SDK.RemoteObject {
421 /** 441 /**
422 * @param {!SDK.Target} target 442 * @param {!SDK.RuntimeModel} runtimeModel
423 * @param {string|undefined} objectId 443 * @param {string|undefined} objectId
424 * @param {string} type 444 * @param {string} type
425 * @param {string|undefined} subtype 445 * @param {string|undefined} subtype
426 * @param {*} value 446 * @param {*} value
427 * @param {!Protocol.Runtime.UnserializableValue=} unserializableValue 447 * @param {!Protocol.Runtime.UnserializableValue=} unserializableValue
428 * @param {string=} description 448 * @param {string=} description
429 * @param {!Protocol.Runtime.ObjectPreview=} preview 449 * @param {!Protocol.Runtime.ObjectPreview=} preview
430 * @param {!Protocol.Runtime.CustomPreview=} customPreview 450 * @param {!Protocol.Runtime.CustomPreview=} customPreview
431 */ 451 */
432 constructor(target, objectId, type, subtype, value, unserializableValue, descr iption, preview, customPreview) { 452 constructor(runtimeModel, objectId, type, subtype, value, unserializableValue, description, preview, customPreview) {
433 super(); 453 super();
434 454
435 this._target = target; 455 this._runtimeModel = runtimeModel;
436 this._runtimeAgent = target.runtimeAgent(); 456 this._runtimeAgent = runtimeModel.target().runtimeAgent();
437 this._debuggerModel = SDK.DebuggerModel.fromTarget(target);
438 457
439 this._type = type; 458 this._type = type;
440 this._subtype = subtype; 459 this._subtype = subtype;
441 if (objectId) { 460 if (objectId) {
442 // handle 461 // handle
443 this._objectId = objectId; 462 this._objectId = objectId;
444 this._description = description; 463 this._description = description;
445 this._hasChildren = (type !== 'symbol'); 464 this._hasChildren = (type !== 'symbol');
446 this._preview = preview; 465 this._preview = preview;
447 } else { 466 } else {
448 this._description = description; 467 this._description = description;
449 if (!this._description && (typeof value !== 'object' || value === null)) 468 if (!this._description && (typeof value !== 'object' || value === null))
450 this._description = value + ''; 469 this._description = value + '';
451 this._hasChildren = false; 470 this._hasChildren = false;
452 if (typeof unserializableValue !== 'undefined') { 471 if (typeof unserializableValue !== 'undefined') {
453 this._unserializableValue = unserializableValue; 472 this._unserializableValue = unserializableValue;
454 if (unserializableValue === Protocol.Runtime.UnserializableValue.Infinit y || 473 if (unserializableValue === Protocol.Runtime.UnserializableValue.Infinit y ||
455 unserializableValue === Protocol.Runtime.UnserializableValue.Negativ eInfinity || 474 unserializableValue === Protocol.Runtime.UnserializableValue.Negativ eInfinity ||
456 unserializableValue === Protocol.Runtime.UnserializableValue.Negativ e0 || 475 unserializableValue === Protocol.Runtime.UnserializableValue.Negativ e0 ||
457 unserializableValue === Protocol.Runtime.UnserializableValue.NaN) 476 unserializableValue === Protocol.Runtime.UnserializableValue.NaN)
458 this.value = Number(unserializableValue); 477 this._value = Number(unserializableValue);
459 else 478 else
460 this.value = unserializableValue; 479 this._value = unserializableValue;
461 480
462 } else { 481 } else {
463 this.value = value; 482 this._value = value;
464 } 483 }
465 } 484 }
466 this._customPreview = customPreview || null; 485 this._customPreview = customPreview || null;
467 } 486 }
468 487
469 /** 488 /**
470 * @override 489 * @override
471 * @return {?Protocol.Runtime.CustomPreview} 490 * @return {?Protocol.Runtime.CustomPreview}
472 */ 491 */
473 customPreview() { 492 customPreview() {
474 return this._customPreview; 493 return this._customPreview;
475 } 494 }
476 495
477 /** @return {!Protocol.Runtime.RemoteObjectId} */ 496 /**
497 * @override
498 * @return {!Protocol.Runtime.RemoteObjectId|undefined}
499 */
478 get objectId() { 500 get objectId() {
479 return this._objectId; 501 return this._objectId;
480 } 502 }
481 503
482 /** 504 /**
483 * @override 505 * @override
484 * @return {string} 506 * @return {string}
485 */ 507 */
486 get type() { 508 get type() {
487 return this._type; 509 return this._type;
488 } 510 }
489 511
490 /** 512 /**
491 * @override 513 * @override
492 * @return {string|undefined} 514 * @return {string|undefined}
493 */ 515 */
494 get subtype() { 516 get subtype() {
495 return this._subtype; 517 return this._subtype;
496 } 518 }
497 519
498 /** 520 /**
499 * @override 521 * @override
522 * @return {*}
523 */
524 get value() {
525 return this._value;
526 }
527
528 /**
529 * @override
500 * @return {string|undefined} 530 * @return {string|undefined}
501 */ 531 */
502 get description() { 532 get description() {
503 return this._description; 533 return this._description;
504 } 534 }
505 535
506 /** 536 /**
507 * @override 537 * @override
508 * @return {boolean} 538 * @return {boolean}
509 */ 539 */
510 get hasChildren() { 540 get hasChildren() {
511 return this._hasChildren; 541 return this._hasChildren;
512 } 542 }
513 543
514 /** 544 /**
545 * @override
515 * @return {!Protocol.Runtime.ObjectPreview|undefined} 546 * @return {!Protocol.Runtime.ObjectPreview|undefined}
516 */ 547 */
517 get preview() { 548 get preview() {
518 return this._preview; 549 return this._preview;
519 } 550 }
520 551
521 /** 552 /**
522 * @override 553 * @override
523 * @param {boolean} generatePreview 554 * @param {boolean} generatePreview
524 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj ectProperty>)} callback 555 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj ectProperty>)} callback
(...skipping 17 matching lines...) Expand all
542 * @return {!Promise<?Array<!SDK.EventListener>>} 573 * @return {!Promise<?Array<!SDK.EventListener>>}
543 */ 574 */
544 eventListeners() { 575 eventListeners() {
545 return new Promise(eventListeners.bind(this)); 576 return new Promise(eventListeners.bind(this));
546 /** 577 /**
547 * @param {function(?)} fulfill 578 * @param {function(?)} fulfill
548 * @param {function(*)} reject 579 * @param {function(*)} reject
549 * @this {SDK.RemoteObjectImpl} 580 * @this {SDK.RemoteObjectImpl}
550 */ 581 */
551 function eventListeners(fulfill, reject) { 582 function eventListeners(fulfill, reject) {
552 if (!this.target().hasDOMCapability()) { 583 if (!this._runtimeModel.target().hasDOMCapability()) {
553 // TODO(kozyatinskiy): figure out how this should work for |window| when there is no DOMDebugger. 584 // TODO(kozyatinskiy): figure out how this should work for |window| when there is no DOMDebugger.
554 fulfill([]); 585 fulfill([]);
555 return; 586 return;
556 } 587 }
557 588
558 if (!this._objectId) { 589 if (!this._objectId) {
559 reject(new Error('No object id specified')); 590 reject(new Error('No object id specified'));
560 return; 591 return;
561 } 592 }
562 593
563 this.target().domdebuggerAgent().getEventListeners(this._objectId, undefin ed, undefined, mycallback.bind(this)); 594 this._runtimeModel.target().domdebuggerAgent().getEventListeners(
595 this._objectId, undefined, undefined, mycallback.bind(this));
564 596
565 /** 597 /**
566 * @this {SDK.RemoteObjectImpl} 598 * @this {SDK.RemoteObjectImpl}
567 * @param {?Protocol.Error} error 599 * @param {?Protocol.Error} error
568 * @param {!Array<!Protocol.DOMDebugger.EventListener>} payloads 600 * @param {!Array<!Protocol.DOMDebugger.EventListener>} payloads
569 */ 601 */
570 function mycallback(error, payloads) { 602 function mycallback(error, payloads) {
571 if (error) { 603 if (error) {
572 reject(new Error(error)); 604 reject(new Error(error));
573 return; 605 return;
574 } 606 }
575 fulfill(payloads.map(createEventListener.bind(this))); 607 fulfill(payloads.map(createEventListener.bind(this)));
576 } 608 }
577 609
578 /** 610 /**
579 * @this {SDK.RemoteObjectImpl} 611 * @this {SDK.RemoteObjectImpl}
580 * @param {!Protocol.DOMDebugger.EventListener} payload 612 * @param {!Protocol.DOMDebugger.EventListener} payload
581 */ 613 */
582 function createEventListener(payload) { 614 function createEventListener(payload) {
583 return new SDK.EventListener( 615 return new SDK.EventListener(
584 this._target, this, payload.type, payload.useCapture, payload.passiv e, payload.once, 616 this._runtimeModel, this, payload.type, payload.useCapture, payload. passive, payload.once,
585 payload.handler ? this.target().runtimeModel.createRemoteObject(payl oad.handler) : null, 617 payload.handler ? this._runtimeModel.createRemoteObject(payload.hand ler) : null,
586 payload.originalHandler ? this.target().runtimeModel.createRemoteObj ect(payload.originalHandler) : null, 618 payload.originalHandler ? this._runtimeModel.createRemoteObject(payl oad.originalHandler) : null,
587 /** @type {!SDK.DebuggerModel.Location} */ (this._debuggerModel.crea teRawLocationByScriptId( 619 /** @type {!SDK.DebuggerModel.Location} */
620 (this.debuggerModel().createRawLocationByScriptId(
588 payload.scriptId, payload.lineNumber, payload.columnNumber)), 621 payload.scriptId, payload.lineNumber, payload.columnNumber)),
589 null); 622 null);
590 } 623 }
591 } 624 }
592 } 625 }
593 626
594 /** 627 /**
628 * @override
595 * @param {!Array.<string>} propertyPath 629 * @param {!Array.<string>} propertyPath
596 * @param {function(?SDK.RemoteObject, boolean=)} callback 630 * @param {function(?SDK.RemoteObject, boolean=)} callback
597 */ 631 */
598 getProperty(propertyPath, callback) { 632 getProperty(propertyPath, callback) {
599 /** 633 /**
600 * @param {string} arrayStr 634 * @param {string} arrayStr
601 * @suppressReceiverCheck 635 * @suppressReceiverCheck
602 * @this {Object} 636 * @this {Object}
603 */ 637 */
604 function remoteFunction(arrayStr) { 638 function remoteFunction(arrayStr) {
(...skipping 26 matching lines...) Expand all
631 * @param {!Array.<!Protocol.Runtime.InternalPropertyDescriptor>=} internalP roperties 665 * @param {!Array.<!Protocol.Runtime.InternalPropertyDescriptor>=} internalP roperties
632 * @param {?Protocol.Runtime.ExceptionDetails=} exceptionDetails 666 * @param {?Protocol.Runtime.ExceptionDetails=} exceptionDetails
633 * @this {SDK.RemoteObjectImpl} 667 * @this {SDK.RemoteObjectImpl}
634 */ 668 */
635 function remoteObjectBinder(error, properties, internalProperties, exception Details) { 669 function remoteObjectBinder(error, properties, internalProperties, exception Details) {
636 if (error) { 670 if (error) {
637 callback(null, null); 671 callback(null, null);
638 return; 672 return;
639 } 673 }
640 if (exceptionDetails) { 674 if (exceptionDetails) {
641 this.target().runtimeModel.exceptionThrown(Date.now(), exceptionDetails) ; 675 this._runtimeModel.exceptionThrown(Date.now(), exceptionDetails);
642 callback(null, null); 676 callback(null, null);
643 return; 677 return;
644 } 678 }
645 var result = []; 679 var result = [];
646 for (var i = 0; properties && i < properties.length; ++i) { 680 for (var i = 0; properties && i < properties.length; ++i) {
647 var property = properties[i]; 681 var property = properties[i];
648 var propertyValue = property.value ? this._target.runtimeModel.createRem oteObject(property.value) : null; 682 var propertyValue = property.value ? this._runtimeModel.createRemoteObje ct(property.value) : null;
649 var propertySymbol = property.symbol ? this._target.runtimeModel.createR emoteObject(property.symbol) : null; 683 var propertySymbol = property.symbol ? this._runtimeModel.createRemoteOb ject(property.symbol) : null;
650 var remoteProperty = new SDK.RemoteObjectProperty( 684 var remoteProperty = new SDK.RemoteObjectProperty(
651 property.name, propertyValue, !!property.enumerable, !!property.writ able, !!property.isOwn, 685 property.name, propertyValue, !!property.enumerable, !!property.writ able, !!property.isOwn,
652 !!property.wasThrown, propertySymbol); 686 !!property.wasThrown, propertySymbol);
653 687
654 if (typeof property.value === 'undefined') { 688 if (typeof property.value === 'undefined') {
655 if (property.get && property.get.type !== 'undefined') 689 if (property.get && property.get.type !== 'undefined')
656 remoteProperty.getter = this._target.runtimeModel.createRemoteObject (property.get); 690 remoteProperty.getter = this._runtimeModel.createRemoteObject(proper ty.get);
657 if (property.set && property.set.type !== 'undefined') 691 if (property.set && property.set.type !== 'undefined')
658 remoteProperty.setter = this._target.runtimeModel.createRemoteObject (property.set); 692 remoteProperty.setter = this._runtimeModel.createRemoteObject(proper ty.set);
659 } 693 }
660 694
661 result.push(remoteProperty); 695 result.push(remoteProperty);
662 } 696 }
663 var internalPropertiesResult = null; 697 var internalPropertiesResult = null;
664 if (internalProperties) { 698 if (internalProperties) {
665 internalPropertiesResult = []; 699 internalPropertiesResult = [];
666 for (var i = 0; i < internalProperties.length; i++) { 700 for (var i = 0; i < internalProperties.length; i++) {
667 var property = internalProperties[i]; 701 var property = internalProperties[i];
668 if (!property.value) 702 if (!property.value)
669 continue; 703 continue;
670 var propertyValue = this._target.runtimeModel.createRemoteObject(prope rty.value); 704 var propertyValue = this._runtimeModel.createRemoteObject(property.val ue);
671 internalPropertiesResult.push(new SDK.RemoteObjectProperty(property.na me, propertyValue, true, false)); 705 internalPropertiesResult.push(new SDK.RemoteObjectProperty(property.na me, propertyValue, true, false));
672 } 706 }
673 } 707 }
674 callback(result, internalPropertiesResult); 708 callback(result, internalPropertiesResult);
675 } 709 }
676 this._runtimeAgent.getProperties( 710 this._runtimeAgent.getProperties(
677 this._objectId, ownProperties, accessorPropertiesOnly, generatePreview, remoteObjectBinder.bind(this)); 711 this._objectId, ownProperties, accessorPropertiesOnly, generatePreview, remoteObjectBinder.bind(this));
678 } 712 }
679 713
680 /** 714 /**
681 * @override 715 * @override
682 * @param {string|!Protocol.Runtime.CallArgument} name 716 * @param {string|!Protocol.Runtime.CallArgument} name
683 * @param {string} value 717 * @param {string} value
684 * @param {function(string=)} callback 718 * @param {function(string=)} callback
685 */ 719 */
686 setPropertyValue(name, value, callback) { 720 setPropertyValue(name, value, callback) {
687 if (!this._objectId) { 721 if (!this._objectId) {
688 callback('Can\'t set a property of non-object.'); 722 callback('Can\'t set a property of non-object.');
689 return; 723 return;
690 } 724 }
691 725
692 this._runtimeAgent.invoke_evaluate({expression: value, silent: true}, evalua tedCallback.bind(this)); 726 this._runtimeAgent.invoke_evaluate({expression: value, silent: true}, evalua tedCallback.bind(this));
693 727
694 /** 728 /**
695 * @param {?Protocol.Error} error 729 * @param {?Protocol.Error} error
696 * @param {!Protocol.Runtime.RemoteObject} result 730 * @param {!Protocol.Runtime.RemoteObject} result
697 * @param {!Protocol.Runtime.ExceptionDetails=} exceptionDetails 731 * @param {!Protocol.Runtime.ExceptionDetails=} exceptionDetails
698 * @this {SDK.RemoteObject} 732 * @this {SDK.RemoteObjectImpl}
699 */ 733 */
700 function evaluatedCallback(error, result, exceptionDetails) { 734 function evaluatedCallback(error, result, exceptionDetails) {
701 if (error || !!exceptionDetails) { 735 if (error || !!exceptionDetails) {
702 callback(error || (result.type !== 'string' ? result.description : /** @ type {string} */ (result.value))); 736 callback(error || (result.type !== 'string' ? result.description : /** @ type {string} */ (result.value)));
703 return; 737 return;
704 } 738 }
705 739
706 if (typeof name === 'string') 740 if (typeof name === 'string')
707 name = SDK.RemoteObject.toCallArgument(name); 741 name = SDK.RemoteObject.toCallArgument(name);
708 742
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 * @param {!Protocol.Runtime.RemoteObject} result 823 * @param {!Protocol.Runtime.RemoteObject} result
790 * @param {!Protocol.Runtime.ExceptionDetails=} exceptionDetails 824 * @param {!Protocol.Runtime.ExceptionDetails=} exceptionDetails
791 * @this {SDK.RemoteObjectImpl} 825 * @this {SDK.RemoteObjectImpl}
792 */ 826 */
793 function mycallback(error, result, exceptionDetails) { 827 function mycallback(error, result, exceptionDetails) {
794 if (!callback) 828 if (!callback)
795 return; 829 return;
796 if (error) 830 if (error)
797 callback(null, false); 831 callback(null, false);
798 else 832 else
799 callback(this.target().runtimeModel.createRemoteObject(result), !!except ionDetails); 833 callback(this._runtimeModel.createRemoteObject(result), !!exceptionDetai ls);
800 } 834 }
801 835
802 this._runtimeAgent.callFunctionOn( 836 this._runtimeAgent.callFunctionOn(
803 this._objectId, functionDeclaration.toString(), args, true, undefined, u ndefined, undefined, undefined, 837 this._objectId, functionDeclaration.toString(), args, true, undefined, u ndefined, undefined, undefined,
804 mycallback.bind(this)); 838 mycallback.bind(this));
805 } 839 }
806 840
807 /** 841 /**
808 * @override 842 * @override
809 * @param {function(this:Object)} functionDeclaration 843 * @param {function(this:Object)} functionDeclaration
810 * @param {!Array.<!Protocol.Runtime.CallArgument>|undefined} args 844 * @param {!Array.<!Protocol.Runtime.CallArgument>|undefined} args
811 * @param {function(*)} callback 845 * @param {function(*)} callback
812 */ 846 */
813 callFunctionJSON(functionDeclaration, args, callback) { 847 callFunctionJSON(functionDeclaration, args, callback) {
814 /** 848 /**
815 * @param {?Protocol.Error} error 849 * @param {?Protocol.Error} error
816 * @param {!Protocol.Runtime.RemoteObject} result 850 * @param {!Protocol.Runtime.RemoteObject} result
817 * @param {!Protocol.Runtime.ExceptionDetails=} exceptionDetails 851 * @param {!Protocol.Runtime.ExceptionDetails=} exceptionDetails
818 */ 852 */
819 function mycallback(error, result, exceptionDetails) { 853 function mycallback(error, result, exceptionDetails) {
820 callback((error || !!exceptionDetails) ? null : result.value); 854 callback((error || !!exceptionDetails) ? null : result.value);
821 } 855 }
822 856
823 this._runtimeAgent.callFunctionOn( 857 this._runtimeAgent.callFunctionOn(
824 this._objectId, functionDeclaration.toString(), args, true, true, false, undefined, undefined, mycallback); 858 this._objectId, functionDeclaration.toString(), args, true, true, false, undefined, undefined, mycallback);
825 } 859 }
826 860
861 /**
862 * @override
863 */
827 release() { 864 release() {
828 if (!this._objectId) 865 if (!this._objectId)
829 return; 866 return;
830 this._runtimeAgent.releaseObject(this._objectId); 867 this._runtimeAgent.releaseObject(this._objectId);
831 } 868 }
832 869
833 /** 870 /**
834 * @override 871 * @override
835 * @return {number} 872 * @return {number}
836 */ 873 */
837 arrayLength() { 874 arrayLength() {
838 return SDK.RemoteObject.arrayLength(this); 875 return SDK.RemoteObject.arrayLength(this);
839 } 876 }
840 877
841 /** 878 /**
842 * @override 879 * @override
843 * @return {!SDK.Target} 880 * @return {!SDK.DebuggerModel}
844 */ 881 */
845 target() { 882 debuggerModel() {
846 return this._target; 883 return this._runtimeModel.debuggerModel();
847 } 884 }
848 885
849 /** 886 /**
850 * @override 887 * @override
851 * @return {?SDK.DebuggerModel} 888 * @return {!SDK.RuntimeModel}
852 */ 889 */
853 debuggerModel() { 890 runtimeModel() {
854 return this._debuggerModel; 891 return this._runtimeModel;
855 } 892 }
856 893
857 /** 894 /**
858 * @override 895 * @override
859 * @return {boolean} 896 * @return {boolean}
860 */ 897 */
861 isNode() { 898 isNode() {
862 return !!this._objectId && this.type === 'object' && this.subtype === 'node' ; 899 return !!this._objectId && this.type === 'object' && this.subtype === 'node' ;
863 } 900 }
864 }; 901 };
865 902
866 903
867 /**
868 * @unrestricted
869 */
870 SDK.ScopeRemoteObject = class extends SDK.RemoteObjectImpl { 904 SDK.ScopeRemoteObject = class extends SDK.RemoteObjectImpl {
871 /** 905 /**
872 * @param {!SDK.Target} target 906 * @param {!SDK.RuntimeModel} runtimeModel
873 * @param {string|undefined} objectId 907 * @param {string|undefined} objectId
874 * @param {!SDK.ScopeRef} scopeRef 908 * @param {!SDK.ScopeRef} scopeRef
875 * @param {string} type 909 * @param {string} type
876 * @param {string|undefined} subtype 910 * @param {string|undefined} subtype
877 * @param {*} value 911 * @param {*} value
878 * @param {!Protocol.Runtime.UnserializableValue=} unserializableValue 912 * @param {!Protocol.Runtime.UnserializableValue=} unserializableValue
879 * @param {string=} description 913 * @param {string=} description
880 * @param {!Protocol.Runtime.ObjectPreview=} preview 914 * @param {!Protocol.Runtime.ObjectPreview=} preview
881 */ 915 */
882 constructor(target, objectId, scopeRef, type, subtype, value, unserializableVa lue, description, preview) { 916 constructor(runtimeModel, objectId, scopeRef, type, subtype, value, unserializ ableValue, description, preview) {
883 super(target, objectId, type, subtype, value, unserializableValue, descripti on, preview); 917 super(runtimeModel, objectId, type, subtype, value, unserializableValue, des cription, preview);
884 this._scopeRef = scopeRef; 918 this._scopeRef = scopeRef;
885 this._savedScopeProperties = undefined; 919 this._savedScopeProperties = undefined;
886 } 920 }
887 921
888 /** 922 /**
889 * @override 923 * @override
890 * @param {boolean} ownProperties 924 * @param {boolean} ownProperties
891 * @param {boolean} accessorPropertiesOnly 925 * @param {boolean} accessorPropertiesOnly
892 * @param {boolean} generatePreview 926 * @param {boolean} generatePreview
893 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj ectProperty>)} callback 927 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj ectProperty>)} callback
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 } 963 }
930 964
931 /** 965 /**
932 * @override 966 * @override
933 * @param {!Protocol.Runtime.RemoteObject} result 967 * @param {!Protocol.Runtime.RemoteObject} result
934 * @param {!Protocol.Runtime.CallArgument} argumentName 968 * @param {!Protocol.Runtime.CallArgument} argumentName
935 * @param {function(string=)} callback 969 * @param {function(string=)} callback
936 */ 970 */
937 doSetObjectPropertyValue(result, argumentName, callback) { 971 doSetObjectPropertyValue(result, argumentName, callback) {
938 var name = /** @type {string} */ (argumentName.value); 972 var name = /** @type {string} */ (argumentName.value);
939 this._debuggerModel.setVariableValue( 973 this.debuggerModel().setVariableValue(
940 this._scopeRef.number, name, SDK.RemoteObject.toCallArgument(result), th is._scopeRef.callFrameId, 974 this._scopeRef.number, name, SDK.RemoteObject.toCallArgument(result), th is._scopeRef.callFrameId,
941 setVariableValueCallback.bind(this)); 975 setVariableValueCallback.bind(this));
942 976
943 /** 977 /**
944 * @param {string=} error 978 * @param {string=} error
945 * @this {SDK.ScopeRemoteObject} 979 * @this {SDK.ScopeRemoteObject}
946 */ 980 */
947 function setVariableValueCallback(error) { 981 function setVariableValueCallback(error) {
948 if (error) { 982 if (error) {
949 callback(error); 983 callback(error);
950 return; 984 return;
951 } 985 }
952 if (this._savedScopeProperties) { 986 if (this._savedScopeProperties) {
953 for (var i = 0; i < this._savedScopeProperties.length; i++) { 987 for (var i = 0; i < this._savedScopeProperties.length; i++) {
954 if (this._savedScopeProperties[i].name === name) 988 if (this._savedScopeProperties[i].name === name)
955 this._savedScopeProperties[i].value = this._target.runtimeModel.crea teRemoteObject(result); 989 this._savedScopeProperties[i].value = this._runtimeModel.createRemot eObject(result);
956 } 990 }
957 } 991 }
958 callback(); 992 callback();
959 } 993 }
960 } 994 }
961 }; 995 };
962 996
963 /**
964 * @unrestricted
965 */
966 SDK.ScopeRef = class { 997 SDK.ScopeRef = class {
967 /** 998 /**
968 * @param {number} number 999 * @param {number} number
969 * @param {string=} callFrameId 1000 * @param {string=} callFrameId
970 */ 1001 */
971 constructor(number, callFrameId) { 1002 constructor(number, callFrameId) {
972 this.number = number; 1003 this.number = number;
973 this.callFrameId = callFrameId; 1004 this.callFrameId = callFrameId;
974 } 1005 }
975 }; 1006 };
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 return !!(this.getter || this.setter); 1039 return !!(this.getter || this.setter);
1009 } 1040 }
1010 }; 1041 };
1011 1042
1012 // Below is a wrapper around a local object that implements the RemoteObject int erface, 1043 // Below is a wrapper around a local object that implements the RemoteObject int erface,
1013 // which can be used by the UI code (primarily ObjectPropertiesSection). 1044 // which can be used by the UI code (primarily ObjectPropertiesSection).
1014 // Note that only JSON-compliant objects are currently supported, as there's no provision 1045 // Note that only JSON-compliant objects are currently supported, as there's no provision
1015 // for traversing prototypes, extracting class names via constructor, handling p roperties 1046 // for traversing prototypes, extracting class names via constructor, handling p roperties
1016 // or functions. 1047 // or functions.
1017 1048
1018 /**
1019 * @unrestricted
1020 */
1021 SDK.LocalJSONObject = class extends SDK.RemoteObject { 1049 SDK.LocalJSONObject = class extends SDK.RemoteObject {
1022 /** 1050 /**
1023 * @param {*} value 1051 * @param {*} value
1024 */ 1052 */
1025 constructor(value) { 1053 constructor(value) {
1026 super(); 1054 super();
1027 this._value = value; 1055 this._value = value;
1056 /** @type {string} */
1057 this._cachedDescription;
1058 /** @type {!Array<!SDK.RemoteObjectProperty>} */
1059 this._cachedChildren;
1028 } 1060 }
1029 1061
1030 /** 1062 /**
1063 * @override
1064 * @return {!Protocol.Runtime.RemoteObjectId|undefined}
1065 * */
1066 get objectId() {
1067 return undefined;
1068 }
1069
1070 /**
1071 * @override
1072 * @return {*}
1073 */
1074 get value() {
1075 return this._value;
1076 }
1077
1078 /**
1031 * @override 1079 * @override
1032 * @return {string} 1080 * @return {string}
1033 */ 1081 */
1034 get description() { 1082 get description() {
1035 if (this._cachedDescription) 1083 if (this._cachedDescription)
1036 return this._cachedDescription; 1084 return this._cachedDescription;
1037 1085
1038 /** 1086 /**
1039 * @param {!SDK.RemoteObjectProperty} property 1087 * @param {!SDK.RemoteObjectProperty} property
1040 * @return {string} 1088 * @return {string}
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 try { 1301 try {
1254 result = functionDeclaration.apply(target, rawArgs); 1302 result = functionDeclaration.apply(target, rawArgs);
1255 } catch (e) { 1303 } catch (e) {
1256 result = null; 1304 result = null;
1257 } 1305 }
1258 1306
1259 callback(result); 1307 callback(result);
1260 } 1308 }
1261 }; 1309 };
1262 1310
1263 /**
1264 * @unrestricted
1265 */
1266 SDK.RemoteArray = class { 1311 SDK.RemoteArray = class {
1267 /** 1312 /**
1268 * @param {!SDK.RemoteObject} object 1313 * @param {!SDK.RemoteObject} object
1269 */ 1314 */
1270 constructor(object) { 1315 constructor(object) {
1271 this._object = object; 1316 this._object = object;
1272 } 1317 }
1273 1318
1274 /** 1319 /**
1275 * @param {?SDK.RemoteObject} object 1320 * @param {?SDK.RemoteObject} object
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1365 1410
1366 /** 1411 /**
1367 * @return {!SDK.RemoteObject} 1412 * @return {!SDK.RemoteObject}
1368 */ 1413 */
1369 object() { 1414 object() {
1370 return this._object; 1415 return this._object;
1371 } 1416 }
1372 }; 1417 };
1373 1418
1374 1419
1375 /**
1376 * @unrestricted
1377 */
1378 SDK.RemoteFunction = class { 1420 SDK.RemoteFunction = class {
1379 /** 1421 /**
1380 * @param {!SDK.RemoteObject} object 1422 * @param {!SDK.RemoteObject} object
1381 */ 1423 */
1382 constructor(object) { 1424 constructor(object) {
1383 this._object = object; 1425 this._object = object;
1384 } 1426 }
1385 1427
1386 /** 1428 /**
1387 * @param {?SDK.RemoteObject} object 1429 * @param {?SDK.RemoteObject} object
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1457 * @const 1499 * @const
1458 * @type {!RegExp} 1500 * @type {!RegExp}
1459 */ 1501 */
1460 SDK.RemoteObject._descriptionLengthParenRegex = /\(([0-9]+)\)/; 1502 SDK.RemoteObject._descriptionLengthParenRegex = /\(([0-9]+)\)/;
1461 1503
1462 /** 1504 /**
1463 * @const 1505 * @const
1464 * @type {!RegExp} 1506 * @type {!RegExp}
1465 */ 1507 */
1466 SDK.RemoteObject._descriptionLengthSquareRegex = /\[([0-9]+)\]/; 1508 SDK.RemoteObject._descriptionLengthSquareRegex = /\[([0-9]+)\]/;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698