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 20 matching lines...) Expand all Loading... |
31 /** | 31 /** |
32 * @typedef {{object: ?WebInspector.RemoteObject, wasThrown: (boolean|undefined)
}} | 32 * @typedef {{object: ?WebInspector.RemoteObject, wasThrown: (boolean|undefined)
}} |
33 */ | 33 */ |
34 WebInspector.CallFunctionResult; | 34 WebInspector.CallFunctionResult; |
35 | 35 |
36 /** | 36 /** |
37 * This may not be an interface due to "instanceof WebInspector.RemoteObject" ch
ecks in the code. | 37 * This may not be an interface due to "instanceof WebInspector.RemoteObject" ch
ecks in the code. |
38 * | 38 * |
39 * @constructor | 39 * @constructor |
40 */ | 40 */ |
41 WebInspector.RemoteObject = function() { } | 41 WebInspector.RemoteObject = function() { }; |
42 | 42 |
43 WebInspector.RemoteObject.prototype = { | 43 WebInspector.RemoteObject.prototype = { |
44 | 44 |
45 /** | 45 /** |
46 * @return {?RuntimeAgent.CustomPreview} | 46 * @return {?RuntimeAgent.CustomPreview} |
47 */ | 47 */ |
48 customPreview: function() | 48 customPreview: function() |
49 { | 49 { |
50 return null; | 50 return null; |
51 }, | 51 }, |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 throw new Error("DebuggerModel-less object"); | 275 throw new Error("DebuggerModel-less object"); |
276 }, | 276 }, |
277 | 277 |
278 /** | 278 /** |
279 * @return {boolean} | 279 * @return {boolean} |
280 */ | 280 */ |
281 isNode: function() | 281 isNode: function() |
282 { | 282 { |
283 return false; | 283 return false; |
284 } | 284 } |
285 } | 285 }; |
286 | 286 |
287 /** | 287 /** |
288 * @param {*} value | 288 * @param {*} value |
289 * @return {!WebInspector.RemoteObject} | 289 * @return {!WebInspector.RemoteObject} |
290 */ | 290 */ |
291 WebInspector.RemoteObject.fromLocalObject = function(value) | 291 WebInspector.RemoteObject.fromLocalObject = function(value) |
292 { | 292 { |
293 return new WebInspector.LocalJSONObject(value); | 293 return new WebInspector.LocalJSONObject(value); |
294 } | 294 }; |
295 | 295 |
296 /** | 296 /** |
297 * @param {!WebInspector.RemoteObject} remoteObject | 297 * @param {!WebInspector.RemoteObject} remoteObject |
298 * @return {string} | 298 * @return {string} |
299 */ | 299 */ |
300 WebInspector.RemoteObject.type = function(remoteObject) | 300 WebInspector.RemoteObject.type = function(remoteObject) |
301 { | 301 { |
302 if (remoteObject === null) | 302 if (remoteObject === null) |
303 return "null"; | 303 return "null"; |
304 | 304 |
305 var type = typeof remoteObject; | 305 var type = typeof remoteObject; |
306 if (type !== "object" && type !== "function") | 306 if (type !== "object" && type !== "function") |
307 return type; | 307 return type; |
308 | 308 |
309 return remoteObject.type; | 309 return remoteObject.type; |
310 } | 310 }; |
311 | 311 |
312 /** | 312 /** |
313 * @param {!WebInspector.RemoteObject|!RuntimeAgent.RemoteObject|!RuntimeAgent.O
bjectPreview} object | 313 * @param {!WebInspector.RemoteObject|!RuntimeAgent.RemoteObject|!RuntimeAgent.O
bjectPreview} object |
314 * @return {number} | 314 * @return {number} |
315 */ | 315 */ |
316 WebInspector.RemoteObject.arrayLength = function(object) | 316 WebInspector.RemoteObject.arrayLength = function(object) |
317 { | 317 { |
318 if (object.subtype !== "array" && object.subtype !== "typedarray") | 318 if (object.subtype !== "array" && object.subtype !== "typedarray") |
319 return 0; | 319 return 0; |
320 var matches = object.description.match(/\[([0-9]+)\]/); | 320 var matches = object.description.match(/\[([0-9]+)\]/); |
321 if (!matches) | 321 if (!matches) |
322 return 0; | 322 return 0; |
323 return parseInt(matches[1], 10); | 323 return parseInt(matches[1], 10); |
324 } | 324 }; |
325 | 325 |
326 /** | 326 /** |
327 * @param {!RuntimeAgent.RemoteObject|!WebInspector.RemoteObject|number|string|b
oolean|undefined|null} object | 327 * @param {!RuntimeAgent.RemoteObject|!WebInspector.RemoteObject|number|string|b
oolean|undefined|null} object |
328 * @return {!RuntimeAgent.CallArgument} | 328 * @return {!RuntimeAgent.CallArgument} |
329 */ | 329 */ |
330 WebInspector.RemoteObject.toCallArgument = function(object) | 330 WebInspector.RemoteObject.toCallArgument = function(object) |
331 { | 331 { |
332 var type = typeof object; | 332 var type = typeof object; |
333 if (type === "undefined") | 333 if (type === "undefined") |
334 return {}; | 334 return {}; |
(...skipping 19 matching lines...) Expand all Loading... |
354 return { unserializableValue: object.unserializableValue }; | 354 return { unserializableValue: object.unserializableValue }; |
355 if (typeof object._unserializableValue !== "undefined") | 355 if (typeof object._unserializableValue !== "undefined") |
356 return { unserializableValue: object._unserializableValue }; | 356 return { unserializableValue: object._unserializableValue }; |
357 | 357 |
358 if (typeof object.objectId !== "undefined") | 358 if (typeof object.objectId !== "undefined") |
359 return { objectId: object.objectId }; | 359 return { objectId: object.objectId }; |
360 if (typeof object._objectId !== "undefined") | 360 if (typeof object._objectId !== "undefined") |
361 return { objectId: object._objectId }; | 361 return { objectId: object._objectId }; |
362 | 362 |
363 return { value: object.value }; | 363 return { value: object.value }; |
364 } | 364 }; |
365 | 365 |
366 /** | 366 /** |
367 * @constructor | 367 * @constructor |
368 * @extends {WebInspector.RemoteObject} | 368 * @extends {WebInspector.RemoteObject} |
369 * @param {!WebInspector.Target} target | 369 * @param {!WebInspector.Target} target |
370 * @param {string|undefined} objectId | 370 * @param {string|undefined} objectId |
371 * @param {string} type | 371 * @param {string} type |
372 * @param {string|undefined} subtype | 372 * @param {string|undefined} subtype |
373 * @param {*} value | 373 * @param {*} value |
374 * @param {!RuntimeAgent.UnserializableValue=} unserializableValue | 374 * @param {!RuntimeAgent.UnserializableValue=} unserializableValue |
(...skipping 30 matching lines...) Expand all Loading... |
405 unserializableValue === RuntimeAgent.UnserializableValue.NaN) { | 405 unserializableValue === RuntimeAgent.UnserializableValue.NaN) { |
406 this.value = Number(unserializableValue); | 406 this.value = Number(unserializableValue); |
407 } else { | 407 } else { |
408 this.value = unserializableValue; | 408 this.value = unserializableValue; |
409 } | 409 } |
410 } else { | 410 } else { |
411 this.value = value; | 411 this.value = value; |
412 } | 412 } |
413 } | 413 } |
414 this._customPreview = customPreview || null; | 414 this._customPreview = customPreview || null; |
415 } | 415 }; |
416 | 416 |
417 WebInspector.RemoteObjectImpl.prototype = { | 417 WebInspector.RemoteObjectImpl.prototype = { |
418 | 418 |
419 /** | 419 /** |
420 * @override | 420 * @override |
421 * @return {?RuntimeAgent.CustomPreview} | 421 * @return {?RuntimeAgent.CustomPreview} |
422 */ | 422 */ |
423 customPreview: function() | 423 customPreview: function() |
424 { | 424 { |
425 return this._customPreview; | 425 return this._customPreview; |
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1008 | 1008 |
1009 /** | 1009 /** |
1010 * @constructor | 1010 * @constructor |
1011 * @param {number} number | 1011 * @param {number} number |
1012 * @param {string=} callFrameId | 1012 * @param {string=} callFrameId |
1013 */ | 1013 */ |
1014 WebInspector.ScopeRef = function(number, callFrameId) | 1014 WebInspector.ScopeRef = function(number, callFrameId) |
1015 { | 1015 { |
1016 this.number = number; | 1016 this.number = number; |
1017 this.callFrameId = callFrameId; | 1017 this.callFrameId = callFrameId; |
1018 } | 1018 }; |
1019 | 1019 |
1020 /** | 1020 /** |
1021 * @constructor | 1021 * @constructor |
1022 * @param {string} name | 1022 * @param {string} name |
1023 * @param {?WebInspector.RemoteObject} value | 1023 * @param {?WebInspector.RemoteObject} value |
1024 * @param {boolean=} enumerable | 1024 * @param {boolean=} enumerable |
1025 * @param {boolean=} writable | 1025 * @param {boolean=} writable |
1026 * @param {boolean=} isOwn | 1026 * @param {boolean=} isOwn |
1027 * @param {boolean=} wasThrown | 1027 * @param {boolean=} wasThrown |
1028 * @param {boolean=} synthetic | 1028 * @param {boolean=} synthetic |
1029 * @param {?WebInspector.RemoteObject=} symbol | 1029 * @param {?WebInspector.RemoteObject=} symbol |
1030 */ | 1030 */ |
1031 WebInspector.RemoteObjectProperty = function(name, value, enumerable, writable,
isOwn, wasThrown, symbol, synthetic) | 1031 WebInspector.RemoteObjectProperty = function(name, value, enumerable, writable,
isOwn, wasThrown, symbol, synthetic) |
1032 { | 1032 { |
1033 this.name = name; | 1033 this.name = name; |
1034 if (value !== null) | 1034 if (value !== null) |
1035 this.value = value; | 1035 this.value = value; |
1036 this.enumerable = typeof enumerable !== "undefined" ? enumerable : true; | 1036 this.enumerable = typeof enumerable !== "undefined" ? enumerable : true; |
1037 this.writable = typeof writable !== "undefined" ? writable : true; | 1037 this.writable = typeof writable !== "undefined" ? writable : true; |
1038 this.isOwn = !!isOwn; | 1038 this.isOwn = !!isOwn; |
1039 this.wasThrown = !!wasThrown; | 1039 this.wasThrown = !!wasThrown; |
1040 if (symbol) | 1040 if (symbol) |
1041 this.symbol = symbol; | 1041 this.symbol = symbol; |
1042 this.synthetic = !!synthetic; | 1042 this.synthetic = !!synthetic; |
1043 } | 1043 }; |
1044 | 1044 |
1045 WebInspector.RemoteObjectProperty.prototype = { | 1045 WebInspector.RemoteObjectProperty.prototype = { |
1046 /** | 1046 /** |
1047 * @return {boolean} | 1047 * @return {boolean} |
1048 */ | 1048 */ |
1049 isAccessorProperty: function() | 1049 isAccessorProperty: function() |
1050 { | 1050 { |
1051 return !!(this.getter || this.setter); | 1051 return !!(this.getter || this.setter); |
1052 } | 1052 } |
1053 }; | 1053 }; |
1054 | 1054 |
1055 // Below is a wrapper around a local object that implements the RemoteObject int
erface, | 1055 // Below is a wrapper around a local object that implements the RemoteObject int
erface, |
1056 // which can be used by the UI code (primarily ObjectPropertiesSection). | 1056 // which can be used by the UI code (primarily ObjectPropertiesSection). |
1057 // Note that only JSON-compliant objects are currently supported, as there's no
provision | 1057 // Note that only JSON-compliant objects are currently supported, as there's no
provision |
1058 // for traversing prototypes, extracting class names via constructor, handling p
roperties | 1058 // for traversing prototypes, extracting class names via constructor, handling p
roperties |
1059 // or functions. | 1059 // or functions. |
1060 | 1060 |
1061 /** | 1061 /** |
1062 * @constructor | 1062 * @constructor |
1063 * @extends {WebInspector.RemoteObject} | 1063 * @extends {WebInspector.RemoteObject} |
1064 * @param {*} value | 1064 * @param {*} value |
1065 */ | 1065 */ |
1066 WebInspector.LocalJSONObject = function(value) | 1066 WebInspector.LocalJSONObject = function(value) |
1067 { | 1067 { |
1068 WebInspector.RemoteObject.call(this); | 1068 WebInspector.RemoteObject.call(this); |
1069 this._value = value; | 1069 this._value = value; |
1070 } | 1070 }; |
1071 | 1071 |
1072 WebInspector.LocalJSONObject.prototype = { | 1072 WebInspector.LocalJSONObject.prototype = { |
1073 /** | 1073 /** |
1074 * @override | 1074 * @override |
1075 * @return {string} | 1075 * @return {string} |
1076 */ | 1076 */ |
1077 get description() | 1077 get description() |
1078 { | 1078 { |
1079 if (this._cachedDescription) | 1079 if (this._cachedDescription) |
1080 return this._cachedDescription; | 1080 return this._cachedDescription; |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1304 try { | 1304 try { |
1305 result = functionDeclaration.apply(target, rawArgs); | 1305 result = functionDeclaration.apply(target, rawArgs); |
1306 } catch (e) { | 1306 } catch (e) { |
1307 result = null; | 1307 result = null; |
1308 } | 1308 } |
1309 | 1309 |
1310 callback(result); | 1310 callback(result); |
1311 }, | 1311 }, |
1312 | 1312 |
1313 __proto__: WebInspector.RemoteObject.prototype | 1313 __proto__: WebInspector.RemoteObject.prototype |
1314 } | 1314 }; |
1315 | 1315 |
1316 /** | 1316 /** |
1317 * @constructor | 1317 * @constructor |
1318 * @param {!WebInspector.RemoteObject} object | 1318 * @param {!WebInspector.RemoteObject} object |
1319 */ | 1319 */ |
1320 WebInspector.RemoteArray = function(object) | 1320 WebInspector.RemoteArray = function(object) |
1321 { | 1321 { |
1322 this._object = object; | 1322 this._object = object; |
1323 }; | 1323 }; |
1324 | 1324 |
1325 /** | 1325 /** |
1326 * @param {?WebInspector.RemoteObject} object | 1326 * @param {?WebInspector.RemoteObject} object |
1327 * @return {!WebInspector.RemoteArray} | 1327 * @return {!WebInspector.RemoteArray} |
1328 */ | 1328 */ |
1329 WebInspector.RemoteArray.objectAsArray = function(object) | 1329 WebInspector.RemoteArray.objectAsArray = function(object) |
1330 { | 1330 { |
1331 if (!object || object.type !== "object" || (object.subtype !== "array" && ob
ject.subtype !== "typedarray")) | 1331 if (!object || object.type !== "object" || (object.subtype !== "array" && ob
ject.subtype !== "typedarray")) |
1332 throw new Error("Object is empty or not an array"); | 1332 throw new Error("Object is empty or not an array"); |
1333 return new WebInspector.RemoteArray(object); | 1333 return new WebInspector.RemoteArray(object); |
1334 } | 1334 }; |
1335 | 1335 |
1336 /** | 1336 /** |
1337 * @param {!Array<!WebInspector.RemoteObject>} objects | 1337 * @param {!Array<!WebInspector.RemoteObject>} objects |
1338 * @return {!Promise<!WebInspector.RemoteArray>} | 1338 * @return {!Promise<!WebInspector.RemoteArray>} |
1339 */ | 1339 */ |
1340 WebInspector.RemoteArray.createFromRemoteObjects = function(objects) | 1340 WebInspector.RemoteArray.createFromRemoteObjects = function(objects) |
1341 { | 1341 { |
1342 if (!objects.length) | 1342 if (!objects.length) |
1343 throw new Error("Input array is empty"); | 1343 throw new Error("Input array is empty"); |
1344 var objectArguments = []; | 1344 var objectArguments = []; |
1345 for (var i = 0; i < objects.length; ++i) | 1345 for (var i = 0; i < objects.length; ++i) |
1346 objectArguments.push(WebInspector.RemoteObject.toCallArgument(objects[i]
)) | 1346 objectArguments.push(WebInspector.RemoteObject.toCallArgument(objects[i]
)); |
1347 return objects[0].callFunctionPromise(createArray, objectArguments).then(ret
urnRemoteArray); | 1347 return objects[0].callFunctionPromise(createArray, objectArguments).then(ret
urnRemoteArray); |
1348 | 1348 |
1349 /** | 1349 /** |
1350 * @return {!Array<*>} | 1350 * @return {!Array<*>} |
1351 */ | 1351 */ |
1352 function createArray() | 1352 function createArray() |
1353 { | 1353 { |
1354 if (arguments.length > 1) | 1354 if (arguments.length > 1) |
1355 return new Array(arguments); | 1355 return new Array(arguments); |
1356 return [arguments[0]]; | 1356 return [arguments[0]]; |
1357 } | 1357 } |
1358 | 1358 |
1359 /** | 1359 /** |
1360 * @param {!WebInspector.CallFunctionResult} result | 1360 * @param {!WebInspector.CallFunctionResult} result |
1361 * @return {!WebInspector.RemoteArray} | 1361 * @return {!WebInspector.RemoteArray} |
1362 */ | 1362 */ |
1363 function returnRemoteArray(result) | 1363 function returnRemoteArray(result) |
1364 { | 1364 { |
1365 if (result.wasThrown || !result.object) | 1365 if (result.wasThrown || !result.object) |
1366 throw new Error("Call function throws exceptions or returns empty va
lue"); | 1366 throw new Error("Call function throws exceptions or returns empty va
lue"); |
1367 return WebInspector.RemoteArray.objectAsArray(result.object); | 1367 return WebInspector.RemoteArray.objectAsArray(result.object); |
1368 } | 1368 } |
1369 } | 1369 }; |
1370 | 1370 |
1371 WebInspector.RemoteArray.prototype = { | 1371 WebInspector.RemoteArray.prototype = { |
1372 /** | 1372 /** |
1373 * @param {number} index | 1373 * @param {number} index |
1374 * @return {!Promise<!WebInspector.RemoteObject>} | 1374 * @return {!Promise<!WebInspector.RemoteObject>} |
1375 */ | 1375 */ |
1376 at: function(index) | 1376 at: function(index) |
1377 { | 1377 { |
1378 if (index < 0 || index > this._object.arrayLength()) | 1378 if (index < 0 || index > this._object.arrayLength()) |
1379 throw new Error("Out of range"); | 1379 throw new Error("Out of range"); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1423 return Promise.all(promises); | 1423 return Promise.all(promises); |
1424 }, | 1424 }, |
1425 | 1425 |
1426 /** | 1426 /** |
1427 * @return {!WebInspector.RemoteObject} | 1427 * @return {!WebInspector.RemoteObject} |
1428 */ | 1428 */ |
1429 object: function() | 1429 object: function() |
1430 { | 1430 { |
1431 return this._object; | 1431 return this._object; |
1432 } | 1432 } |
1433 } | 1433 }; |
1434 | 1434 |
1435 /** | 1435 /** |
1436 * @constructor | 1436 * @constructor |
1437 * @param {!WebInspector.RemoteObject} object | 1437 * @param {!WebInspector.RemoteObject} object |
1438 */ | 1438 */ |
1439 WebInspector.RemoteFunction = function(object) | 1439 WebInspector.RemoteFunction = function(object) |
1440 { | 1440 { |
1441 this._object = object; | 1441 this._object = object; |
1442 } | 1442 }; |
1443 | 1443 |
1444 /** | 1444 /** |
1445 * @param {?WebInspector.RemoteObject} object | 1445 * @param {?WebInspector.RemoteObject} object |
1446 * @return {!WebInspector.RemoteFunction} | 1446 * @return {!WebInspector.RemoteFunction} |
1447 */ | 1447 */ |
1448 WebInspector.RemoteFunction.objectAsFunction = function(object) | 1448 WebInspector.RemoteFunction.objectAsFunction = function(object) |
1449 { | 1449 { |
1450 if (!object || object.type !== "function") | 1450 if (!object || object.type !== "function") |
1451 throw new Error("Object is empty or not a function"); | 1451 throw new Error("Object is empty or not a function"); |
1452 return new WebInspector.RemoteFunction(object); | 1452 return new WebInspector.RemoteFunction(object); |
1453 } | 1453 }; |
1454 | 1454 |
1455 WebInspector.RemoteFunction.prototype = { | 1455 WebInspector.RemoteFunction.prototype = { |
1456 /** | 1456 /** |
1457 * @return {!Promise<!WebInspector.RemoteObject>} | 1457 * @return {!Promise<!WebInspector.RemoteObject>} |
1458 */ | 1458 */ |
1459 targetFunction: function() | 1459 targetFunction: function() |
1460 { | 1460 { |
1461 return this._object.getOwnPropertiesPromise().then(targetFunction.bind(t
his)); | 1461 return this._object.getOwnPropertiesPromise().then(targetFunction.bind(t
his)); |
1462 | 1462 |
1463 /** | 1463 /** |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1509 } | 1509 } |
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 |