Chromium Code Reviews| 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 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 653 if (!this._objectId) { | 653 if (!this._objectId) { |
| 654 callback("Can't set a property of non-object."); | 654 callback("Can't set a property of non-object."); |
| 655 return; | 655 return; |
| 656 } | 656 } |
| 657 | 657 |
| 658 this._runtimeAgent.invoke_evaluate({expression:value, doNotPauseOnExcept ionsAndMuteConsole:true}, evaluatedCallback.bind(this)); | 658 this._runtimeAgent.invoke_evaluate({expression:value, doNotPauseOnExcept ionsAndMuteConsole:true}, evaluatedCallback.bind(this)); |
| 659 | 659 |
| 660 /** | 660 /** |
| 661 * @param {?Protocol.Error} error | 661 * @param {?Protocol.Error} error |
| 662 * @param {!RuntimeAgent.RemoteObject} result | 662 * @param {!RuntimeAgent.RemoteObject} result |
| 663 * @param {boolean=} wasThrown | 663 * @param {!RuntimeAgent.ExceptionDetails=} exceptionDetails |
| 664 * @this {WebInspector.RemoteObject} | 664 * @this {WebInspector.RemoteObject} |
| 665 */ | 665 */ |
| 666 function evaluatedCallback(error, result, wasThrown) | 666 function evaluatedCallback(error, result, exceptionDetails) |
|
dgozman
2016/08/11 01:54:36
Could you please check why compiler didn't catch m
kozy
2016/08/11 21:04:22
Compiler allows to omit optional arguments in call
| |
| 667 { | 667 { |
| 668 if (error || wasThrown) { | 668 if (error || !!exceptionDetails) { |
| 669 callback(error || (result.type !== "string" ? result.description : /** @type {string} */(result.value))); | 669 callback(error || (result.type !== "string" ? result.description : /** @type {string} */(result.value))); |
| 670 return; | 670 return; |
| 671 } | 671 } |
| 672 | 672 |
| 673 if (typeof name === "string") | 673 if (typeof name === "string") |
| 674 name = WebInspector.RemoteObject.toCallArgument(name); | 674 name = WebInspector.RemoteObject.toCallArgument(name); |
| 675 | 675 |
| 676 this.doSetObjectPropertyValue(result, name, callback); | 676 this.doSetObjectPropertyValue(result, name, callback); |
| 677 | 677 |
| 678 if (result.objectId) | 678 if (result.objectId) |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 692 // but logically it is bound to the object in question. JavaScript passe s this object to getters/setters, not the object | 692 // but logically it is bound to the object in question. JavaScript passe s this object to getters/setters, not the object |
| 693 // where property was defined; so do we. | 693 // where property was defined; so do we. |
| 694 var setPropertyValueFunction = "function(a, b) { this[a] = b; }"; | 694 var setPropertyValueFunction = "function(a, b) { this[a] = b; }"; |
| 695 | 695 |
| 696 var argv = [name, WebInspector.RemoteObject.toCallArgument(result)]; | 696 var argv = [name, WebInspector.RemoteObject.toCallArgument(result)]; |
| 697 this._runtimeAgent.callFunctionOn(this._objectId, setPropertyValueFuncti on, argv, true, undefined, undefined, undefined, undefined, propertySetCallback) ; | 697 this._runtimeAgent.callFunctionOn(this._objectId, setPropertyValueFuncti on, argv, true, undefined, undefined, undefined, undefined, propertySetCallback) ; |
| 698 | 698 |
| 699 /** | 699 /** |
| 700 * @param {?Protocol.Error} error | 700 * @param {?Protocol.Error} error |
| 701 * @param {!RuntimeAgent.RemoteObject} result | 701 * @param {!RuntimeAgent.RemoteObject} result |
| 702 * @param {boolean=} wasThrown | 702 * @param {!RuntimeAgent.ExceptionDetails=} exceptionDetails |
| 703 */ | 703 */ |
| 704 function propertySetCallback(error, result, wasThrown) | 704 function propertySetCallback(error, result, exceptionDetails) |
| 705 { | 705 { |
| 706 if (error || wasThrown) { | 706 if (error || !!exceptionDetails) { |
| 707 callback(error || result.description); | 707 callback(error || result.description); |
| 708 return; | 708 return; |
| 709 } | 709 } |
| 710 callback(); | 710 callback(); |
| 711 } | 711 } |
| 712 }, | 712 }, |
| 713 | 713 |
| 714 /** | 714 /** |
| 715 * @override | 715 * @override |
| 716 * @param {!RuntimeAgent.CallArgument} name | 716 * @param {!RuntimeAgent.CallArgument} name |
| 717 * @param {function(string=)} callback | 717 * @param {function(string=)} callback |
| 718 */ | 718 */ |
| 719 deleteProperty: function(name, callback) | 719 deleteProperty: function(name, callback) |
| 720 { | 720 { |
| 721 if (!this._objectId) { | 721 if (!this._objectId) { |
| 722 callback("Can't delete a property of non-object."); | 722 callback("Can't delete a property of non-object."); |
| 723 return; | 723 return; |
| 724 } | 724 } |
| 725 | 725 |
| 726 var deletePropertyFunction = "function(a) { delete this[a]; return !(a i n this); }"; | 726 var deletePropertyFunction = "function(a) { delete this[a]; return !(a i n this); }"; |
| 727 this._runtimeAgent.callFunctionOn(this._objectId, deletePropertyFunction , [name], true, undefined, undefined, undefined, undefined, deletePropertyCallba ck); | 727 this._runtimeAgent.callFunctionOn(this._objectId, deletePropertyFunction , [name], true, undefined, undefined, undefined, undefined, deletePropertyCallba ck); |
| 728 | 728 |
| 729 /** | 729 /** |
| 730 * @param {?Protocol.Error} error | 730 * @param {?Protocol.Error} error |
| 731 * @param {!RuntimeAgent.RemoteObject} result | 731 * @param {!RuntimeAgent.RemoteObject} result |
| 732 * @param {boolean=} wasThrown | 732 * @param {!RuntimeAgent.ExceptionDetails=} exceptionDetails |
| 733 */ | 733 */ |
| 734 function deletePropertyCallback(error, result, wasThrown) | 734 function deletePropertyCallback(error, result, exceptionDetails) |
| 735 { | 735 { |
| 736 if (error || wasThrown) { | 736 if (error || !!exceptionDetails) { |
| 737 callback(error || result.description); | 737 callback(error || result.description); |
| 738 return; | 738 return; |
| 739 } | 739 } |
| 740 if (!result.value) | 740 if (!result.value) |
| 741 callback("Failed to delete property."); | 741 callback("Failed to delete property."); |
| 742 else | 742 else |
| 743 callback(); | 743 callback(); |
| 744 } | 744 } |
| 745 }, | 745 }, |
| 746 | 746 |
| 747 /** | 747 /** |
| 748 * @override | 748 * @override |
| 749 * @param {function(this:Object, ...)} functionDeclaration | 749 * @param {function(this:Object, ...)} functionDeclaration |
| 750 * @param {!Array.<!RuntimeAgent.CallArgument>=} args | 750 * @param {!Array.<!RuntimeAgent.CallArgument>=} args |
| 751 * @param {function(?WebInspector.RemoteObject, boolean=)=} callback | 751 * @param {function(?WebInspector.RemoteObject, boolean=)=} callback |
| 752 */ | 752 */ |
| 753 callFunction: function(functionDeclaration, args, callback) | 753 callFunction: function(functionDeclaration, args, callback) |
| 754 { | 754 { |
| 755 /** | 755 /** |
| 756 * @param {?Protocol.Error} error | 756 * @param {?Protocol.Error} error |
| 757 * @param {!RuntimeAgent.RemoteObject} result | 757 * @param {!RuntimeAgent.RemoteObject} result |
| 758 * @param {boolean=} wasThrown | 758 * @param {!RuntimeAgent.ExceptionDetails=} exceptionDetails |
| 759 * @this {WebInspector.RemoteObjectImpl} | 759 * @this {WebInspector.RemoteObjectImpl} |
| 760 */ | 760 */ |
| 761 function mycallback(error, result, wasThrown) | 761 function mycallback(error, result, exceptionDetails) |
| 762 { | 762 { |
| 763 if (!callback) | 763 if (!callback) |
| 764 return; | 764 return; |
| 765 if (error) | 765 if (error) |
| 766 callback(null, false); | 766 callback(null, false); |
| 767 else | 767 else |
| 768 callback(this.target().runtimeModel.createRemoteObject(result), wasThrown); | 768 callback(this.target().runtimeModel.createRemoteObject(result), !!exceptionDetails); |
| 769 } | 769 } |
| 770 | 770 |
| 771 this._runtimeAgent.callFunctionOn(this._objectId, functionDeclaration.to String(), args, true, undefined, undefined, undefined, undefined, mycallback.bin d(this)); | 771 this._runtimeAgent.callFunctionOn(this._objectId, functionDeclaration.to String(), args, true, undefined, undefined, undefined, undefined, mycallback.bin d(this)); |
| 772 }, | 772 }, |
| 773 | 773 |
| 774 /** | 774 /** |
| 775 * @override | 775 * @override |
| 776 * @param {function(this:Object)} functionDeclaration | 776 * @param {function(this:Object)} functionDeclaration |
| 777 * @param {!Array.<!RuntimeAgent.CallArgument>|undefined} args | 777 * @param {!Array.<!RuntimeAgent.CallArgument>|undefined} args |
| 778 * @param {function(*)} callback | 778 * @param {function(*)} callback |
| 779 */ | 779 */ |
| 780 callFunctionJSON: function(functionDeclaration, args, callback) | 780 callFunctionJSON: function(functionDeclaration, args, callback) |
| 781 { | 781 { |
| 782 /** | 782 /** |
| 783 * @param {?Protocol.Error} error | 783 * @param {?Protocol.Error} error |
| 784 * @param {!RuntimeAgent.RemoteObject} result | 784 * @param {!RuntimeAgent.RemoteObject} result |
| 785 * @param {boolean=} wasThrown | 785 * @param {!RuntimeAgent.ExceptionDetails=} exceptionDetails |
| 786 */ | 786 */ |
| 787 function mycallback(error, result, wasThrown) | 787 function mycallback(error, result, exceptionDetails) |
| 788 { | 788 { |
| 789 callback((error || wasThrown) ? null : result.value); | 789 callback((error || !!exceptionDetails) ? null : result.value); |
| 790 } | 790 } |
| 791 | 791 |
| 792 this._runtimeAgent.callFunctionOn(this._objectId, functionDeclaration.to String(), args, true, true, false, undefined, undefined, mycallback); | 792 this._runtimeAgent.callFunctionOn(this._objectId, functionDeclaration.to String(), args, true, true, false, undefined, undefined, mycallback); |
| 793 }, | 793 }, |
| 794 | 794 |
| 795 release: function() | 795 release: function() |
| 796 { | 796 { |
| 797 if (!this._objectId) | 797 if (!this._objectId) |
| 798 return; | 798 return; |
| 799 this._runtimeAgent.releaseObject(this._objectId); | 799 this._runtimeAgent.releaseObject(this._objectId); |
| (...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1510 }, | 1510 }, |
| 1511 | 1511 |
| 1512 /** | 1512 /** |
| 1513 * @return {!WebInspector.RemoteObject} | 1513 * @return {!WebInspector.RemoteObject} |
| 1514 */ | 1514 */ |
| 1515 object: function() | 1515 object: function() |
| 1516 { | 1516 { |
| 1517 return this._object; | 1517 return this._object; |
| 1518 } | 1518 } |
| 1519 } | 1519 } |
| OLD | NEW |