OLD | NEW |
---|---|
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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
374 throw 'Not implemented'; | 374 throw 'Not implemented'; |
375 } | 375 } |
376 | 376 |
377 /** | 377 /** |
378 * @param {function(this:Object, ...):T} functionDeclaration | 378 * @param {function(this:Object, ...):T} functionDeclaration |
379 * @param {!Array<!Protocol.Runtime.CallArgument>|undefined} args | 379 * @param {!Array<!Protocol.Runtime.CallArgument>|undefined} args |
380 * @return {!Promise<T>} | 380 * @return {!Promise<T>} |
381 * @template T | 381 * @template T |
382 */ | 382 */ |
383 callFunctionJSONPromise(functionDeclaration, args) { | 383 callFunctionJSONPromise(functionDeclaration, args) { |
384 return new Promise(promiseConstructor.bind(this)); | 384 return new Promise(success => this.callFunctionJSON(functionDeclaration, arg s, success)); |
385 | |
386 /** | |
387 * @this {SDK.RemoteObject} | |
388 */ | |
389 function promiseConstructor(success) { | |
390 this.callFunctionJSON(functionDeclaration, args, success); | |
391 } | |
392 } | 385 } |
393 | 386 |
394 release() { | 387 release() { |
395 } | 388 } |
396 | 389 |
397 /** | 390 /** |
398 * @return {!SDK.DebuggerModel} | 391 * @return {!SDK.DebuggerModel} |
399 */ | 392 */ |
400 debuggerModel() { | 393 debuggerModel() { |
401 throw new Error('DebuggerModel-less object'); | 394 throw new Error('DebuggerModel-less object'); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
568 } | 561 } |
569 | 562 |
570 var args = [{value: JSON.stringify(propertyPath)}]; | 563 var args = [{value: JSON.stringify(propertyPath)}]; |
571 this.callFunction(remoteFunction, args, callback); | 564 this.callFunction(remoteFunction, args, callback); |
572 } | 565 } |
573 | 566 |
574 /** | 567 /** |
575 * @param {boolean} ownProperties | 568 * @param {boolean} ownProperties |
576 * @param {boolean} accessorPropertiesOnly | 569 * @param {boolean} accessorPropertiesOnly |
577 * @param {boolean} generatePreview | 570 * @param {boolean} generatePreview |
578 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj ectProperty>)} callback | 571 * @param {function(?Array<!SDK.RemoteObjectProperty>, ?Array<!SDK.RemoteObjec tProperty>)} callback |
579 */ | 572 */ |
580 doGetProperties(ownProperties, accessorPropertiesOnly, generatePreview, callba ck) { | 573 async doGetProperties(ownProperties, accessorPropertiesOnly, generatePreview, callback) { |
pfeldman
2017/05/24 00:43:32
async function with the callback seems like an ant
alph
2017/05/24 01:42:57
Done.
| |
581 if (!this._objectId) { | 574 if (!this._objectId) { |
582 callback(null, null); | 575 callback(null, null); |
583 return; | 576 return; |
584 } | 577 } |
585 | 578 |
586 /** | 579 var response = await this._runtimeAgent.invoke_getProperties({ |
587 * @param {?Protocol.Error} error | 580 objectId: this._objectId, |
588 * @param {!Array.<!Protocol.Runtime.PropertyDescriptor>} properties | 581 ownProperties: ownProperties, |
589 * @param {!Array.<!Protocol.Runtime.InternalPropertyDescriptor>=} internalP roperties | 582 accessorPropertiesOnly: accessorPropertiesOnly, |
590 * @param {?Protocol.Runtime.ExceptionDetails=} exceptionDetails | 583 generatePreview: generatePreview |
591 * @this {SDK.RemoteObjectImpl} | 584 }); |
592 */ | 585 if (response[Protocol.Error]) { |
593 function remoteObjectBinder(error, properties, internalProperties, exception Details) { | 586 callback(null, null); |
594 if (error) { | 587 return; |
595 callback(null, null); | 588 } |
596 return; | 589 |
590 var properties = response.result; | |
591 var internalProperties = response.internalProperties; | |
592 if (response.exceptionDetails) { | |
593 this._runtimeModel.exceptionThrown(Date.now(), response.exceptionDetails); | |
594 callback(null, null); | |
595 return; | |
596 } | |
597 var result = []; | |
598 for (var i = 0; properties && i < properties.length; ++i) { | |
599 var property = properties[i]; | |
600 var propertyValue = property.value ? this._runtimeModel.createRemoteObject (property.value) : null; | |
601 var propertySymbol = property.symbol ? this._runtimeModel.createRemoteObje ct(property.symbol) : null; | |
602 var remoteProperty = new SDK.RemoteObjectProperty( | |
603 property.name, propertyValue, !!property.enumerable, !!property.writab le, !!property.isOwn, | |
604 !!property.wasThrown, propertySymbol); | |
605 | |
606 if (typeof property.value === 'undefined') { | |
607 if (property.get && property.get.type !== 'undefined') | |
608 remoteProperty.getter = this._runtimeModel.createRemoteObject(property .get); | |
609 if (property.set && property.set.type !== 'undefined') | |
610 remoteProperty.setter = this._runtimeModel.createRemoteObject(property .set); | |
597 } | 611 } |
598 if (exceptionDetails) { | 612 |
599 this._runtimeModel.exceptionThrown(Date.now(), exceptionDetails); | 613 result.push(remoteProperty); |
600 callback(null, null); | 614 } |
601 return; | 615 var internalPropertiesResult = null; |
616 if (internalProperties) { | |
617 internalPropertiesResult = []; | |
618 for (var i = 0; i < internalProperties.length; i++) { | |
619 var property = internalProperties[i]; | |
620 if (!property.value) | |
621 continue; | |
622 var propertyValue = this._runtimeModel.createRemoteObject(property.value ); | |
623 internalPropertiesResult.push(new SDK.RemoteObjectProperty(property.name , propertyValue, true, false)); | |
602 } | 624 } |
603 var result = []; | |
604 for (var i = 0; properties && i < properties.length; ++i) { | |
605 var property = properties[i]; | |
606 var propertyValue = property.value ? this._runtimeModel.createRemoteObje ct(property.value) : null; | |
607 var propertySymbol = property.symbol ? this._runtimeModel.createRemoteOb ject(property.symbol) : null; | |
608 var remoteProperty = new SDK.RemoteObjectProperty( | |
609 property.name, propertyValue, !!property.enumerable, !!property.writ able, !!property.isOwn, | |
610 !!property.wasThrown, propertySymbol); | |
611 | |
612 if (typeof property.value === 'undefined') { | |
613 if (property.get && property.get.type !== 'undefined') | |
614 remoteProperty.getter = this._runtimeModel.createRemoteObject(proper ty.get); | |
615 if (property.set && property.set.type !== 'undefined') | |
616 remoteProperty.setter = this._runtimeModel.createRemoteObject(proper ty.set); | |
617 } | |
618 | |
619 result.push(remoteProperty); | |
620 } | |
621 var internalPropertiesResult = null; | |
622 if (internalProperties) { | |
623 internalPropertiesResult = []; | |
624 for (var i = 0; i < internalProperties.length; i++) { | |
625 var property = internalProperties[i]; | |
626 if (!property.value) | |
627 continue; | |
628 var propertyValue = this._runtimeModel.createRemoteObject(property.val ue); | |
629 internalPropertiesResult.push(new SDK.RemoteObjectProperty(property.na me, propertyValue, true, false)); | |
630 } | |
631 } | |
632 callback(result, internalPropertiesResult); | |
633 } | 625 } |
634 this._runtimeAgent.getProperties( | 626 callback(result, internalPropertiesResult); |
635 this._objectId, ownProperties, accessorPropertiesOnly, generatePreview, remoteObjectBinder.bind(this)); | |
636 } | 627 } |
637 | 628 |
638 /** | 629 /** |
639 * @override | 630 * @override |
640 * @param {string|!Protocol.Runtime.CallArgument} name | 631 * @param {string|!Protocol.Runtime.CallArgument} name |
641 * @param {string} value | 632 * @param {string} value |
642 * @param {function(string=)} callback | 633 * @param {function(string=)} callback |
643 */ | 634 */ |
644 setPropertyValue(name, value, callback) { | 635 setPropertyValue(name, value, callback) { |
645 if (!this._objectId) { | 636 if (!this._objectId) { |
646 callback('Can\'t set a property of non-object.'); | 637 callback('Can\'t set a property of non-object.'); |
647 return; | 638 return; |
648 } | 639 } |
649 | 640 |
650 this._runtimeAgent.invoke_evaluate({expression: value, silent: true}).then(r esponse => { | 641 this._runtimeAgent.invoke_evaluate({expression: value, silent: true}).then(r esponse => { |
651 if (response[Protocol.Error] || response.exceptionDetails) { | 642 if (response[Protocol.Error] || response.exceptionDetails) { |
652 callback( | 643 callback( |
653 response[Protocol.Error] || | 644 response[Protocol.Error] || |
654 (response.result.type !== 'string' ? response.result.description : | 645 (response.result.type !== 'string' ? response.result.description : |
655 /** @type {string} */ (response .result.value))); | 646 /** @type {string} */ (response .result.value))); |
656 return; | 647 return; |
657 } | 648 } |
658 | 649 |
659 if (typeof name === 'string') | 650 if (typeof name === 'string') |
660 name = SDK.RemoteObject.toCallArgument(name); | 651 name = SDK.RemoteObject.toCallArgument(name); |
661 | 652 |
662 this.doSetObjectPropertyValue(response.result, name, callback); | 653 this.doSetObjectPropertyValue(response.result, name).then(callback); |
663 | 654 |
664 if (response.result.objectId) | 655 if (response.result.objectId) |
665 this._runtimeAgent.releaseObject(response.result.objectId); | 656 this._runtimeAgent.releaseObject(response.result.objectId); |
666 }); | 657 }); |
667 } | 658 } |
668 | 659 |
669 /** | 660 /** |
670 * @param {!Protocol.Runtime.RemoteObject} result | 661 * @param {!Protocol.Runtime.RemoteObject} result |
671 * @param {!Protocol.Runtime.CallArgument} name | 662 * @param {!Protocol.Runtime.CallArgument} name |
672 * @param {function(string=)} callback | 663 * @return {!Promise<string|undefined>} |
673 */ | 664 */ |
674 doSetObjectPropertyValue(result, name, callback) { | 665 async doSetObjectPropertyValue(result, name) { |
pfeldman
2017/05/24 00:43:32
async overriden by non-async below.
alph
2017/05/24 01:42:58
No, they are both async
| |
675 // This assignment may be for a regular (data) property, and for an accessor property (with getter/setter). | 666 // This assignment may be for a regular (data) property, and for an accessor property (with getter/setter). |
676 // Note the sensitive matter about accessor property: the property may be ph ysically defined in some proto object, | 667 // Note the sensitive matter about accessor property: the property may be ph ysically defined in some proto object, |
677 // but logically it is bound to the object in question. JavaScript passes th is object to getters/setters, not the object | 668 // but logically it is bound to the object in question. JavaScript passes th is object to getters/setters, not the object |
678 // where property was defined; so do we. | 669 // where property was defined; so do we. |
679 var setPropertyValueFunction = 'function(a, b) { this[a] = b; }'; | 670 var setPropertyValueFunction = 'function(a, b) { this[a] = b; }'; |
680 | 671 |
681 var argv = [name, SDK.RemoteObject.toCallArgument(result)]; | 672 var argv = [name, SDK.RemoteObject.toCallArgument(result)]; |
682 this._runtimeAgent.callFunctionOn( | 673 var response = await this._runtimeAgent.invoke_callFunctionOn( |
683 this._objectId, setPropertyValueFunction, argv, true, undefined, undefin ed, undefined, undefined, | 674 {objectId: this._objectId, functionDeclaration: setPropertyValueFunction , arguments: argv, silent: true}); |
684 propertySetCallback); | 675 return response[Protocol.error] || response.result.description || undefined; |
pfeldman
2017/05/24 00:43:32
You should return non-undefined upon error only.
alph
2017/05/24 01:42:58
Done.
| |
685 | |
686 /** | |
687 * @param {?Protocol.Error} error | |
688 * @param {!Protocol.Runtime.RemoteObject} result | |
689 * @param {!Protocol.Runtime.ExceptionDetails=} exceptionDetails | |
690 */ | |
691 function propertySetCallback(error, result, exceptionDetails) { | |
692 if (error || !!exceptionDetails) { | |
693 callback(error || result.description); | |
694 return; | |
695 } | |
696 callback(); | |
697 } | |
698 } | 676 } |
699 | 677 |
700 /** | 678 /** |
701 * @override | 679 * @override |
702 * @param {!Protocol.Runtime.CallArgument} name | 680 * @param {!Protocol.Runtime.CallArgument} name |
703 * @param {function(string=)} callback | 681 * @param {function(string=)} callback |
704 */ | 682 */ |
705 deleteProperty(name, callback) { | 683 deleteProperty(name, callback) { |
706 if (!this._objectId) { | 684 if (!this._objectId) { |
707 callback('Can\'t delete a property of non-object.'); | 685 callback(`Can't delete a property of non-object.`); |
708 return; | 686 return; |
709 } | 687 } |
710 | 688 |
711 var deletePropertyFunction = 'function(a) { delete this[a]; return !(a in th is); }'; | 689 var deletePropertyFunction = 'function(a) { delete this[a]; return !(a in th is); }'; |
712 this._runtimeAgent.callFunctionOn( | 690 this._runtimeAgent |
713 this._objectId, deletePropertyFunction, [name], true, undefined, undefin ed, undefined, undefined, | 691 .invoke_callFunctionOn( |
714 deletePropertyCallback); | 692 {objectId: this._objectId, functionDeclaration: deletePropertyFuncti on, arguments: [name], silent: true}) |
715 | 693 .then(response => { |
716 /** | 694 if (response[Protocol.Error] || response.exceptionDetails) { |
717 * @param {?Protocol.Error} error | 695 callback(response[Protocol.Error] || response.result.description); |
718 * @param {!Protocol.Runtime.RemoteObject} result | 696 return; |
719 * @param {!Protocol.Runtime.ExceptionDetails=} exceptionDetails | 697 } |
720 */ | 698 if (!response.result.value) |
721 function deletePropertyCallback(error, result, exceptionDetails) { | 699 callback('Failed to delete property.'); |
722 if (error || !!exceptionDetails) { | 700 else |
723 callback(error || result.description); | 701 callback(); |
724 return; | 702 }); |
725 } | |
726 if (!result.value) | |
727 callback('Failed to delete property.'); | |
728 else | |
729 callback(); | |
730 } | |
731 } | 703 } |
732 | 704 |
733 /** | 705 /** |
734 * @override | 706 * @override |
735 * @param {function(this:Object, ...)} functionDeclaration | 707 * @param {function(this:Object, ...)} functionDeclaration |
736 * @param {!Array.<!Protocol.Runtime.CallArgument>=} args | 708 * @param {!Array.<!Protocol.Runtime.CallArgument>=} args |
737 * @param {function(?SDK.RemoteObject, boolean=)=} callback | 709 * @param {function(?SDK.RemoteObject, boolean=)=} callback |
738 */ | 710 */ |
739 callFunction(functionDeclaration, args, callback) { | 711 callFunction(functionDeclaration, args, callback) { |
740 /** | 712 this._runtimeAgent |
741 * @param {?Protocol.Error} error | 713 .invoke_callFunctionOn({ |
742 * @param {!Protocol.Runtime.RemoteObject} result | 714 objectId: this._objectId, |
743 * @param {!Protocol.Runtime.ExceptionDetails=} exceptionDetails | 715 functionDeclaration: functionDeclaration.toString(), |
744 * @this {SDK.RemoteObjectImpl} | 716 arguments: args, |
745 */ | 717 silent: true |
746 function mycallback(error, result, exceptionDetails) { | 718 }) |
747 if (!callback) | 719 .then(response => { |
748 return; | 720 if (!callback) |
749 if (error) | 721 return; |
750 callback(null, false); | 722 if (response[Protocol.Error]) |
751 else | 723 callback(null, false); |
752 callback(this._runtimeModel.createRemoteObject(result), !!exceptionDetai ls); | 724 else |
753 } | 725 callback(this._runtimeModel.createRemoteObject(response.result), !!r esponse.exceptionDetails); |
754 | 726 }); |
755 this._runtimeAgent.callFunctionOn( | |
756 this._objectId, functionDeclaration.toString(), args, true, undefined, u ndefined, undefined, undefined, | |
757 mycallback.bind(this)); | |
758 } | 727 } |
759 | 728 |
760 /** | 729 /** |
761 * @override | 730 * @override |
762 * @param {function(this:Object)} functionDeclaration | 731 * @param {function(this:Object)} functionDeclaration |
763 * @param {!Array.<!Protocol.Runtime.CallArgument>|undefined} args | 732 * @param {!Array.<!Protocol.Runtime.CallArgument>|undefined} args |
764 * @param {function(*)} callback | 733 * @param {function(*)} callback |
765 */ | 734 */ |
766 callFunctionJSON(functionDeclaration, args, callback) { | 735 callFunctionJSON(functionDeclaration, args, callback) { |
767 /** | 736 this._runtimeAgent |
768 * @param {?Protocol.Error} error | 737 .invoke_callFunctionOn({ |
769 * @param {!Protocol.Runtime.RemoteObject} result | 738 objectId: this._objectId, |
770 * @param {!Protocol.Runtime.ExceptionDetails=} exceptionDetails | 739 functionDeclaration: functionDeclaration.toString(), |
771 */ | 740 arguments: args, |
772 function mycallback(error, result, exceptionDetails) { | 741 silent: true, |
773 callback((error || !!exceptionDetails) ? null : result.value); | 742 returnByValue: true |
774 } | 743 }) |
775 | 744 .then( |
776 this._runtimeAgent.callFunctionOn( | 745 response => callback(response[Protocol.Error] || response.exceptionD etails ? null : response.result.value)); |
777 this._objectId, functionDeclaration.toString(), args, true, true, false, undefined, undefined, mycallback); | |
778 } | 746 } |
779 | 747 |
780 /** | 748 /** |
781 * @override | 749 * @override |
782 */ | 750 */ |
783 release() { | 751 release() { |
784 if (!this._objectId) | 752 if (!this._objectId) |
785 return; | 753 return; |
786 this._runtimeAgent.releaseObject(this._objectId); | 754 this._runtimeAgent.releaseObject(this._objectId); |
787 } | 755 } |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
878 // Scope objects always fetch preview. | 846 // Scope objects always fetch preview. |
879 generatePreview = true; | 847 generatePreview = true; |
880 | 848 |
881 super.doGetProperties(ownProperties, accessorPropertiesOnly, generatePreview , wrappedCallback.bind(this)); | 849 super.doGetProperties(ownProperties, accessorPropertiesOnly, generatePreview , wrappedCallback.bind(this)); |
882 } | 850 } |
883 | 851 |
884 /** | 852 /** |
885 * @override | 853 * @override |
886 * @param {!Protocol.Runtime.RemoteObject} result | 854 * @param {!Protocol.Runtime.RemoteObject} result |
887 * @param {!Protocol.Runtime.CallArgument} argumentName | 855 * @param {!Protocol.Runtime.CallArgument} argumentName |
888 * @param {function(string=)} callback | 856 * @return {!Promise<string|undefined>} |
889 */ | 857 */ |
890 doSetObjectPropertyValue(result, argumentName, callback) { | 858 async doSetObjectPropertyValue(result, argumentName) { |
891 var name = /** @type {string} */ (argumentName.value); | 859 var name = /** @type {string} */ (argumentName.value); |
892 this.debuggerModel().setVariableValue( | 860 this.debuggerModel().setVariableValue( |
893 this._scopeRef.number, name, SDK.RemoteObject.toCallArgument(result), th is._scopeRef.callFrameId, | 861 this._scopeRef.number, name, SDK.RemoteObject.toCallArgument(result), th is._scopeRef.callFrameId, |
894 setVariableValueCallback.bind(this)); | 862 setVariableValueCallback.bind(this)); |
863 var callback; | |
864 return new Promise(resolve => callback = resolve); | |
895 | 865 |
896 /** | 866 /** |
897 * @param {string=} error | 867 * @param {string=} error |
898 * @this {SDK.ScopeRemoteObject} | 868 * @this {SDK.ScopeRemoteObject} |
899 */ | 869 */ |
900 function setVariableValueCallback(error) { | 870 function setVariableValueCallback(error) { |
901 if (error) { | 871 if (error) { |
902 callback(error); | 872 callback(error); |
903 return; | 873 return; |
904 } | 874 } |
905 if (this._savedScopeProperties) { | 875 if (this._savedScopeProperties) { |
906 for (var i = 0; i < this._savedScopeProperties.length; i++) { | 876 for (var i = 0; i < this._savedScopeProperties.length; i++) { |
907 if (this._savedScopeProperties[i].name === name) | 877 if (this._savedScopeProperties[i].name === name) |
908 this._savedScopeProperties[i].value = this._runtimeModel.createRemot eObject(result); | 878 this._savedScopeProperties[i].value = this._runtimeModel.createRemot eObject(result); |
909 } | 879 } |
910 } | 880 } |
911 callback(); | 881 callback(undefined); |
912 } | 882 } |
913 } | 883 } |
914 }; | 884 }; |
915 | 885 |
916 SDK.ScopeRef = class { | 886 SDK.ScopeRef = class { |
917 /** | 887 /** |
918 * @param {number} number | 888 * @param {number} number |
919 * @param {string=} callFrameId | 889 * @param {string=} callFrameId |
920 */ | 890 */ |
921 constructor(number, callFrameId) { | 891 constructor(number, callFrameId) { |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1173 * @override | 1143 * @override |
1174 * @return {number} | 1144 * @return {number} |
1175 */ | 1145 */ |
1176 arrayLength() { | 1146 arrayLength() { |
1177 return Array.isArray(this._value) ? this._value.length : 0; | 1147 return Array.isArray(this._value) ? this._value.length : 0; |
1178 } | 1148 } |
1179 | 1149 |
1180 /** | 1150 /** |
1181 * @override | 1151 * @override |
1182 * @param {function(this:Object, ...)} functionDeclaration | 1152 * @param {function(this:Object, ...)} functionDeclaration |
1183 * @param {!Array.<!Protocol.Runtime.CallArgument>=} args | 1153 * @param {!Array<!Protocol.Runtime.CallArgument>=} args |
1184 * @param {function(?SDK.RemoteObject, boolean=)=} callback | 1154 * @param {function(?SDK.RemoteObject, boolean=)=} callback |
1185 */ | 1155 */ |
1186 callFunction(functionDeclaration, args, callback) { | 1156 callFunction(functionDeclaration, args, callback) { |
1187 var target = /** @type {?Object} */ (this._value); | 1157 var target = /** @type {?Object} */ (this._value); |
1188 var rawArgs = args ? args.map(function(arg) { | 1158 var rawArgs = args ? args.map(arg => arg.value) : []; |
1189 return arg.value; | |
1190 }) : | |
1191 []; | |
1192 | 1159 |
1193 var result; | 1160 var result; |
1194 var wasThrown = false; | 1161 var wasThrown = false; |
1195 try { | 1162 try { |
1196 result = functionDeclaration.apply(target, rawArgs); | 1163 result = functionDeclaration.apply(target, rawArgs); |
1197 } catch (e) { | 1164 } catch (e) { |
1198 wasThrown = true; | 1165 wasThrown = true; |
1199 } | 1166 } |
1200 | 1167 |
1201 if (!callback) | 1168 if (!callback) |
1202 return; | 1169 return; |
1203 callback(SDK.RemoteObject.fromLocalObject(result), wasThrown); | 1170 callback(SDK.RemoteObject.fromLocalObject(result), wasThrown); |
1204 } | 1171 } |
1205 | 1172 |
1206 /** | 1173 /** |
1207 * @override | 1174 * @override |
1208 * @param {function(this:Object)} functionDeclaration | 1175 * @param {function(this:Object)} functionDeclaration |
1209 * @param {!Array.<!Protocol.Runtime.CallArgument>|undefined} args | 1176 * @param {!Array<!Protocol.Runtime.CallArgument>|undefined} args |
1210 * @param {function(*)} callback | 1177 * @param {function(*)} callback |
1211 */ | 1178 */ |
1212 callFunctionJSON(functionDeclaration, args, callback) { | 1179 callFunctionJSON(functionDeclaration, args, callback) { |
1213 var target = /** @type {?Object} */ (this._value); | 1180 var target = /** @type {?Object} */ (this._value); |
1214 var rawArgs = args ? args.map(function(arg) { | 1181 var rawArgs = args ? args.map(arg => arg.value) : []; |
1215 return arg.value; | |
1216 }) : | |
1217 []; | |
1218 | 1182 |
1219 var result; | 1183 var result; |
1220 try { | 1184 try { |
1221 result = functionDeclaration.apply(target, rawArgs); | 1185 result = functionDeclaration.apply(target, rawArgs); |
1222 } catch (e) { | 1186 } catch (e) { |
1223 result = null; | 1187 result = null; |
1224 } | 1188 } |
1225 | 1189 |
1226 callback(result); | 1190 callback(result); |
1227 } | 1191 } |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1418 * @const | 1382 * @const |
1419 * @type {!RegExp} | 1383 * @type {!RegExp} |
1420 */ | 1384 */ |
1421 SDK.RemoteObject._descriptionLengthParenRegex = /\(([0-9]+)\)/; | 1385 SDK.RemoteObject._descriptionLengthParenRegex = /\(([0-9]+)\)/; |
1422 | 1386 |
1423 /** | 1387 /** |
1424 * @const | 1388 * @const |
1425 * @type {!RegExp} | 1389 * @type {!RegExp} |
1426 */ | 1390 */ |
1427 SDK.RemoteObject._descriptionLengthSquareRegex = /\[([0-9]+)\]/; | 1391 SDK.RemoteObject._descriptionLengthSquareRegex = /\[([0-9]+)\]/; |
OLD | NEW |