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

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

Issue 312143003: This fixes bug with trying to get properties of non-object (symbol). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Address review comments 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
« no previous file with comments | « Source/core/inspector/InjectedScriptExterns.js ('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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 return a > b ? a : b; 172 return a > b ? a : b;
173 } 173 }
174 174
175 /** 175 /**
176 * @constructor 176 * @constructor
177 */ 177 */
178 var InjectedScript = function() 178 var InjectedScript = function()
179 { 179 {
180 /** @type {number} */ 180 /** @type {number} */
181 this._lastBoundObjectId = 1; 181 this._lastBoundObjectId = 1;
182 /** @type {!Object.<number, Object>} */ 182 /** @type {!Object.<number, Object>} */
aandrey 2014/06/04 15:39:08 @type {!Object.<number, (!Object|symbol)>}
Alexandra Mikhaylova 2014/06/05 13:27:43 Done.
183 this._idToWrappedObject = { __proto__: null }; 183 this._idToWrappedObject = { __proto__: null };
184 /** @type {!Object.<number, string>} */ 184 /** @type {!Object.<number, string>} */
185 this._idToObjectGroupName = { __proto__: null }; 185 this._idToObjectGroupName = { __proto__: null };
186 /** @type {!Object.<string, Array.<number>>} */ 186 /** @type {!Object.<string, Array.<number>>} */
187 this._objectGroups = { __proto__: null }; 187 this._objectGroups = { __proto__: null };
188 /** @type {!Object.<string, Object>} */ 188 /** @type {!Object.<string, Object>} */
189 this._modules = { __proto__: null }; 189 this._modules = { __proto__: null };
190 } 190 }
191 191
192 /** 192 /**
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 try { 305 try {
306 var description = injectedScript._describe(e); 306 var description = injectedScript._describe(e);
307 } catch (ex) { 307 } catch (ex) {
308 var description = "<failed to convert exception to string>"; 308 var description = "<failed to convert exception to string>";
309 } 309 }
310 return new InjectedScript.RemoteObject(description); 310 return new InjectedScript.RemoteObject(description);
311 } 311 }
312 }, 312 },
313 313
314 /** 314 /**
315 * @param {Object} object 315 * @param {Object} object
aandrey 2014/06/04 15:39:08 {!Object|symbol}
Alexandra Mikhaylova 2014/06/05 13:27:43 Done.
316 * @param {string=} objectGroupName 316 * @param {string=} objectGroupName
317 * @return {string} 317 * @return {string}
318 */ 318 */
319 _bind: function(object, objectGroupName) 319 _bind: function(object, objectGroupName)
320 { 320 {
321 var id = this._lastBoundObjectId++; 321 var id = this._lastBoundObjectId++;
322 this._idToWrappedObject[id] = object; 322 this._idToWrappedObject[id] = object;
323 var objectId = "{\"injectedScriptId\":" + injectedScriptId + ",\"id\":" + id + "}"; 323 var objectId = "{\"injectedScriptId\":" + injectedScriptId + ",\"id\":" + id + "}";
324 if (objectGroupName) { 324 if (objectGroupName) {
325 var group = this._objectGroups[objectGroupName]; 325 var group = this._objectGroups[objectGroupName];
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 * @param {boolean} ownProperties 376 * @param {boolean} ownProperties
377 * @param {boolean} accessorPropertiesOnly 377 * @param {boolean} accessorPropertiesOnly
378 * @return {Array.<RuntimeAgent.PropertyDescriptor>|boolean} 378 * @return {Array.<RuntimeAgent.PropertyDescriptor>|boolean}
379 */ 379 */
380 getProperties: function(objectId, ownProperties, accessorPropertiesOnly) 380 getProperties: function(objectId, ownProperties, accessorPropertiesOnly)
381 { 381 {
382 var parsedObjectId = this._parseObjectId(objectId); 382 var parsedObjectId = this._parseObjectId(objectId);
383 var object = this._objectForId(parsedObjectId); 383 var object = this._objectForId(parsedObjectId);
384 var objectGroupName = this._idToObjectGroupName[parsedObjectId.id]; 384 var objectGroupName = this._idToObjectGroupName[parsedObjectId.id];
385 385
386 if (!this._isDefined(object)) 386 if (!this._isDefined(object) || typeof object !== "object")
aandrey 2014/06/04 15:39:08 I think "console.dir(function(){})" will no longer
Alexandra Mikhaylova 2014/06/05 13:27:43 Done.
387 return false; 387 return false;
388 var descriptors = this._propertyDescriptors(object, ownProperties, acces sorPropertiesOnly); 388 var descriptors = this._propertyDescriptors(object, ownProperties, acces sorPropertiesOnly);
389 389
390 // Go over properties, wrap object values. 390 // Go over properties, wrap object values.
391 for (var i = 0; i < descriptors.length; ++i) { 391 for (var i = 0; i < descriptors.length; ++i) {
392 var descriptor = descriptors[i]; 392 var descriptor = descriptors[i];
393 if ("get" in descriptor) 393 if ("get" in descriptor)
394 descriptor.get = this._wrapObject(descriptor.get, objectGroupNam e); 394 descriptor.get = this._wrapObject(descriptor.get, objectGroupNam e);
395 if ("set" in descriptor) 395 if ("set" in descriptor)
396 descriptor.set = this._wrapObject(descriptor.set, objectGroupNam e); 396 descriptor.set = this._wrapObject(descriptor.set, objectGroupNam e);
(...skipping 11 matching lines...) Expand all
408 408
409 /** 409 /**
410 * @param {string} objectId 410 * @param {string} objectId
411 * @return {Array.<Object>|boolean} 411 * @return {Array.<Object>|boolean}
412 */ 412 */
413 getInternalProperties: function(objectId, ownProperties) 413 getInternalProperties: function(objectId, ownProperties)
414 { 414 {
415 var parsedObjectId = this._parseObjectId(objectId); 415 var parsedObjectId = this._parseObjectId(objectId);
416 var object = this._objectForId(parsedObjectId); 416 var object = this._objectForId(parsedObjectId);
417 var objectGroupName = this._idToObjectGroupName[parsedObjectId.id]; 417 var objectGroupName = this._idToObjectGroupName[parsedObjectId.id];
418 if (!this._isDefined(object)) 418 if (!this._isDefined(object) || typeof object !== "object")
419 return false; 419 return false;
420 var descriptors = []; 420 var descriptors = [];
421 var internalProperties = InjectedScriptHost.getInternalProperties(object ); 421 var internalProperties = InjectedScriptHost.getInternalProperties(object );
422 if (internalProperties) { 422 if (internalProperties) {
423 for (var i = 0; i < internalProperties.length; i++) { 423 for (var i = 0; i < internalProperties.length; i++) {
424 var property = internalProperties[i]; 424 var property = internalProperties[i];
425 var descriptor = { 425 var descriptor = {
426 name: property.name, 426 name: property.name,
427 value: this._wrapObject(property.value, objectGroupName), 427 value: this._wrapObject(property.value, objectGroupName),
428 __proto__: null 428 __proto__: null
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 topCallFrame = asyncCallStacks[asyncOrdinal - 1]; 867 topCallFrame = asyncCallStacks[asyncOrdinal - 1];
868 var ordinal = parsedCallFrameId["ordinal"]; 868 var ordinal = parsedCallFrameId["ordinal"];
869 var callFrame = topCallFrame; 869 var callFrame = topCallFrame;
870 while (--ordinal >= 0 && callFrame) 870 while (--ordinal >= 0 && callFrame)
871 callFrame = callFrame.caller; 871 callFrame = callFrame.caller;
872 return callFrame; 872 return callFrame;
873 }, 873 },
874 874
875 /** 875 /**
876 * @param {Object} objectId 876 * @param {Object} objectId
877 * @return {Object} 877 * @return {Object|symbol}
878 */ 878 */
879 _objectForId: function(objectId) 879 _objectForId: function(objectId)
880 { 880 {
881 return this._idToWrappedObject[objectId.id]; 881 return this._idToWrappedObject[objectId.id];
882 }, 882 },
883 883
884 /** 884 /**
885 * @param {string} objectId 885 * @param {string} objectId
886 * @return {Object} 886 * @return {Object|symbol}
887 */ 887 */
888 findObjectById: function(objectId) 888 findObjectById: function(objectId)
889 { 889 {
890 var parsedObjectId = this._parseObjectId(objectId); 890 var parsedObjectId = this._parseObjectId(objectId);
891 return this._objectForId(parsedObjectId); 891 return this._objectForId(parsedObjectId);
892 }, 892 },
893 893
894 /** 894 /**
895 * @param {string} objectId 895 * @param {string} objectId
896 * @return {Node} 896 * @return {Node}
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after
1642 */ 1642 */
1643 _logEvent: function(event) 1643 _logEvent: function(event)
1644 { 1644 {
1645 inspectedWindow.console.log(event.type, event); 1645 inspectedWindow.console.log(event.type, event);
1646 } 1646 }
1647 } 1647 }
1648 1648
1649 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); 1649 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl();
1650 return injectedScript; 1650 return injectedScript;
1651 }) 1651 })
OLDNEW
« no previous file with comments | « Source/core/inspector/InjectedScriptExterns.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698