| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 /** | 79 /** |
| 80 * @param {boolean} accessorPropertiesOnly | 80 * @param {boolean} accessorPropertiesOnly |
| 81 * @param {function(?Array.<!WebInspector.RemoteObjectProperty>, ?Array.<!We
bInspector.RemoteObjectProperty>)} callback | 81 * @param {function(?Array.<!WebInspector.RemoteObjectProperty>, ?Array.<!We
bInspector.RemoteObjectProperty>)} callback |
| 82 */ | 82 */ |
| 83 getAllProperties: function(accessorPropertiesOnly, callback) | 83 getAllProperties: function(accessorPropertiesOnly, callback) |
| 84 { | 84 { |
| 85 throw "Not implemented"; | 85 throw "Not implemented"; |
| 86 }, | 86 }, |
| 87 | 87 |
| 88 /** | 88 /** |
| 89 * @param {function(this:Object, ...)} functionDeclaration | 89 * @param {function(this:Object, ...)|!String} functionDeclaration |
| 90 * @param {!Array.<!RuntimeAgent.CallArgument>=} args | 90 * @param {!Array.<!RuntimeAgent.CallArgument>=} args |
| 91 * @param {function(?WebInspector.RemoteObject, boolean=)=} callback | 91 * @param {function(?WebInspector.RemoteObject, boolean=)=} callback |
| 92 */ | 92 */ |
| 93 callFunction: function(functionDeclaration, args, callback) | 93 callFunction: function(functionDeclaration, args, callback) |
| 94 { | 94 { |
| 95 throw "Not implemented"; | 95 throw "Not implemented"; |
| 96 }, | 96 }, |
| 97 | 97 |
| 98 /** | 98 /** |
| 99 * @param {function(this:Object)} functionDeclaration | 99 * @param {function(this:Object)|!String} functionDeclaration |
| 100 * @param {!Array.<!RuntimeAgent.CallArgument>|undefined} args | 100 * @param {!Array.<!RuntimeAgent.CallArgument>|undefined} args |
| 101 * @param {function(*)} callback | 101 * @param {function(*)} callback |
| 102 */ | 102 */ |
| 103 callFunctionJSON: function(functionDeclaration, args, callback) | 103 callFunctionJSON: function(functionDeclaration, args, callback) |
| 104 { | 104 { |
| 105 throw "Not implemented"; | 105 throw "Not implemented"; |
| 106 }, | 106 }, |
| 107 | 107 |
| 108 /** | 108 /** |
| 109 * @return {!WebInspector.Target} | 109 * @return {!WebInspector.Target} |
| (...skipping 15 matching lines...) Expand all Loading... |
| 125 { | 125 { |
| 126 WebInspector.Revealer.reveal(this); | 126 WebInspector.Revealer.reveal(this); |
| 127 }, | 127 }, |
| 128 | 128 |
| 129 /** | 129 /** |
| 130 * @param {function(?DebuggerAgent.FunctionDetails)} callback | 130 * @param {function(?DebuggerAgent.FunctionDetails)} callback |
| 131 */ | 131 */ |
| 132 functionDetails: function(callback) | 132 functionDetails: function(callback) |
| 133 { | 133 { |
| 134 callback(null); | 134 callback(null); |
| 135 } | 135 }, |
| 136 |
| 137 /** @return {string|undefined} */ |
| 138 get language() |
| 139 { |
| 140 throw "Not implemented"; |
| 141 }, |
| 136 } | 142 } |
| 137 | 143 |
| 138 /** | 144 /** |
| 139 * @param {*} value | 145 * @param {*} value |
| 140 * @return {!WebInspector.RemoteObject} | 146 * @return {!WebInspector.RemoteObject} |
| 141 */ | 147 */ |
| 142 WebInspector.RemoteObject.fromLocalObject = function(value) | 148 WebInspector.RemoteObject.fromLocalObject = function(value) |
| 143 { | 149 { |
| 144 return new WebInspector.LocalJSONObject(value); | 150 return new WebInspector.LocalJSONObject(value); |
| 145 } | 151 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 * @constructor | 198 * @constructor |
| 193 * @extends {WebInspector.RemoteObject} | 199 * @extends {WebInspector.RemoteObject} |
| 194 * @param {!WebInspector.Target} target | 200 * @param {!WebInspector.Target} target |
| 195 * @param {string|undefined} objectId | 201 * @param {string|undefined} objectId |
| 196 * @param {string} type | 202 * @param {string} type |
| 197 * @param {string|undefined} subtype | 203 * @param {string|undefined} subtype |
| 198 * @param {*} value | 204 * @param {*} value |
| 199 * @param {string=} description | 205 * @param {string=} description |
| 200 * @param {!RuntimeAgent.ObjectPreview=} preview | 206 * @param {!RuntimeAgent.ObjectPreview=} preview |
| 201 */ | 207 */ |
| 202 WebInspector.RemoteObjectImpl = function(target, objectId, type, subtype, value,
description, preview) | 208 WebInspector.RemoteObjectImpl = function(target, objectId, type, subtype, value,
description, preview, language) |
| 203 { | 209 { |
| 204 WebInspector.RemoteObject.call(this); | 210 WebInspector.RemoteObject.call(this); |
| 205 | 211 |
| 206 this._target = target; | 212 this._target = target; |
| 207 this._runtimeAgent = target.runtimeAgent(); | 213 this._runtimeAgent = target.runtimeAgent(); |
| 208 this._domModel = target.domModel; | 214 this._domModel = target.domModel; |
| 209 | 215 |
| 210 this._type = type; | 216 this._type = type; |
| 211 this._subtype = subtype; | 217 this._subtype = subtype; |
| 218 this._language = language; |
| 212 if (objectId) { | 219 if (objectId) { |
| 213 // handle | 220 // handle |
| 214 this._objectId = objectId; | 221 this._objectId = objectId; |
| 215 this._description = description; | 222 this._description = description; |
| 216 this._hasChildren = true; | 223 this._hasChildren = true; |
| 217 this._preview = preview; | 224 this._preview = preview; |
| 225 if (value !== undefined) |
| 226 this.value = value; |
| 218 } else { | 227 } else { |
| 219 // Primitive or null object. | 228 // Primitive or null object. |
| 220 console.assert(type !== "object" || value === null); | 229 console.assert(type !== "object" || value === null); |
| 221 this._description = description || (value + ""); | 230 this._description = description || (value + ""); |
| 222 this._hasChildren = false; | 231 this._hasChildren = false; |
| 223 // Handle special numbers: NaN, Infinity, -Infinity, -0. | 232 // Handle special numbers: NaN, Infinity, -Infinity, -0. |
| 224 if (type === "number" && typeof value !== "number") | 233 if (type === "number" && typeof value !== "number") |
| 225 this.value = Number(value); | 234 this.value = Number(value); |
| 226 else | 235 else |
| 227 this.value = value; | 236 this.value = value; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 258 { | 267 { |
| 259 return this._hasChildren; | 268 return this._hasChildren; |
| 260 }, | 269 }, |
| 261 | 270 |
| 262 /** @return {!RuntimeAgent.ObjectPreview|undefined} */ | 271 /** @return {!RuntimeAgent.ObjectPreview|undefined} */ |
| 263 get preview() | 272 get preview() |
| 264 { | 273 { |
| 265 return this._preview; | 274 return this._preview; |
| 266 }, | 275 }, |
| 267 | 276 |
| 277 /** @return {string|undefined} */ |
| 278 get language() |
| 279 { |
| 280 return this._language; |
| 281 }, |
| 282 |
| 268 /** | 283 /** |
| 269 * @param {function(?Array.<!WebInspector.RemoteObjectProperty>, ?Array.<!We
bInspector.RemoteObjectProperty>)} callback | 284 * @param {function(?Array.<!WebInspector.RemoteObjectProperty>, ?Array.<!We
bInspector.RemoteObjectProperty>)} callback |
| 270 */ | 285 */ |
| 271 getOwnProperties: function(callback) | 286 getOwnProperties: function(callback) |
| 272 { | 287 { |
| 273 this.doGetProperties(true, false, callback); | 288 this.doGetProperties(true, false, callback); |
| 274 }, | 289 }, |
| 275 | 290 |
| 276 /** | 291 /** |
| 277 * @param {boolean} accessorPropertiesOnly | 292 * @param {boolean} accessorPropertiesOnly |
| 278 * @param {function(?Array.<!WebInspector.RemoteObjectProperty>, ?Array.<!We
bInspector.RemoteObjectProperty>)} callback | 293 * @param {function(?Array.<!WebInspector.RemoteObjectProperty>, ?Array.<!We
bInspector.RemoteObjectProperty>)} callback |
| 279 */ | 294 */ |
| 280 getAllProperties: function(accessorPropertiesOnly, callback) | 295 getAllProperties: function(accessorPropertiesOnly, callback) |
| 281 { | 296 { |
| 282 this.doGetProperties(false, accessorPropertiesOnly, callback); | 297 this.doGetProperties(false, accessorPropertiesOnly, callback); |
| 283 }, | 298 }, |
| 284 | 299 |
| 285 /** | 300 /** |
| 286 * @param {!Array.<string>} propertyPath | 301 * @param {!Array.<string>} propertyPath |
| 287 * @param {function(?WebInspector.RemoteObject, boolean=)} callback | 302 * @param {function(?WebInspector.RemoteObject, boolean=)} callback |
| 288 */ | 303 */ |
| 289 getProperty: function(propertyPath, callback) | 304 getProperty: function(propertyPath, callback) |
| 290 { | 305 { |
| 291 /** | 306 /** |
| 292 * @param {string} arrayStr | 307 * @param {string} arrayStr |
| 293 * @suppressReceiverCheck | 308 * @suppressReceiverCheck |
| 294 * @this {Object} | 309 * @this {Object} |
| 295 */ | 310 */ |
| 296 function remoteFunction(arrayStr) | 311 function mycallback(error, result, wasThrown) |
| 297 { | 312 { |
| 298 var result = this; | 313 if (error) |
| 299 var properties = JSON.parse(arrayStr); | 314 callback(null, false); |
| 300 for (var i = 0, n = properties.length; i < n; ++i) | 315 else |
| 301 result = result[properties[i]]; | 316 callback(this.target().runtimeModel.createRemoteObject(result),
wasThrown); |
| 302 return result; | |
| 303 } | 317 } |
| 304 | 318 |
| 305 var args = [{ value: JSON.stringify(propertyPath) }]; | 319 this._runtimeAgent.getProperty(this._objectId, propertyPath, mycallback.
bind(this)); |
| 306 this.callFunction(remoteFunction, args, callback); | |
| 307 }, | 320 }, |
| 308 | 321 |
| 309 /** | 322 /** |
| 310 * @param {boolean} ownProperties | 323 * @param {boolean} ownProperties |
| 311 * @param {boolean} accessorPropertiesOnly | 324 * @param {boolean} accessorPropertiesOnly |
| 312 * @param {?function(?Array.<!WebInspector.RemoteObjectProperty>, ?Array.<!W
ebInspector.RemoteObjectProperty>)} callback | 325 * @param {?function(?Array.<!WebInspector.RemoteObjectProperty>, ?Array.<!W
ebInspector.RemoteObjectProperty>)} callback |
| 313 */ | 326 */ |
| 314 doGetProperties: function(ownProperties, accessorPropertiesOnly, callback) | 327 doGetProperties: function(ownProperties, accessorPropertiesOnly, callback) |
| 315 { | 328 { |
| 316 if (!this._objectId) { | 329 if (!this._objectId) { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 { | 454 { |
| 442 this._domModel.highlightDOMNode(undefined, undefined, this._objectId); | 455 this._domModel.highlightDOMNode(undefined, undefined, this._objectId); |
| 443 }, | 456 }, |
| 444 | 457 |
| 445 hideDOMNodeHighlight: function() | 458 hideDOMNodeHighlight: function() |
| 446 { | 459 { |
| 447 this._domModel.hideDOMNodeHighlight(); | 460 this._domModel.hideDOMNodeHighlight(); |
| 448 }, | 461 }, |
| 449 | 462 |
| 450 /** | 463 /** |
| 451 * @param {function(this:Object, ...)} functionDeclaration | 464 * @param {function(this:Object, ...)|!String} functionDeclaration |
| 452 * @param {!Array.<!RuntimeAgent.CallArgument>=} args | 465 * @param {!Array.<!RuntimeAgent.CallArgument>=} args |
| 453 * @param {function(?WebInspector.RemoteObject, boolean=)=} callback | 466 * @param {function(?WebInspector.RemoteObject, boolean=)=} callback |
| 454 */ | 467 */ |
| 455 callFunction: function(functionDeclaration, args, callback) | 468 callFunction: function(functionDeclaration, args, callback) |
| 456 { | 469 { |
| 457 /** | 470 /** |
| 458 * @param {?Protocol.Error} error | 471 * @param {?Protocol.Error} error |
| 459 * @param {!RuntimeAgent.RemoteObject} result | 472 * @param {!RuntimeAgent.RemoteObject} result |
| 460 * @param {boolean=} wasThrown | 473 * @param {boolean=} wasThrown |
| 461 * @this {WebInspector.RemoteObjectImpl} | 474 * @this {WebInspector.RemoteObjectImpl} |
| 462 */ | 475 */ |
| 463 function mycallback(error, result, wasThrown) | 476 function mycallback(error, result, wasThrown) |
| 464 { | 477 { |
| 465 if (!callback) | 478 if (!callback) |
| 466 return; | 479 return; |
| 467 if (error) | 480 if (error) |
| 468 callback(null, false); | 481 callback(null, false); |
| 469 else | 482 else |
| 470 callback(this.target().runtimeModel.createRemoteObject(result),
wasThrown); | 483 callback(this.target().runtimeModel.createRemoteObject(result),
wasThrown); |
| 471 } | 484 } |
| 472 | 485 |
| 473 this._runtimeAgent.callFunctionOn(this._objectId, functionDeclaration.to
String(), args, true, undefined, undefined, mycallback.bind(this)); | 486 this._runtimeAgent.callFunctionOn(this._objectId, functionDeclaration.to
String(), args, true, undefined, undefined, mycallback.bind(this)); |
| 474 }, | 487 }, |
| 475 | 488 |
| 476 /** | 489 /** |
| 477 * @param {function(this:Object)} functionDeclaration | 490 * @param {function(this:Object)|!String} functionDeclaration |
| 478 * @param {!Array.<!RuntimeAgent.CallArgument>|undefined} args | 491 * @param {!Array.<!RuntimeAgent.CallArgument>|undefined} args |
| 479 * @param {function(*)} callback | 492 * @param {function(*)} callback |
| 480 */ | 493 */ |
| 481 callFunctionJSON: function(functionDeclaration, args, callback) | 494 callFunctionJSON: function(functionDeclaration, args, callback) |
| 482 { | 495 { |
| 483 /** | 496 /** |
| 484 * @param {?Protocol.Error} error | 497 * @param {?Protocol.Error} error |
| 485 * @param {!RuntimeAgent.RemoteObject} result | 498 * @param {!RuntimeAgent.RemoteObject} result |
| 486 * @param {boolean=} wasThrown | 499 * @param {boolean=} wasThrown |
| 487 */ | 500 */ |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 918 | 931 |
| 919 /** | 932 /** |
| 920 * @return {number} | 933 * @return {number} |
| 921 */ | 934 */ |
| 922 arrayLength: function() | 935 arrayLength: function() |
| 923 { | 936 { |
| 924 return this._value instanceof Array ? this._value.length : 0; | 937 return this._value instanceof Array ? this._value.length : 0; |
| 925 }, | 938 }, |
| 926 | 939 |
| 927 /** | 940 /** |
| 928 * @param {function(this:Object, ...)} functionDeclaration | 941 * @param {function(this:Object, ...)|!String} functionDeclaration |
| 929 * @param {!Array.<!RuntimeAgent.CallArgument>=} args | 942 * @param {!Array.<!RuntimeAgent.CallArgument>=} args |
| 930 * @param {function(?WebInspector.RemoteObject, boolean=)=} callback | 943 * @param {function(?WebInspector.RemoteObject, boolean=)=} callback |
| 931 */ | 944 */ |
| 932 callFunction: function(functionDeclaration, args, callback) | 945 callFunction: function(functionDeclaration, args, callback) |
| 933 { | 946 { |
| 934 var target = /** @type {?Object} */ (this._value); | 947 var target = /** @type {?Object} */ (this._value); |
| 935 var rawArgs = args ? args.map(function(arg) {return arg.value;}) : []; | 948 var rawArgs = args ? args.map(function(arg) {return arg.value;}) : []; |
| 936 | 949 |
| 937 var result; | 950 var result; |
| 938 var wasThrown = false; | 951 var wasThrown = false; |
| 939 try { | 952 try { |
| 940 result = functionDeclaration.apply(target, rawArgs); | 953 result = functionDeclaration.apply(target, rawArgs); |
| 941 } catch (e) { | 954 } catch (e) { |
| 942 wasThrown = true; | 955 wasThrown = true; |
| 943 } | 956 } |
| 944 | 957 |
| 945 if (!callback) | 958 if (!callback) |
| 946 return; | 959 return; |
| 947 callback(WebInspector.RemoteObject.fromLocalObject(result), wasThrown); | 960 callback(WebInspector.RemoteObject.fromLocalObject(result), wasThrown); |
| 948 }, | 961 }, |
| 949 | 962 |
| 950 /** | 963 /** |
| 951 * @param {function(this:Object)} functionDeclaration | 964 * @param {function(this:Object)|!String} functionDeclaration |
| 952 * @param {!Array.<!RuntimeAgent.CallArgument>|undefined} args | 965 * @param {!Array.<!RuntimeAgent.CallArgument>|undefined} args |
| 953 * @param {function(*)} callback | 966 * @param {function(*)} callback |
| 954 */ | 967 */ |
| 955 callFunctionJSON: function(functionDeclaration, args, callback) | 968 callFunctionJSON: function(functionDeclaration, args, callback) |
| 956 { | 969 { |
| 957 var target = /** @type {?Object} */ (this._value); | 970 var target = /** @type {?Object} */ (this._value); |
| 958 var rawArgs = args ? args.map(function(arg) {return arg.value;}) : []; | 971 var rawArgs = args ? args.map(function(arg) {return arg.value;}) : []; |
| 959 | 972 |
| 960 var result; | 973 var result; |
| 961 try { | 974 try { |
| 962 result = functionDeclaration.apply(target, rawArgs); | 975 result = functionDeclaration.apply(target, rawArgs); |
| 963 } catch (e) { | 976 } catch (e) { |
| 964 result = null; | 977 result = null; |
| 965 } | 978 } |
| 966 | 979 |
| 967 callback(result); | 980 callback(result); |
| 968 }, | 981 }, |
| 969 | 982 |
| 970 __proto__: WebInspector.RemoteObject.prototype | 983 __proto__: WebInspector.RemoteObject.prototype |
| 971 } | 984 } |
| OLD | NEW |