Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 376 * @param {boolean} ownProperties | 376 * @param {boolean} ownProperties |
| 377 * @param {boolean} accessorPropertiesOnly | 377 * @param {boolean} accessorPropertiesOnly |
| 378 * @return {Array.<RuntimeAgent.PropertyDescriptor>|boolean} | 378 * @return {Array.<RuntimeAgent.PropertyDescriptor>|boolean} |
| 379 */ | 379 */ |
| 380 getProperties: function(objectId, ownProperties, accessorPropertiesOnly) | 380 getProperties: function(objectId, ownProperties, accessorPropertiesOnly) |
| 381 { | 381 { |
| 382 var parsedObjectId = this._parseObjectId(objectId); | 382 var parsedObjectId = this._parseObjectId(objectId); |
| 383 var object = this._objectForId(parsedObjectId); | 383 var object = this._objectForId(parsedObjectId); |
| 384 var objectGroupName = this._idToObjectGroupName[parsedObjectId.id]; | 384 var objectGroupName = this._idToObjectGroupName[parsedObjectId.id]; |
| 385 | 385 |
| 386 if (!this._isDefined(object)) | 386 if (!this._isDefined(object) || this._isSymbol(object)) |
|
aandrey
2014/06/04 13:03:51
typeof object !== "object"
Alexandra Mikhaylova
2014/06/04 14:08:37
Done.
| |
| 387 return false; | 387 return false; |
| 388 var descriptors = this._propertyDescriptors(object, ownProperties, acces sorPropertiesOnly); | 388 var descriptors = this._propertyDescriptors(object, ownProperties, acces sorPropertiesOnly); |
| 389 | 389 |
| 390 // Go over properties, wrap object values. | 390 // Go over properties, wrap object values. |
| 391 for (var i = 0; i < descriptors.length; ++i) { | 391 for (var i = 0; i < descriptors.length; ++i) { |
| 392 var descriptor = descriptors[i]; | 392 var descriptor = descriptors[i]; |
| 393 if ("get" in descriptor) | 393 if ("get" in descriptor) |
| 394 descriptor.get = this._wrapObject(descriptor.get, objectGroupNam e); | 394 descriptor.get = this._wrapObject(descriptor.get, objectGroupNam e); |
| 395 if ("set" in descriptor) | 395 if ("set" in descriptor) |
| 396 descriptor.set = this._wrapObject(descriptor.set, objectGroupNam e); | 396 descriptor.set = this._wrapObject(descriptor.set, objectGroupNam e); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 408 | 408 |
| 409 /** | 409 /** |
| 410 * @param {string} objectId | 410 * @param {string} objectId |
| 411 * @return {Array.<Object>|boolean} | 411 * @return {Array.<Object>|boolean} |
| 412 */ | 412 */ |
| 413 getInternalProperties: function(objectId, ownProperties) | 413 getInternalProperties: function(objectId, ownProperties) |
| 414 { | 414 { |
| 415 var parsedObjectId = this._parseObjectId(objectId); | 415 var parsedObjectId = this._parseObjectId(objectId); |
| 416 var object = this._objectForId(parsedObjectId); | 416 var object = this._objectForId(parsedObjectId); |
| 417 var objectGroupName = this._idToObjectGroupName[parsedObjectId.id]; | 417 var objectGroupName = this._idToObjectGroupName[parsedObjectId.id]; |
| 418 if (!this._isDefined(object)) | 418 if (!this._isDefined(object) || this._isSymbol(object)) |
|
aandrey
2014/06/04 13:03:51
ditto
Alexandra Mikhaylova
2014/06/04 14:08:37
Done.
| |
| 419 return false; | 419 return false; |
| 420 var descriptors = []; | 420 var descriptors = []; |
| 421 var internalProperties = InjectedScriptHost.getInternalProperties(object ); | 421 var internalProperties = InjectedScriptHost.getInternalProperties(object ); |
| 422 if (internalProperties) { | 422 if (internalProperties) { |
| 423 for (var i = 0; i < internalProperties.length; i++) { | 423 for (var i = 0; i < internalProperties.length; i++) { |
| 424 var property = internalProperties[i]; | 424 var property = internalProperties[i]; |
| 425 var descriptor = { | 425 var descriptor = { |
| 426 name: property.name, | 426 name: property.name, |
| 427 value: this._wrapObject(property.value, objectGroupName), | 427 value: this._wrapObject(property.value, objectGroupName), |
| 428 __proto__: null | 428 __proto__: null |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 490 * @param {!Array.<string|symbol>} properties | 490 * @param {!Array.<string|symbol>} properties |
| 491 */ | 491 */ |
| 492 function process(o, properties) | 492 function process(o, properties) |
| 493 { | 493 { |
| 494 for (var i = 0; i < properties.length; ++i) { | 494 for (var i = 0; i < properties.length; ++i) { |
| 495 var property = properties[i]; | 495 var property = properties[i]; |
| 496 if (propertyProcessed[property]) | 496 if (propertyProcessed[property]) |
| 497 continue; | 497 continue; |
| 498 | 498 |
| 499 var name = property; | 499 var name = property; |
| 500 var type = typeof property; | 500 if (injectedScript._isSymbol(property)) |
|
aandrey
2014/06/04 13:03:51
revert
Alexandra Mikhaylova
2014/06/04 14:08:37
Done.
| |
| 501 if (type === "symbol") | |
| 502 name = injectedScript._describe(property); | 501 name = injectedScript._describe(property); |
| 503 | 502 |
| 504 try { | 503 try { |
| 505 propertyProcessed[property] = true; | 504 propertyProcessed[property] = true; |
| 506 var descriptor = nullifyObjectProto(InjectedScriptHost.suppr essWarningsAndCall(Object, Object.getOwnPropertyDescriptor, o, property)); | 505 var descriptor = nullifyObjectProto(InjectedScriptHost.suppr essWarningsAndCall(Object, Object.getOwnPropertyDescriptor, o, property)); |
| 507 if (descriptor) { | 506 if (descriptor) { |
| 508 if (accessorPropertiesOnly && !("get" in descriptor || " set" in descriptor)) | 507 if (accessorPropertiesOnly && !("get" in descriptor || " set" in descriptor)) |
| 509 continue; | 508 continue; |
| 510 } else { | 509 } else { |
| 511 // Not all bindings provide proper descriptors. Fall bac k to the writable, configurable property. | 510 // Not all bindings provide proper descriptors. Fall bac k to the writable, configurable property. |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 525 if (accessorPropertiesOnly) | 524 if (accessorPropertiesOnly) |
| 526 continue; | 525 continue; |
| 527 var descriptor = { __proto__: null }; | 526 var descriptor = { __proto__: null }; |
| 528 descriptor.value = e; | 527 descriptor.value = e; |
| 529 descriptor.wasThrown = true; | 528 descriptor.wasThrown = true; |
| 530 } | 529 } |
| 531 | 530 |
| 532 descriptor.name = name; | 531 descriptor.name = name; |
| 533 if (o === object) | 532 if (o === object) |
| 534 descriptor.isOwn = true; | 533 descriptor.isOwn = true; |
| 535 if (type === "symbol") | 534 if (injectedScript._isSymbol(property)) |
| 536 descriptor.symbol = property; | 535 descriptor.symbol = property; |
| 537 push(descriptors, descriptor); | 536 push(descriptors, descriptor); |
| 538 } | 537 } |
| 539 } | 538 } |
| 540 | 539 |
| 541 for (var o = object; this._isDefined(o); o = o.__proto__) { | 540 for (var o = object; this._isDefined(o); o = o.__proto__) { |
| 542 // First call Object.keys() to enforce ordering of the property desc riptors. | 541 // First call Object.keys() to enforce ordering of the property desc riptors. |
| 543 process(o, Object.keys(/** @type {!Object} */ (o))); | 542 process(o, Object.keys(/** @type {!Object} */ (o))); |
| 544 process(o, Object.getOwnPropertyNames(/** @type {!Object} */ (o))); | 543 process(o, Object.getOwnPropertyNames(/** @type {!Object} */ (o))); |
| 545 if (Object.getOwnPropertySymbols) | 544 if (Object.getOwnPropertySymbols) |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 867 topCallFrame = asyncCallStacks[asyncOrdinal - 1]; | 866 topCallFrame = asyncCallStacks[asyncOrdinal - 1]; |
| 868 var ordinal = parsedCallFrameId["ordinal"]; | 867 var ordinal = parsedCallFrameId["ordinal"]; |
| 869 var callFrame = topCallFrame; | 868 var callFrame = topCallFrame; |
| 870 while (--ordinal >= 0 && callFrame) | 869 while (--ordinal >= 0 && callFrame) |
| 871 callFrame = callFrame.caller; | 870 callFrame = callFrame.caller; |
| 872 return callFrame; | 871 return callFrame; |
| 873 }, | 872 }, |
| 874 | 873 |
| 875 /** | 874 /** |
| 876 * @param {Object} objectId | 875 * @param {Object} objectId |
| 877 * @return {Object} | 876 * @return {Object|symbol} |
| 878 */ | 877 */ |
| 879 _objectForId: function(objectId) | 878 _objectForId: function(objectId) |
| 880 { | 879 { |
| 881 return this._idToWrappedObject[objectId.id]; | 880 return this._idToWrappedObject[objectId.id]; |
| 882 }, | 881 }, |
| 883 | 882 |
| 884 /** | 883 /** |
| 885 * @param {string} objectId | 884 * @param {string} objectId |
| 886 * @return {Object} | 885 * @return {Object} |
| 887 */ | 886 */ |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 943 * @param {*} object | 942 * @param {*} object |
| 944 * @return {boolean} | 943 * @return {boolean} |
| 945 */ | 944 */ |
| 946 _isHTMLAllCollection: function(object) | 945 _isHTMLAllCollection: function(object) |
| 947 { | 946 { |
| 948 // document.all is reported as undefined, but we still want to process i t. | 947 // document.all is reported as undefined, but we still want to process i t. |
| 949 return (typeof object === "undefined") && InjectedScriptHost.isHTMLAllCo llection(object); | 948 return (typeof object === "undefined") && InjectedScriptHost.isHTMLAllCo llection(object); |
| 950 }, | 949 }, |
| 951 | 950 |
| 952 /** | 951 /** |
| 952 * @param {*} object | |
| 953 * @return {boolean} | |
| 954 */ | |
| 955 _isSymbol: function(object) | |
| 956 { | |
| 957 var type = typeof object; | |
| 958 return (type === "symbol"); | |
| 959 }, | |
| 960 | |
| 961 /** | |
| 953 * @param {*} obj | 962 * @param {*} obj |
| 954 * @return {string?} | 963 * @return {string?} |
| 955 */ | 964 */ |
| 956 _subtype: function(obj) | 965 _subtype: function(obj) |
| 957 { | 966 { |
| 958 if (obj === null) | 967 if (obj === null) |
| 959 return "null"; | 968 return "null"; |
| 960 | 969 |
| 961 if (this.isPrimitiveValue(obj)) | 970 if (this.isPrimitiveValue(obj)) |
| 962 return null; | 971 return null; |
| (...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1642 */ | 1651 */ |
| 1643 _logEvent: function(event) | 1652 _logEvent: function(event) |
| 1644 { | 1653 { |
| 1645 inspectedWindow.console.log(event.type, event); | 1654 inspectedWindow.console.log(event.type, event); |
| 1646 } | 1655 } |
| 1647 } | 1656 } |
| 1648 | 1657 |
| 1649 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); | 1658 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); |
| 1650 return injectedScript; | 1659 return injectedScript; |
| 1651 }) | 1660 }) |
| OLD | NEW |