| 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 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 var stackMessageEnd = firstCallFrame ? firstCallFrame.index : -1
; | 628 var stackMessageEnd = firstCallFrame ? firstCallFrame.index : -1
; |
| 629 if (stackMessageEnd !== -1) { | 629 if (stackMessageEnd !== -1) { |
| 630 var stackTrace = stack.substr(stackMessageEnd); | 630 var stackTrace = stack.substr(stackMessageEnd); |
| 631 return className + message + "\n" + stackTrace; | 631 return className + message + "\n" + stackTrace; |
| 632 } | 632 } |
| 633 return className + message; | 633 return className + message; |
| 634 } catch(e) { | 634 } catch(e) { |
| 635 } | 635 } |
| 636 } | 636 } |
| 637 | 637 |
| 638 if (subtype === "internal#entry") { |
| 639 if ("key" in obj) |
| 640 return "{" + this._describeIncludingPrimitives(obj.key) + " => "
+ this._describeIncludingPrimitives(obj.value) + "}"; |
| 641 return this._describeIncludingPrimitives(obj.value); |
| 642 } |
| 643 |
| 638 return className; | 644 return className; |
| 639 }, | 645 }, |
| 640 | 646 |
| 641 /** | 647 /** |
| 648 * @param {*} value |
| 649 * @return {string} |
| 650 */ |
| 651 _describeIncludingPrimitives: function(value) |
| 652 { |
| 653 if (typeof value === "string") |
| 654 return "\"" + value.replace(/\n/g, "\u21B5") + "\""; |
| 655 if (value === null) |
| 656 return "" + value; |
| 657 return this.isPrimitiveValue(value) ? toStringDescription(value) : (this
._describe(value) || ""); |
| 658 }, |
| 659 |
| 660 /** |
| 642 * @param {boolean} enabled | 661 * @param {boolean} enabled |
| 643 */ | 662 */ |
| 644 setCustomObjectFormatterEnabled: function(enabled) | 663 setCustomObjectFormatterEnabled: function(enabled) |
| 645 { | 664 { |
| 646 this._customObjectFormatterEnabled = enabled; | 665 this._customObjectFormatterEnabled = enabled; |
| 647 } | 666 } |
| 648 } | 667 } |
| 649 | 668 |
| 650 /** | 669 /** |
| 651 * @type {!InjectedScript} | 670 * @type {!InjectedScript} |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 try { | 839 try { |
| 821 var descriptors = injectedScript._propertyDescriptors(object, undefi
ned, undefined, firstLevelKeys); | 840 var descriptors = injectedScript._propertyDescriptors(object, undefi
ned, undefined, firstLevelKeys); |
| 822 | 841 |
| 823 this._appendPropertyDescriptors(preview, descriptors, propertiesThre
shold, secondLevelKeys, isTable); | 842 this._appendPropertyDescriptors(preview, descriptors, propertiesThre
shold, secondLevelKeys, isTable); |
| 824 if (propertiesThreshold.indexes < 0 || propertiesThreshold.propertie
s < 0) | 843 if (propertiesThreshold.indexes < 0 || propertiesThreshold.propertie
s < 0) |
| 825 return preview; | 844 return preview; |
| 826 | 845 |
| 827 // Add internal properties to preview. | 846 // Add internal properties to preview. |
| 828 var rawInternalProperties = InjectedScriptHost.getInternalProperties
(object) || []; | 847 var rawInternalProperties = InjectedScriptHost.getInternalProperties
(object) || []; |
| 829 var internalProperties = []; | 848 var internalProperties = []; |
| 849 var entries = null; |
| 830 for (var i = 0; i < rawInternalProperties.length; i += 2) { | 850 for (var i = 0; i < rawInternalProperties.length; i += 2) { |
| 851 if (rawInternalProperties[i] === "[[Entries]]") { |
| 852 entries = /** @type {!Array<*>} */(rawInternalProperties[i +
1]); |
| 853 continue; |
| 854 } |
| 831 push(internalProperties, { | 855 push(internalProperties, { |
| 832 name: rawInternalProperties[i], | 856 name: rawInternalProperties[i], |
| 833 value: rawInternalProperties[i + 1], | 857 value: rawInternalProperties[i + 1], |
| 834 isOwn: true, | 858 isOwn: true, |
| 835 enumerable: true, | 859 enumerable: true, |
| 836 __proto__: null | 860 __proto__: null |
| 837 }); | 861 }); |
| 838 } | 862 } |
| 839 this._appendPropertyDescriptors(preview, internalProperties, propert
iesThreshold, secondLevelKeys, isTable); | 863 this._appendPropertyDescriptors(preview, internalProperties, propert
iesThreshold, secondLevelKeys, isTable); |
| 840 | 864 |
| 841 if (this.subtype === "map" || this.subtype === "set" || this.subtype
=== "iterator") | 865 if (this.subtype === "map" || this.subtype === "set" || this.subtype
=== "iterator") |
| 842 this._appendEntriesPreview(object, preview, skipEntriesPreview); | 866 this._appendEntriesPreview(entries, preview, skipEntriesPreview)
; |
| 843 | 867 |
| 844 } catch (e) {} | 868 } catch (e) {} |
| 845 | 869 |
| 846 return preview; | 870 return preview; |
| 847 }, | 871 }, |
| 848 | 872 |
| 849 /** | 873 /** |
| 850 * @param {!RuntimeAgent.ObjectPreview} preview | 874 * @param {!RuntimeAgent.ObjectPreview} preview |
| 851 * @param {!Array.<*>|!Iterable.<*>} descriptors | 875 * @param {!Array.<*>|!Iterable.<*>} descriptors |
| 852 * @param {!Object} propertiesThreshold | 876 * @param {!Object} propertiesThreshold |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 else | 964 else |
| 941 propertiesThreshold.properties--; | 965 propertiesThreshold.properties--; |
| 942 if (propertiesThreshold.indexes < 0 || propertiesThreshold.properties <
0) { | 966 if (propertiesThreshold.indexes < 0 || propertiesThreshold.properties <
0) { |
| 943 preview.overflow = true; | 967 preview.overflow = true; |
| 944 } else { | 968 } else { |
| 945 push(preview.properties, property); | 969 push(preview.properties, property); |
| 946 } | 970 } |
| 947 }, | 971 }, |
| 948 | 972 |
| 949 /** | 973 /** |
| 950 * @param {!Object} object | 974 * @param {?Array<*>} entries |
| 951 * @param {!RuntimeAgent.ObjectPreview} preview | 975 * @param {!RuntimeAgent.ObjectPreview} preview |
| 952 * @param {boolean=} skipEntriesPreview | 976 * @param {boolean=} skipEntriesPreview |
| 953 */ | 977 */ |
| 954 _appendEntriesPreview: function(object, preview, skipEntriesPreview) | 978 _appendEntriesPreview: function(entries, preview, skipEntriesPreview) |
| 955 { | 979 { |
| 956 var entries = InjectedScriptHost.collectionEntries(object); | |
| 957 if (!entries) | 980 if (!entries) |
| 958 return; | 981 return; |
| 959 if (skipEntriesPreview) { | 982 if (skipEntriesPreview) { |
| 960 if (entries.length) | 983 if (entries.length) |
| 961 preview.overflow = true; | 984 preview.overflow = true; |
| 962 return; | 985 return; |
| 963 } | 986 } |
| 964 preview.entries = []; | 987 preview.entries = []; |
| 965 var entriesThreshold = 5; | 988 var entriesThreshold = 5; |
| 966 for (var i = 0; i < entries.length; ++i) { | 989 for (var i = 0; i < entries.length; ++i) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1006 return string.substr(0, leftHalf) + "\u2026" + string.substr(string.
length - rightHalf, rightHalf); | 1029 return string.substr(0, leftHalf) + "\u2026" + string.substr(string.
length - rightHalf, rightHalf); |
| 1007 } | 1030 } |
| 1008 return string.substr(0, maxLength) + "\u2026"; | 1031 return string.substr(0, maxLength) + "\u2026"; |
| 1009 }, | 1032 }, |
| 1010 | 1033 |
| 1011 __proto__: null | 1034 __proto__: null |
| 1012 } | 1035 } |
| 1013 | 1036 |
| 1014 return injectedScript; | 1037 return injectedScript; |
| 1015 }) | 1038 }) |
| OLD | NEW |