Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(284)

Side by Side Diff: Source/core/inspector/InjectedScriptSource.js

Issue 317703003: DevTools: Show internal properties in object preview in console. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « LayoutTests/inspector/console/console-format-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 this.objectId = injectedScript._bind(object, objectGroupName); 1087 this.objectId = injectedScript._bind(object, objectGroupName);
1088 var subtype = injectedScript._subtype(object); 1088 var subtype = injectedScript._subtype(object);
1089 if (subtype) 1089 if (subtype)
1090 this.subtype = subtype; 1090 this.subtype = subtype;
1091 var className = InjectedScriptHost.internalConstructorName(object); 1091 var className = InjectedScriptHost.internalConstructorName(object);
1092 if (className) 1092 if (className)
1093 this.className = className; 1093 this.className = className;
1094 this.description = injectedScript._describe(object); 1094 this.description = injectedScript._describe(object);
1095 1095
1096 if (generatePreview && (this.type === "object" || injectedScript._isHTMLAllC ollection(object))) 1096 if (generatePreview && (this.type === "object" || injectedScript._isHTMLAllC ollection(object)))
1097 this.preview = this._generatePreview(object, undefined, columnNames, isT able, false); 1097 this.preview = this._generatePreview(object, undefined, columnNames, isT able);
1098 } 1098 }
1099 1099
1100 InjectedScript.RemoteObject.prototype = { 1100 InjectedScript.RemoteObject.prototype = {
1101 /** 1101 /**
1102 * @param {Object} object 1102 * @param {Object} object
1103 * @param {Array.<string>=} firstLevelKeys 1103 * @param {Array.<string>=} firstLevelKeys
1104 * @param {?Array.<string>=} secondLevelKeys 1104 * @param {?Array.<string>=} secondLevelKeys
1105 * @param {boolean=} isTable 1105 * @param {boolean=} isTable
1106 * @param {boolean=} isTableRow
1107 * @return {!RuntimeAgent.ObjectPreview} preview 1106 * @return {!RuntimeAgent.ObjectPreview} preview
1108 */ 1107 */
1109 _generatePreview: function(object, firstLevelKeys, secondLevelKeys, isTable, isTableRow) 1108 _generatePreview: function(object, firstLevelKeys, secondLevelKeys, isTable)
1110 { 1109 {
1111 var preview = { __proto__: null }; 1110 var preview = { __proto__: null };
1112 preview.lossless = true; 1111 preview.lossless = true;
1113 preview.overflow = false; 1112 preview.overflow = false;
1114 preview.properties = []; 1113 preview.properties = [];
1115 1114
1116 var firstLevelKeysCount = firstLevelKeys ? firstLevelKeys.length : 0; 1115 var firstLevelKeysCount = firstLevelKeys ? firstLevelKeys.length : 0;
1117 1116
1118 var propertiesThreshold = { 1117 var propertiesThreshold = {
1119 properties: (isTable || isTableRow) ? 1000 : max(5, firstLevelKeysCo unt), 1118 properties: isTable ? 1000 : max(5, firstLevelKeysCount),
1120 indexes: (isTable || isTableRow) ? 1000 : max(100, firstLevelKeysCou nt) 1119 indexes: isTable ? 1000 : max(100, firstLevelKeysCount)
1121 }; 1120 };
1122 1121
1123 try { 1122 try {
1124 var descriptors = injectedScript._propertyDescriptors(object); 1123 var descriptors = injectedScript._propertyDescriptors(object);
1124 var internalProperties;
1125 1125
1126 if (firstLevelKeys) { 1126 if (firstLevelKeys) {
1127 var nameToDescriptors = { __proto__: null }; 1127 var nameToDescriptors = { __proto__: null };
1128 for (var i = 0; i < descriptors.length; ++i) { 1128 for (var i = 0; i < descriptors.length; ++i) {
1129 var descriptor = descriptors[i]; 1129 var descriptor = descriptors[i];
1130 nameToDescriptors["#" + descriptor.name] = descriptor; 1130 nameToDescriptors["#" + descriptor.name] = descriptor;
1131 } 1131 }
1132 descriptors = []; 1132 descriptors = [];
1133 for (var i = 0; i < firstLevelKeys.length; ++i) 1133 for (var i = 0; i < firstLevelKeys.length; ++i)
1134 descriptors[i] = nameToDescriptors["#" + firstLevelKeys[i]]; 1134 descriptors[i] = nameToDescriptors["#" + firstLevelKeys[i]];
1135 } 1135 }
1136 1136
1137 for (var i = 0; i < descriptors.length; ++i) { 1137 for (var i = 0, n = descriptors.length + 1; i < n; ++i) {
1138 if (propertiesThreshold.indexes < 0 || propertiesThreshold.prope rties < 0) 1138 if (propertiesThreshold.indexes < 0 || propertiesThreshold.prope rties < 0)
1139 break; 1139 break;
1140 1140
1141 var descriptor = descriptors[i]; 1141 var descriptor = descriptors[i];
1142 if (i >= descriptors.length && !isTable) {
1143 // Add internal properties to preview.
1144 if (!internalProperties) {
1145 internalProperties = InjectedScriptHost.getInternalPrope rties(object) || [];
1146 n = descriptors.length + internalProperties.length;
1147 if (i >= n)
1148 break;
1149 }
1150 descriptor = nullifyObjectProto(internalProperties[i - descr iptors.length]);
1151 descriptor.enumerable = true;
1152 }
1153
1142 if (!descriptor) 1154 if (!descriptor)
yurys 2014/06/06 09:12:01 Let's try to extract common part into a separate m
aandrey 2014/06/06 09:28:41 Done.
1143 continue; 1155 continue;
1144 if (descriptor.wasThrown) { 1156 if (descriptor.wasThrown) {
1145 preview.lossless = false; 1157 preview.lossless = false;
1146 continue; 1158 continue;
1147 } 1159 }
1148 if (!descriptor.enumerable && !descriptor.isOwn) 1160 if (!descriptor.enumerable && !descriptor.isOwn)
1149 continue; 1161 continue;
1150 1162
1151 var name = descriptor.name; 1163 var name = descriptor.name;
1152 if (name === "__proto__") 1164 if (name === "__proto__")
(...skipping 23 matching lines...) Expand all
1176 if (InjectedScript.primitiveTypes[type]) { 1188 if (InjectedScript.primitiveTypes[type]) {
1177 if (type === "string" && value.length > maxLength) { 1189 if (type === "string" && value.length > maxLength) {
1178 value = this._abbreviateString(value, maxLength, true); 1190 value = this._abbreviateString(value, maxLength, true);
1179 preview.lossless = false; 1191 preview.lossless = false;
1180 } 1192 }
1181 this._appendPropertyPreview(preview, { name: name, type: typ e, value: toStringDescription(value), __proto__: null }, propertiesThreshold); 1193 this._appendPropertyPreview(preview, { name: name, type: typ e, value: toStringDescription(value), __proto__: null }, propertiesThreshold);
1182 continue; 1194 continue;
1183 } 1195 }
1184 1196
1185 if (secondLevelKeys === null || secondLevelKeys) { 1197 if (secondLevelKeys === null || secondLevelKeys) {
1186 var subPreview = this._generatePreview(value, secondLevelKey s || undefined, undefined, false, isTable); 1198 var subPreview = this._generatePreview(value, secondLevelKey s || undefined, undefined, isTable);
1187 var property = { name: name, type: type, valuePreview: subPr eview, __proto__: null }; 1199 var property = { name: name, type: type, valuePreview: subPr eview, __proto__: null };
1188 this._appendPropertyPreview(preview, property, propertiesThr eshold); 1200 this._appendPropertyPreview(preview, property, propertiesThr eshold);
1189 if (!subPreview.lossless) 1201 if (!subPreview.lossless)
1190 preview.lossless = false; 1202 preview.lossless = false;
1191 if (subPreview.overflow) 1203 if (subPreview.overflow)
1192 preview.overflow = true; 1204 preview.overflow = true;
1193 continue; 1205 continue;
1194 } 1206 }
1195 1207
1196 preview.lossless = false; 1208 preview.lossless = false;
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
1642 */ 1654 */
1643 _logEvent: function(event) 1655 _logEvent: function(event)
1644 { 1656 {
1645 inspectedWindow.console.log(event.type, event); 1657 inspectedWindow.console.log(event.type, event);
1646 } 1658 }
1647 } 1659 }
1648 1660
1649 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); 1661 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl();
1650 return injectedScript; 1662 return injectedScript;
1651 }) 1663 })
OLDNEW
« no previous file with comments | « LayoutTests/inspector/console/console-format-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698