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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 * @param {boolean=} wasThrown | 358 * @param {boolean=} wasThrown |
359 * @this {WebInspector.RemoteObject} | 359 * @this {WebInspector.RemoteObject} |
360 */ | 360 */ |
361 function evaluatedCallback(error, result, wasThrown) | 361 function evaluatedCallback(error, result, wasThrown) |
362 { | 362 { |
363 if (error || wasThrown) { | 363 if (error || wasThrown) { |
364 callback(error || result.description); | 364 callback(error || result.description); |
365 return; | 365 return; |
366 } | 366 } |
367 | 367 |
368 this.doSetObjectPropertyValue(result, name, callback); | 368 this.setObjectPropertyValue(name, result, callback); |
369 | 369 |
370 if (result.objectId) | 370 if (result.objectId) |
371 this._runtimeAgent.releaseObject(result.objectId); | 371 this._runtimeAgent.releaseObject(result.objectId); |
372 } | 372 } |
373 }, | 373 }, |
374 | 374 |
375 /** | 375 /** |
376 * @param {!RuntimeAgent.RemoteObject} result | |
377 * @param {string} name | 376 * @param {string} name |
| 377 * @param {!RuntimeAgent.RemoteObject|!WebInspector.RemoteObject} result |
378 * @param {function(string=)} callback | 378 * @param {function(string=)} callback |
379 */ | 379 */ |
380 doSetObjectPropertyValue: function(result, name, callback) | 380 setObjectPropertyValue: function(name, result, callback) |
381 { | 381 { |
382 // This assignment may be for a regular (data) property, and for an accc
essor property (with getter/setter). | 382 // This assignment may be for a regular (data) property, and for an accc
essor property (with getter/setter). |
383 // Note the sensitive matter about accessor property: the property may b
e physically defined in some proto object, | 383 // Note the sensitive matter about accessor property: the property may b
e physically defined in some proto object, |
384 // but logically it is bound to the object in question. JavaScript passe
s this object to getters/setters, not the object | 384 // but logically it is bound to the object in question. JavaScript passe
s this object to getters/setters, not the object |
385 // where property was defined; so do we. | 385 // where property was defined; so do we. |
386 var setPropertyValueFunction = "function(a, b) { this[a] = b; }"; | 386 var setPropertyValueFunction = "function(a, b) { this[a] = b; }"; |
387 | 387 |
388 // Special case for NaN, Infinity, -Infinity, -0. | 388 // Special case for NaN, Infinity, -Infinity, -0. |
389 if (result.type === "number" && String(result.value) !== result.descript
ion) | 389 if (result.type === "number" && String(result.value) !== result.descript
ion) |
390 setPropertyValueFunction = "function(a) { this[a] = " + result.descr
iption + "; }"; | 390 setPropertyValueFunction = "function(a) { this[a] = " + result.descr
iption + "; }"; |
391 | 391 |
392 delete result.description; // Optimize on traffic. | 392 var argv = [{ value: name }, { value: result.value, objectId: result.obj
ectId }]; |
393 this._runtimeAgent.callFunctionOn(this._objectId, setPropertyValueFuncti
on, [{ value:name }, result], true, undefined, undefined, propertySetCallback.bi
nd(this)); | 393 this._runtimeAgent.callFunctionOn(this._objectId, setPropertyValueFuncti
on, argv, true, undefined, undefined, propertySetCallback.bind(this)); |
394 | 394 |
395 /** | 395 /** |
396 * @param {?Protocol.Error} error | 396 * @param {?Protocol.Error} error |
397 * @param {!RuntimeAgent.RemoteObject} result | 397 * @param {!RuntimeAgent.RemoteObject} result |
398 * @param {boolean=} wasThrown | 398 * @param {boolean=} wasThrown |
399 */ | 399 */ |
400 function propertySetCallback(error, result, wasThrown) | 400 function propertySetCallback(error, result, wasThrown) |
401 { | 401 { |
402 if (error || wasThrown) { | 402 if (error || wasThrown) { |
403 callback(error || result.description); | 403 callback(error || result.description); |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 if (this._scopeRef && properties instanceof Array) | 632 if (this._scopeRef && properties instanceof Array) |
633 this._savedScopeProperties = properties.slice(); | 633 this._savedScopeProperties = properties.slice(); |
634 callback(properties, internalProperties); | 634 callback(properties, internalProperties); |
635 } | 635 } |
636 | 636 |
637 WebInspector.RemoteObjectImpl.prototype.doGetProperties.call(this, ownPr
operties, accessorPropertiesOnly, wrappedCallback.bind(this)); | 637 WebInspector.RemoteObjectImpl.prototype.doGetProperties.call(this, ownPr
operties, accessorPropertiesOnly, wrappedCallback.bind(this)); |
638 }, | 638 }, |
639 | 639 |
640 /** | 640 /** |
641 * @override | 641 * @override |
| 642 * @param {string} name |
642 * @param {!RuntimeAgent.RemoteObject} result | 643 * @param {!RuntimeAgent.RemoteObject} result |
643 * @param {string} name | |
644 * @param {function(string=)} callback | 644 * @param {function(string=)} callback |
645 */ | 645 */ |
646 doSetObjectPropertyValue: function(result, name, callback) | 646 setObjectPropertyValue: function(name, result, callback) |
647 { | 647 { |
648 var newValue; | 648 var newValue; |
649 | 649 |
650 switch (result.type) { | 650 switch (result.type) { |
651 case "undefined": | 651 case "undefined": |
652 newValue = {}; | 652 newValue = {}; |
653 break; | 653 break; |
654 case "object": | 654 case "object": |
655 case "function": | 655 case "function": |
656 newValue = { objectId: result.objectId }; | 656 newValue = { objectId: result.objectId }; |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
978 result = functionDeclaration.apply(target, rawArgs); | 978 result = functionDeclaration.apply(target, rawArgs); |
979 } catch (e) { | 979 } catch (e) { |
980 result = null; | 980 result = null; |
981 } | 981 } |
982 | 982 |
983 callback(result); | 983 callback(result); |
984 }, | 984 }, |
985 | 985 |
986 __proto__: WebInspector.RemoteObject.prototype | 986 __proto__: WebInspector.RemoteObject.prototype |
987 } | 987 } |
OLD | NEW |