| 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([ |
| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 /** | 354 /** |
| 341 * @param {!Object} object | 355 * @param {!Object} object |
| 342 * @param {string} objectGroupName | 356 * @param {string} objectGroupName |
| 343 * @param {boolean} ownProperties | 357 * @param {boolean} ownProperties |
| 344 * @param {boolean} accessorPropertiesOnly | 358 * @param {boolean} accessorPropertiesOnly |
| 345 * @param {boolean} generatePreview | 359 * @param {boolean} generatePreview |
| 346 * @return {!Array<!RuntimeAgent.PropertyDescriptor>|boolean} | 360 * @return {!Array<!RuntimeAgent.PropertyDescriptor>|boolean} |
| 347 */ | 361 */ |
| 348 getProperties: function(object, objectGroupName, ownProperties, accessorProp
ertiesOnly, generatePreview) | 362 getProperties: function(object, objectGroupName, ownProperties, accessorProp
ertiesOnly, generatePreview) |
| 349 { | 363 { |
| 364 var subtype = this._subtype(object); |
| 365 if (subtype === "internal#scope") { |
| 366 // Internally, scope contains object with scope variables and additi
onal information like type, |
| 367 // we use additional information for preview and would like to repor
t variables as scope |
| 368 // properties. |
| 369 object = object.object; |
| 370 } |
| 371 |
| 350 var descriptors = []; | 372 var descriptors = []; |
| 351 var iter = this._propertyDescriptors(object, ownProperties, accessorProp
ertiesOnly, undefined); | 373 var iter = this._propertyDescriptors(object, ownProperties, accessorProp
ertiesOnly, undefined); |
| 352 // Go over properties, wrap object values. | 374 // Go over properties, wrap object values. |
| 353 for (var descriptor of iter) { | 375 for (var descriptor of iter) { |
| 376 if (subtype === "internal#scopeList" && descriptor.name === "length"
) |
| 377 continue; |
| 354 if ("get" in descriptor) | 378 if ("get" in descriptor) |
| 355 descriptor.get = this._wrapObject(descriptor.get, objectGroupNam
e); | 379 descriptor.get = this._wrapObject(descriptor.get, objectGroupNam
e); |
| 356 if ("set" in descriptor) | 380 if ("set" in descriptor) |
| 357 descriptor.set = this._wrapObject(descriptor.set, objectGroupNam
e); | 381 descriptor.set = this._wrapObject(descriptor.set, objectGroupNam
e); |
| 358 if ("value" in descriptor) | 382 if ("value" in descriptor) |
| 359 descriptor.value = this._wrapObject(descriptor.value, objectGrou
pName, false, generatePreview); | 383 descriptor.value = this._wrapObject(descriptor.value, objectGrou
pName, false, generatePreview); |
| 360 if (!("configurable" in descriptor)) | 384 if (!("configurable" in descriptor)) |
| 361 descriptor.configurable = false; | 385 descriptor.configurable = false; |
| 362 if (!("enumerable" in descriptor)) | 386 if (!("enumerable" in descriptor)) |
| 363 descriptor.enumerable = false; | 387 descriptor.enumerable = false; |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 } catch(e) { | 667 } catch(e) { |
| 644 } | 668 } |
| 645 } | 669 } |
| 646 | 670 |
| 647 if (subtype === "internal#entry") { | 671 if (subtype === "internal#entry") { |
| 648 if ("key" in obj) | 672 if ("key" in obj) |
| 649 return "{" + this._describeIncludingPrimitives(obj.key) + " => "
+ this._describeIncludingPrimitives(obj.value) + "}"; | 673 return "{" + this._describeIncludingPrimitives(obj.key) + " => "
+ this._describeIncludingPrimitives(obj.value) + "}"; |
| 650 return this._describeIncludingPrimitives(obj.value); | 674 return this._describeIncludingPrimitives(obj.value); |
| 651 } | 675 } |
| 652 | 676 |
| 677 if (subtype === "internal#scopeList") |
| 678 return "Scopes[" + obj.length + "]"; |
| 679 |
| 680 if (subtype === "internal#scope") |
| 681 return (InjectedScript.closureTypes.get(obj.type) || "Unknown") + (o
bj.name ? " (" + obj.name + ")" : ""); |
| 682 |
| 653 return className; | 683 return className; |
| 654 }, | 684 }, |
| 655 | 685 |
| 656 /** | 686 /** |
| 657 * @param {*} value | 687 * @param {*} value |
| 658 * @return {string} | 688 * @return {string} |
| 659 */ | 689 */ |
| 660 _describeIncludingPrimitives: function(value) | 690 _describeIncludingPrimitives: function(value) |
| 661 { | 691 { |
| 662 if (typeof value === "string") | 692 if (typeof value === "string") |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1045 return string.substr(0, leftHalf) + "\u2026" + string.substr(string.
length - rightHalf, rightHalf); | 1075 return string.substr(0, leftHalf) + "\u2026" + string.substr(string.
length - rightHalf, rightHalf); |
| 1046 } | 1076 } |
| 1047 return string.substr(0, maxLength) + "\u2026"; | 1077 return string.substr(0, maxLength) + "\u2026"; |
| 1048 }, | 1078 }, |
| 1049 | 1079 |
| 1050 __proto__: null | 1080 __proto__: null |
| 1051 } | 1081 } |
| 1052 | 1082 |
| 1053 return injectedScript; | 1083 return injectedScript; |
| 1054 }) | 1084 }) |
| OLD | NEW |