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

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

Issue 135973010: Revert of DevTools: Fix console.log for arrays in some corner cases. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebaselined Created 6 years, 10 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
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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 * @template T 104 * @template T
105 */ 105 */
106 function nullifyObjectProto(obj) 106 function nullifyObjectProto(obj)
107 { 107 {
108 if (obj && typeof obj === "object") 108 if (obj && typeof obj === "object")
109 obj.__proto__ = null; 109 obj.__proto__ = null;
110 return obj; 110 return obj;
111 } 111 }
112 112
113 /** 113 /**
114 * @param {string} name
115 * @return {boolean}
116 */
117 function isArrayIndexPropertyName(name)
118 {
119 // Array index check according to the ES5-15.4.
120 var index = name >>> 0;
121 return toString(index) === name && index !== 0xffffffff;
122 }
123
124 /**
125 * @constructor 114 * @constructor
126 */ 115 */
127 var InjectedScript = function() 116 var InjectedScript = function()
128 { 117 {
129 /** @type {number} */ 118 /** @type {number} */
130 this._lastBoundObjectId = 1; 119 this._lastBoundObjectId = 1;
131 /** @type {!Object.<number, Object>} */ 120 /** @type {!Object.<number, Object>} */
132 this._idToWrappedObject = { __proto__: null }; 121 this._idToWrappedObject = { __proto__: null };
133 /** @type {!Object.<number, string>} */ 122 /** @type {!Object.<number, string>} */
134 this._idToObjectGroupName = { __proto__: null }; 123 this._idToObjectGroupName = { __proto__: null };
(...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 var nameToDescriptors = { __proto__: null }; 1048 var nameToDescriptors = { __proto__: null };
1060 for (var i = 0; i < descriptors.length; ++i) { 1049 for (var i = 0; i < descriptors.length; ++i) {
1061 var descriptor = descriptors[i]; 1050 var descriptor = descriptors[i];
1062 nameToDescriptors["#" + descriptor.name] = descriptor; 1051 nameToDescriptors["#" + descriptor.name] = descriptor;
1063 } 1052 }
1064 descriptors = []; 1053 descriptors = [];
1065 for (var i = 0; i < firstLevelKeys.length; ++i) 1054 for (var i = 0; i < firstLevelKeys.length; ++i)
1066 descriptors.push(nameToDescriptors["#" + firstLevelKeys[i]]) ; 1055 descriptors.push(nameToDescriptors["#" + firstLevelKeys[i]]) ;
1067 } 1056 }
1068 1057
1069 var isArray = (this.subtype === "array");
1070 for (var i = 0; i < descriptors.length; ++i) { 1058 for (var i = 0; i < descriptors.length; ++i) {
1071 if (propertiesThreshold.indexes < 0 && propertiesThreshold.prope rties < 0) 1059 if (propertiesThreshold.indexes < 0 || propertiesThreshold.prope rties < 0)
1072 break; 1060 break;
1073 1061
1074 var descriptor = descriptors[i]; 1062 var descriptor = descriptors[i];
1075 if (!descriptor) 1063 if (!descriptor)
1076 continue; 1064 continue;
1077 if (descriptor.wasThrown) { 1065 if (descriptor.wasThrown) {
1078 preview.lossless = false; 1066 preview.lossless = false;
1079 continue; 1067 continue;
1080 } 1068 }
1069 if (!descriptor.enumerable && !descriptor.isOwn)
1070 continue;
1081 1071
1082 var name = descriptor.name; 1072 var name = descriptor.name;
1083 if (name === "__proto__") 1073 if (name === "__proto__")
1084 continue; 1074 continue;
1085 if (isArray && name === "length") 1075 if (this.subtype === "array" && name === "length")
1086 continue;
1087
1088 var isArrayIndex = isArray && isArrayIndexPropertyName(name);
1089 if (!descriptor.enumerable && !descriptor.isOwn && !isArrayIndex )
1090 continue; 1076 continue;
1091 1077
1092 if (!("value" in descriptor)) { 1078 if (!("value" in descriptor)) {
1093 preview.lossless = false; 1079 preview.lossless = false;
1094 this._appendPropertyPreview(preview, { name: name, type: "ac cessor", __proto__: null }, propertiesThreshold); 1080 this._appendPropertyPreview(preview, { name: name, type: "ac cessor", __proto__: null }, propertiesThreshold);
1095 continue; 1081 continue;
1096 } 1082 }
1097 1083
1098 var value = descriptor.value; 1084 var value = descriptor.value;
1099 if (value === null) { 1085 if (value === null) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 return preview; 1133 return preview;
1148 }, 1134 },
1149 1135
1150 /** 1136 /**
1151 * @param {!RuntimeAgent.ObjectPreview} preview 1137 * @param {!RuntimeAgent.ObjectPreview} preview
1152 * @param {!Object} property 1138 * @param {!Object} property
1153 * @param {!Object} propertiesThreshold 1139 * @param {!Object} propertiesThreshold
1154 */ 1140 */
1155 _appendPropertyPreview: function(preview, property, propertiesThreshold) 1141 _appendPropertyPreview: function(preview, property, propertiesThreshold)
1156 { 1142 {
1157 var threshold; 1143 if (toString(property.name >>> 0) === property.name)
1158 if (isArrayIndexPropertyName(property.name)) 1144 propertiesThreshold.indexes--;
1159 threshold = --propertiesThreshold.indexes;
1160 else 1145 else
1161 threshold = --propertiesThreshold.properties; 1146 propertiesThreshold.properties--;
1162 if (threshold < 0) { 1147 if (propertiesThreshold.indexes < 0 || propertiesThreshold.properties < 0) {
1163 preview.overflow = true; 1148 preview.overflow = true;
1164 preview.lossless = false; 1149 preview.lossless = false;
1165 } else { 1150 } else {
1166 preview.properties.push(property); 1151 preview.properties.push(property);
1167 } 1152 }
1168 }, 1153 },
1169 1154
1170 /** 1155 /**
1171 * @param {string} string 1156 * @param {string} string
1172 * @param {number} maxLength 1157 * @param {number} maxLength
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
1580 */ 1565 */
1581 _logEvent: function(event) 1566 _logEvent: function(event)
1582 { 1567 {
1583 inspectedWindow.console.log(event.type, event); 1568 inspectedWindow.console.log(event.type, event);
1584 } 1569 }
1585 } 1570 }
1586 1571
1587 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); 1572 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl();
1588 return injectedScript; 1573 return injectedScript;
1589 }) 1574 })
OLDNEW
« no previous file with comments | « LayoutTests/inspector/console/console-object-preview-expected.txt ('k') | Source/devtools/front_end/ConsoleMessage.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698