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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 return "null"; | 172 return "null"; |
173 | 173 |
174 var type = typeof remoteObject; | 174 var type = typeof remoteObject; |
175 if (type !== "object" && type !== "function") | 175 if (type !== "object" && type !== "function") |
176 return type; | 176 return type; |
177 | 177 |
178 return remoteObject.type; | 178 return remoteObject.type; |
179 } | 179 } |
180 | 180 |
181 /** | 181 /** |
| 182 * @param {!RuntimeAgent.RemoteObject|!WebInspector.RemoteObject} remoteObject |
| 183 * @return {!RuntimeAgent.CallArgument} |
| 184 */ |
| 185 WebInspector.RemoteObject.toCallArgument = function(remoteObject) |
| 186 { |
| 187 var type = /** @type {!RuntimeAgent.CallArgumentType.<string>} */ (remoteObj
ect.type); |
| 188 var value = remoteObject.value; |
| 189 |
| 190 // Handle special numbers: NaN, Infinity, -Infinity, -0. |
| 191 if (type === "number") { |
| 192 switch (remoteObject.description) { |
| 193 case "NaN": |
| 194 case "Infinity": |
| 195 case "-Infinity": |
| 196 case "-0": |
| 197 value = remoteObject.description; |
| 198 break; |
| 199 } |
| 200 } |
| 201 |
| 202 return { |
| 203 value: value, |
| 204 objectId: remoteObject.objectId, |
| 205 type: type |
| 206 }; |
| 207 } |
| 208 |
| 209 /** |
182 * @constructor | 210 * @constructor |
183 * @extends {WebInspector.RemoteObject} | 211 * @extends {WebInspector.RemoteObject} |
184 * @param {!WebInspector.Target|undefined} target | 212 * @param {!WebInspector.Target|undefined} target |
185 * @param {string|undefined} objectId | 213 * @param {string|undefined} objectId |
186 * @param {string} type | 214 * @param {string} type |
187 * @param {string|undefined} subtype | 215 * @param {string|undefined} subtype |
188 * @param {*} value | 216 * @param {*} value |
189 * @param {string=} description | 217 * @param {string=} description |
190 * @param {!RuntimeAgent.ObjectPreview=} preview | 218 * @param {!RuntimeAgent.ObjectPreview=} preview |
191 */ | 219 */ |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 * @param {function(string=)} callback | 411 * @param {function(string=)} callback |
384 */ | 412 */ |
385 doSetObjectPropertyValue: function(result, name, callback) | 413 doSetObjectPropertyValue: function(result, name, callback) |
386 { | 414 { |
387 // This assignment may be for a regular (data) property, and for an accc
essor property (with getter/setter). | 415 // This assignment may be for a regular (data) property, and for an accc
essor property (with getter/setter). |
388 // Note the sensitive matter about accessor property: the property may b
e physically defined in some proto object, | 416 // Note the sensitive matter about accessor property: the property may b
e physically defined in some proto object, |
389 // but logically it is bound to the object in question. JavaScript passe
s this object to getters/setters, not the object | 417 // but logically it is bound to the object in question. JavaScript passe
s this object to getters/setters, not the object |
390 // where property was defined; so do we. | 418 // where property was defined; so do we. |
391 var setPropertyValueFunction = "function(a, b) { this[a] = b; }"; | 419 var setPropertyValueFunction = "function(a, b) { this[a] = b; }"; |
392 | 420 |
393 var argv = [{ value: name }, this._toCallArgument(result)] | 421 var argv = [{ value: name }, WebInspector.RemoteObject.toCallArgument(re
sult)] |
394 this._runtimeAgent.callFunctionOn(this._objectId, setPropertyValueFuncti
on, argv, true, undefined, undefined, propertySetCallback); | 422 this._runtimeAgent.callFunctionOn(this._objectId, setPropertyValueFuncti
on, argv, true, undefined, undefined, propertySetCallback); |
395 | 423 |
396 /** | 424 /** |
397 * @param {?Protocol.Error} error | 425 * @param {?Protocol.Error} error |
398 * @param {!RuntimeAgent.RemoteObject} result | 426 * @param {!RuntimeAgent.RemoteObject} result |
399 * @param {boolean=} wasThrown | 427 * @param {boolean=} wasThrown |
400 */ | 428 */ |
401 function propertySetCallback(error, result, wasThrown) | 429 function propertySetCallback(error, result, wasThrown) |
402 { | 430 { |
403 if (error || wasThrown) { | 431 if (error || wasThrown) { |
404 callback(error || result.description); | 432 callback(error || result.description); |
405 return; | 433 return; |
406 } | 434 } |
407 callback(); | 435 callback(); |
408 } | 436 } |
409 }, | 437 }, |
410 | 438 |
411 /** | 439 /** |
412 * @param {!RuntimeAgent.RemoteObject} object | |
413 * @return {!RuntimeAgent.CallArgument} | |
414 */ | |
415 _toCallArgument: function(object) | |
416 { | |
417 return { value: object.value, objectId: object.objectId, type: /** @type
{!RuntimeAgent.CallArgumentType.<string>} */ (object.type) }; | |
418 }, | |
419 | |
420 /** | |
421 * @param {function(?DOMAgent.NodeId)} callback | 440 * @param {function(?DOMAgent.NodeId)} callback |
422 */ | 441 */ |
423 pushNodeToFrontend: function(callback) | 442 pushNodeToFrontend: function(callback) |
424 { | 443 { |
425 if (this._objectId) | 444 if (this._objectId) |
426 this._domAgent.pushNodeToFrontend(this._objectId, callback); | 445 this._domAgent.pushNodeToFrontend(this._objectId, callback); |
427 else | 446 else |
428 callback(0); | 447 callback(0); |
429 }, | 448 }, |
430 | 449 |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 }, | 667 }, |
649 | 668 |
650 /** | 669 /** |
651 * @override | 670 * @override |
652 * @param {!RuntimeAgent.RemoteObject} result | 671 * @param {!RuntimeAgent.RemoteObject} result |
653 * @param {string} name | 672 * @param {string} name |
654 * @param {function(string=)} callback | 673 * @param {function(string=)} callback |
655 */ | 674 */ |
656 doSetObjectPropertyValue: function(result, name, callback) | 675 doSetObjectPropertyValue: function(result, name, callback) |
657 { | 676 { |
658 this._debuggerAgent.setVariableValue(this._scopeRef.number, name, this._
toCallArgument(result), this._scopeRef.callFrameId, this._scopeRef.functionId, s
etVariableValueCallback.bind(this)); | 677 this._debuggerAgent.setVariableValue(this._scopeRef.number, name, WebIns
pector.RemoteObject.toCallArgument(result), this._scopeRef.callFrameId, this._sc
opeRef.functionId, setVariableValueCallback.bind(this)); |
659 | 678 |
660 /** | 679 /** |
661 * @param {?Protocol.Error} error | 680 * @param {?Protocol.Error} error |
662 * @this {WebInspector.ScopeRemoteObject} | 681 * @this {WebInspector.ScopeRemoteObject} |
663 */ | 682 */ |
664 function setVariableValueCallback(error) | 683 function setVariableValueCallback(error) |
665 { | 684 { |
666 if (error) { | 685 if (error) { |
667 callback(error); | 686 callback(error); |
668 return; | 687 return; |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
974 result = functionDeclaration.apply(target, rawArgs); | 993 result = functionDeclaration.apply(target, rawArgs); |
975 } catch (e) { | 994 } catch (e) { |
976 result = null; | 995 result = null; |
977 } | 996 } |
978 | 997 |
979 callback(result); | 998 callback(result); |
980 }, | 999 }, |
981 | 1000 |
982 __proto__: WebInspector.RemoteObject.prototype | 1001 __proto__: WebInspector.RemoteObject.prototype |
983 } | 1002 } |
OLD | NEW |