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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 192 * @const | 192 * @const |
| 193 */ | 193 */ |
| 194 InjectedScript.primitiveTypes = { | 194 InjectedScript.primitiveTypes = { |
| 195 "undefined": true, | 195 "undefined": true, |
| 196 "boolean": true, | 196 "boolean": true, |
| 197 "number": true, | 197 "number": true, |
| 198 "string": true, | 198 "string": true, |
| 199 __proto__: null | 199 __proto__: null |
| 200 } | 200 } |
| 201 | 201 |
| 202 /** | |
| 203 * @type {!Map<string, string>} | |
| 204 * @const | |
| 205 */ | |
| 206 InjectedScript.closureTypes = new Map([ | |
|
pfeldman
2016/08/10 16:02:09
You redefine Object and push for safety, but intro
dgozman
2016/08/10 16:17:51
Good catch!
| |
| 207 ["local", "Local"], | |
| 208 ["closure", "Closure"], | |
| 209 ["catch", "Catch"], | |
| 210 ["block", "Block"], | |
| 211 ["script", "Script"], | |
| 212 ["with", "With Block"], | |
| 213 ["global", "Global"] | |
| 214 ]); | |
| 215 | |
| 202 InjectedScript.prototype = { | 216 InjectedScript.prototype = { |
| 203 /** | 217 /** |
| 204 * @param {*} object | 218 * @param {*} object |
| 205 * @return {boolean} | 219 * @return {boolean} |
| 206 */ | 220 */ |
| 207 isPrimitiveValue: function(object) | 221 isPrimitiveValue: function(object) |
| 208 { | 222 { |
| 209 // FIXME(33716): typeof document.all is always 'undefined'. | 223 // FIXME(33716): typeof document.all is always 'undefined'. |
| 210 return InjectedScript.primitiveTypes[typeof object] && !this._isHTMLAllC ollection(object); | 224 return InjectedScript.primitiveTypes[typeof object] && !this._isHTMLAllC ollection(object); |
| 211 }, | 225 }, |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 317 /** | 331 /** |
| 318 * @param {!Object} object | 332 * @param {!Object} object |
| 319 * @param {string} objectGroupName | 333 * @param {string} objectGroupName |
| 320 * @param {boolean} ownProperties | 334 * @param {boolean} ownProperties |
| 321 * @param {boolean} accessorPropertiesOnly | 335 * @param {boolean} accessorPropertiesOnly |
| 322 * @param {boolean} generatePreview | 336 * @param {boolean} generatePreview |
| 323 * @return {!Array<!RuntimeAgent.PropertyDescriptor>|boolean} | 337 * @return {!Array<!RuntimeAgent.PropertyDescriptor>|boolean} |
| 324 */ | 338 */ |
| 325 getProperties: function(object, objectGroupName, ownProperties, accessorProp ertiesOnly, generatePreview) | 339 getProperties: function(object, objectGroupName, ownProperties, accessorProp ertiesOnly, generatePreview) |
| 326 { | 340 { |
| 341 var subtype = this._subtype(object); | |
| 342 if (subtype === "internal#scope") { | |
| 343 // Internally, scope contains object with scope variables and additi onal information like type, | |
| 344 // we use additional information for preview and would like to repor t variables as scope | |
| 345 // properties. | |
| 346 object = object.object; | |
| 347 } | |
| 348 | |
| 327 var descriptors = []; | 349 var descriptors = []; |
| 328 var iter = this._propertyDescriptors(object, ownProperties, accessorProp ertiesOnly, undefined); | 350 var iter = this._propertyDescriptors(object, ownProperties, accessorProp ertiesOnly, undefined); |
| 329 // Go over properties, wrap object values. | 351 // Go over properties, wrap object values. |
| 330 for (var descriptor of iter) { | 352 for (var descriptor of iter) { |
| 353 if (subtype === "internal#scopeList" && descriptor.name === "length" ) | |
| 354 continue; | |
| 331 if ("get" in descriptor) | 355 if ("get" in descriptor) |
| 332 descriptor.get = this._wrapObject(descriptor.get, objectGroupNam e); | 356 descriptor.get = this._wrapObject(descriptor.get, objectGroupNam e); |
| 333 if ("set" in descriptor) | 357 if ("set" in descriptor) |
| 334 descriptor.set = this._wrapObject(descriptor.set, objectGroupNam e); | 358 descriptor.set = this._wrapObject(descriptor.set, objectGroupNam e); |
| 335 if ("value" in descriptor) | 359 if ("value" in descriptor) |
| 336 descriptor.value = this._wrapObject(descriptor.value, objectGrou pName, false, generatePreview); | 360 descriptor.value = this._wrapObject(descriptor.value, objectGrou pName, false, generatePreview); |
| 337 if (!("configurable" in descriptor)) | 361 if (!("configurable" in descriptor)) |
| 338 descriptor.configurable = false; | 362 descriptor.configurable = false; |
| 339 if (!("enumerable" in descriptor)) | 363 if (!("enumerable" in descriptor)) |
| 340 descriptor.enumerable = false; | 364 descriptor.enumerable = false; |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 620 } catch(e) { | 644 } catch(e) { |
| 621 } | 645 } |
| 622 } | 646 } |
| 623 | 647 |
| 624 if (subtype === "internal#entry") { | 648 if (subtype === "internal#entry") { |
| 625 if ("key" in obj) | 649 if ("key" in obj) |
| 626 return "{" + this._describeIncludingPrimitives(obj.key) + " => " + this._describeIncludingPrimitives(obj.value) + "}"; | 650 return "{" + this._describeIncludingPrimitives(obj.key) + " => " + this._describeIncludingPrimitives(obj.value) + "}"; |
| 627 return this._describeIncludingPrimitives(obj.value); | 651 return this._describeIncludingPrimitives(obj.value); |
| 628 } | 652 } |
| 629 | 653 |
| 654 if (subtype === "internal#scopeList") | |
| 655 return "Scopes[" + obj.length + "]"; | |
| 656 | |
| 657 if (subtype === "internal#scope") | |
| 658 return (InjectedScript.closureTypes.get(obj.type) || "Unknown") + (o bj.name ? " (" + obj.name + ")" : ""); | |
| 659 | |
| 630 return className; | 660 return className; |
| 631 }, | 661 }, |
| 632 | 662 |
| 633 /** | 663 /** |
| 634 * @param {*} value | 664 * @param {*} value |
| 635 * @return {string} | 665 * @return {string} |
| 636 */ | 666 */ |
| 637 _describeIncludingPrimitives: function(value) | 667 _describeIncludingPrimitives: function(value) |
| 638 { | 668 { |
| 639 if (typeof value === "string") | 669 if (typeof value === "string") |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1022 return string.substr(0, leftHalf) + "\u2026" + string.substr(string. length - rightHalf, rightHalf); | 1052 return string.substr(0, leftHalf) + "\u2026" + string.substr(string. length - rightHalf, rightHalf); |
| 1023 } | 1053 } |
| 1024 return string.substr(0, maxLength) + "\u2026"; | 1054 return string.substr(0, maxLength) + "\u2026"; |
| 1025 }, | 1055 }, |
| 1026 | 1056 |
| 1027 __proto__: null | 1057 __proto__: null |
| 1028 } | 1058 } |
| 1029 | 1059 |
| 1030 return injectedScript; | 1060 return injectedScript; |
| 1031 }) | 1061 }) |
| OLD | NEW |