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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
328 getProperties: function(object, objectGroupName, ownProperties, accessorProp ertiesOnly, generatePreview) | 328 getProperties: function(object, objectGroupName, ownProperties, accessorProp ertiesOnly, generatePreview) |
329 { | 329 { |
330 var subtype = this._subtype(object); | 330 var subtype = this._subtype(object); |
331 if (subtype === "internal#scope") { | 331 if (subtype === "internal#scope") { |
332 // Internally, scope contains object with scope variables and additi onal information like type, | 332 // Internally, scope contains object with scope variables and additi onal information like type, |
333 // we use additional information for preview and would like to repor t variables as scope | 333 // we use additional information for preview and would like to repor t variables as scope |
334 // properties. | 334 // properties. |
335 object = object.object; | 335 object = object.object; |
336 } | 336 } |
337 | 337 |
338 var descriptors = []; | |
339 var iter = this._propertyDescriptors(object, ownProperties, accessorProp ertiesOnly, undefined); | |
340 // Go over properties, wrap object values. | 338 // Go over properties, wrap object values. |
341 for (var descriptor of iter) { | 339 var descriptors = this._propertyDescriptors(object, ownProperties, acces sorPropertiesOnly, undefined, false); |
342 if (subtype === "internal#scopeList" && descriptor.name === "length" ) | 340 for (var i = 0; i < descriptors.length; ++i) { |
343 continue; | 341 var descriptor = descriptors[i]; |
344 if ("get" in descriptor) | 342 if ("get" in descriptor) |
345 descriptor.get = this._wrapObject(descriptor.get, objectGroupNam e); | 343 descriptor.get = this._wrapObject(descriptor.get, objectGroupNam e); |
346 if ("set" in descriptor) | 344 if ("set" in descriptor) |
347 descriptor.set = this._wrapObject(descriptor.set, objectGroupNam e); | 345 descriptor.set = this._wrapObject(descriptor.set, objectGroupNam e); |
348 if ("value" in descriptor) | 346 if ("value" in descriptor) |
349 descriptor.value = this._wrapObject(descriptor.value, objectGrou pName, false, generatePreview); | 347 descriptor.value = this._wrapObject(descriptor.value, objectGrou pName, false, generatePreview); |
350 if (!("configurable" in descriptor)) | 348 if (!("configurable" in descriptor)) |
351 descriptor.configurable = false; | 349 descriptor.configurable = false; |
352 if (!("enumerable" in descriptor)) | 350 if (!("enumerable" in descriptor)) |
353 descriptor.enumerable = false; | 351 descriptor.enumerable = false; |
354 if ("symbol" in descriptor) | 352 if ("symbol" in descriptor) |
355 descriptor.symbol = this._wrapObject(descriptor.symbol, objectGr oupName); | 353 descriptor.symbol = this._wrapObject(descriptor.symbol, objectGr oupName); |
356 push(descriptors, descriptor); | |
357 } | 354 } |
358 return descriptors; | 355 return descriptors; |
359 }, | 356 }, |
360 | 357 |
361 /** | 358 /** |
362 * @param {!Object} object | 359 * @param {!Object} object |
363 * @return {?Object} | 360 * @return {?Object} |
364 */ | 361 */ |
365 _objectPrototype: function(object) | 362 _objectPrototype: function(object) |
366 { | 363 { |
367 if (InjectedScriptHost.subtype(object) === "proxy") | 364 if (InjectedScriptHost.subtype(object) === "proxy") |
368 return null; | 365 return null; |
369 try { | 366 try { |
370 return Object.getPrototypeOf(object); | 367 return Object.getPrototypeOf(object); |
371 } catch (e) { | 368 } catch (e) { |
372 return null; | 369 return null; |
373 } | 370 } |
374 }, | 371 }, |
375 | 372 |
376 /** | 373 /** |
377 * @param {!Object} object | 374 * @param {!Object} object |
378 * @param {boolean=} ownProperties | 375 * @param {boolean=} ownProperties |
379 * @param {boolean=} accessorPropertiesOnly | 376 * @param {boolean=} accessorPropertiesOnly |
380 * @param {?Array.<string>=} propertyNamesOnly | 377 * @param {?Array<string>=} propertyNamesOnly |
378 * @param {boolean=} forPreview | |
379 * @param {!function(): boolean=} isSpaceAvailable | |
380 * @param {!function(!Array<!Object>, !Object)=} customPush | |
381 * @return {!Array<!Object>} | |
381 */ | 382 */ |
382 _propertyDescriptors: function*(object, ownProperties, accessorPropertiesOnl y, propertyNamesOnly) | 383 _propertyDescriptors: function(object, ownProperties, accessorPropertiesOnly , propertyNamesOnly, forPreview, isSpaceAvailable, customPush) |
383 { | 384 { |
385 var descriptors = []; | |
386 descriptors.__proto__ = null; | |
387 isSpaceAvailable = isSpaceAvailable || function() { return true; }; | |
388 customPush = customPush || push; | |
389 if (!isSpaceAvailable()) | |
390 return descriptors; | |
384 var propertyProcessed = { __proto__: null }; | 391 var propertyProcessed = { __proto__: null }; |
392 var subtype = InjectedScriptHost.subtype(object); | |
385 | 393 |
386 /** | 394 /** |
387 * @param {?Object} o | 395 * @param {!Object} o |
388 * @param {!Iterable<string|symbol|number>|!Array<string|number|symbol>} properties | 396 * @param {!Array<string|number|symbol>=} properties |
397 * @param {number=} objectLength | |
389 */ | 398 */ |
390 function* process(o, properties) | 399 function process(o, properties, objectLength) |
391 { | 400 { |
392 for (var property of properties) { | 401 // When properties is not provided, iterate over the object's indice s. |
402 var length = properties ? properties.length : objectLength; | |
403 for (var i = 0; i < length; ++i) { | |
404 if (!isSpaceAvailable()) | |
405 return; | |
406 var property = properties ? properties[i] : ("" + i); | |
407 if (propertyProcessed[property]) | |
408 continue; | |
409 propertyProcessed[property] = true; | |
393 var name; | 410 var name; |
394 if (isSymbol(property)) | 411 if (isSymbol(property)) |
395 name = /** @type {string} */ (injectedScript._describe(prope rty)); | 412 name = /** @type {string} */ (injectedScript._describe(prope rty)); |
396 else | 413 else |
397 name = typeof property === "number" ? ("" + property) : /** @type {string} */(property); | 414 name = typeof property === "number" ? ("" + property) : /** @type {string} */(property); |
398 | 415 |
399 if (propertyProcessed[property]) | 416 if (subtype === "internal#scopeList" && name === "length") |
400 continue; | 417 continue; |
401 | 418 |
419 var descriptor; | |
402 try { | 420 try { |
403 propertyProcessed[property] = true; | 421 descriptor = Object.getOwnPropertyDescriptor(o, property); |
404 var descriptor = nullifyObjectProto(Object.getOwnPropertyDes criptor(o, property)); | 422 var isAccessorProperty = descriptor && ("get" in descriptor || "set" in descriptor); |
405 if (descriptor) { | 423 if (accessorPropertiesOnly && !isAccessorProperty) |
406 if (accessorPropertiesOnly && !("get" in descriptor || " set" in descriptor)) | 424 continue; |
407 continue; | 425 if (descriptor && "get" in descriptor && "set" in descriptor && name !== "__proto__" && |
408 if ("get" in descriptor && "set" in descriptor && name ! = "__proto__" && InjectedScriptHost.formatAccessorsAsProperties(object, descript or.get) && !doesAttributeHaveObservableSideEffectOnGet(object, name)) { | 426 InjectedScriptHost.formatAccessorsAsProperties(objec t, descriptor.get) && |
409 descriptor.value = object[property]; | 427 !doesAttributeHaveObservableSideEffectOnGet(object, name)) { |
410 descriptor.isOwn = true; | 428 descriptor.value = object[property]; |
411 delete descriptor.get; | 429 descriptor.isOwn = true; |
412 delete descriptor.set; | 430 delete descriptor.get; |
413 } | 431 delete descriptor.set; |
414 } else { | 432 } |
415 // Not all bindings provide proper descriptors. Fall bac k to the writable, configurable property. | 433 } catch (e) { |
416 if (accessorPropertiesOnly) | 434 if (accessorPropertiesOnly || forPreview) |
417 continue; | 435 continue; |
418 try { | 436 descriptor = { value: e, wasThrown: true }; |
419 descriptor = { name: name, value: o[property], writa ble: false, configurable: false, enumerable: false, __proto__: null }; | 437 } |
420 if (o === object) | 438 |
421 descriptor.isOwn = true; | 439 // Not all bindings provide proper descriptors. Fall back to the non-configurable, non-enumerable, |
422 yield descriptor; | 440 // non-writable property. |
423 } catch (e) { | 441 if (!descriptor) { |
424 // Silent catch. | 442 try { |
425 } | 443 descriptor = { value: o[property], writable: false }; |
444 } catch (e) { | |
445 // Silent catch. | |
426 continue; | 446 continue; |
427 } | 447 } |
428 } catch (e) { | |
429 if (accessorPropertiesOnly) | |
430 continue; | |
431 var descriptor = { __proto__: null }; | |
432 descriptor.value = e; | |
433 descriptor.wasThrown = true; | |
434 } | 448 } |
435 | 449 |
436 descriptor.name = name; | 450 descriptor.name = name; |
437 if (o === object) | 451 if (o === object) |
438 descriptor.isOwn = true; | 452 descriptor.isOwn = true; |
439 if (isSymbol(property)) | 453 if (isSymbol(property)) |
440 descriptor.symbol = property; | 454 descriptor.symbol = property; |
441 yield descriptor; | 455 if (forPreview) { |
456 // Ignore __proto__ property. | |
457 if (name === "__proto__") | |
458 continue; | |
459 | |
460 // Ignore length property of array. | |
461 if ((subtype === "array" || subtype === "typedarray") && nam e === "length") | |
462 continue; | |
463 | |
464 // Ignore size property of map, set. | |
465 if ((subtype === "map" || subtype === "set") && name === "si ze") | |
466 continue; | |
467 | |
468 // Never preview prototype properties. | |
469 if (!descriptor.isOwn) | |
470 continue; | |
471 | |
472 // Ignore computed properties unless they have getters. | |
473 if (!("value" in descriptor) && !descriptor.get) | |
474 continue; | |
475 } | |
476 customPush(descriptors, nullifyObjectProto(descriptor)); | |
kozy
2017/02/23 23:27:15
let's use regular push and pass callback to functi
luoe
2017/02/24 00:46:01
After our offline discussion, I've removed isSpace
| |
442 } | 477 } |
443 } | 478 } |
444 | 479 |
445 if (propertyNamesOnly) { | 480 if (propertyNamesOnly) { |
446 for (var i = 0; i < propertyNamesOnly.length; ++i) { | 481 for (var i = 0; i < propertyNamesOnly.length; ++i) { |
447 var name = propertyNamesOnly[i]; | 482 var name = propertyNamesOnly[i]; |
448 for (var o = object; this._isDefined(o); o = this._objectPrototy pe(o)) { | 483 for (var o = object; this._isDefined(o); o = this._objectPrototy pe(/** @type {!Object} */ (o))) { |
484 o = /** @type {!Object} */ (o); | |
449 if (InjectedScriptHost.objectHasOwnProperty(o, name)) { | 485 if (InjectedScriptHost.objectHasOwnProperty(o, name)) { |
450 for (var descriptor of process(o, [name])) | 486 process(o, [name]); |
451 yield descriptor; | 487 if (!isSpaceAvailable()) |
488 return descriptors; | |
452 break; | 489 break; |
453 } | 490 } |
454 if (ownProperties) | 491 if (ownProperties || forPreview) |
455 break; | 492 break; |
456 } | 493 } |
457 } | 494 } |
458 return; | 495 return descriptors; |
459 } | 496 } |
460 | 497 |
461 /** | 498 for (var o = object; this._isDefined(o); o = this._objectPrototype(/** @ type {!Object} */ (o))) { |
462 * @param {number} length | 499 o = /** @type {!Object} */ (o); |
463 */ | |
464 function* arrayIndexNames(length) | |
465 { | |
466 for (var i = 0; i < length; ++i) | |
467 yield "" + i; | |
468 } | |
469 | |
470 var skipGetOwnPropertyNames; | |
471 try { | |
472 skipGetOwnPropertyNames = InjectedScriptHost.subtype(object) === "ty pedarray" && object.length > 500000; | |
473 } catch (e) { | |
474 } | |
475 | |
476 for (var o = object; this._isDefined(o); o = this._objectPrototype(o)) { | |
477 if (InjectedScriptHost.subtype(o) === "proxy") | 500 if (InjectedScriptHost.subtype(o) === "proxy") |
478 continue; | 501 continue; |
479 if (skipGetOwnPropertyNames && o === object) { | 502 |
480 // Avoid OOM crashes from getting all own property names of a la rge TypedArray. | 503 try { |
481 for (var descriptor of process(o, arrayIndexNames(o.length))) | 504 var objectLength = o.length; |
482 yield descriptor; | 505 var skipGetOwnPropertyNames = subtype === "typedarray" && object Length > 500000; |
483 } else { | 506 if (skipGetOwnPropertyNames && o === object) { |
484 // First call Object.keys() to enforce ordering of the property descriptors. | 507 process(o, undefined, objectLength); |
485 for (var descriptor of process(o, Object.keys(/** @type {!Object } */ (o)))) | 508 } else { |
486 yield descriptor; | 509 // First call Object.keys() to enforce ordering of the prope rty descriptors. |
487 for (var descriptor of process(o, Object.getOwnPropertyNames(/** @type {!Object} */ (o)))) | 510 process(o, Object.keys(o)); |
488 yield descriptor; | 511 if (isSpaceAvailable()) |
512 process(o, Object.getOwnPropertyNames(o)); | |
513 } | |
514 if (isSpaceAvailable() && Object.getOwnPropertySymbols) | |
515 process(o, Object.getOwnPropertySymbols(o)); | |
516 if (ownProperties) { | |
517 var proto = this._objectPrototype(o); | |
518 if (isSpaceAvailable() && proto && !accessorPropertiesOnly) { | |
519 var descriptor = { name: "__proto__", value: proto, writ able: true, configurable: true, enumerable: false, isOwn: true, __proto__: null }; | |
520 customPush(descriptors, descriptor); | |
521 } | |
522 } | |
523 } catch (e) { | |
489 } | 524 } |
490 if (Object.getOwnPropertySymbols) { | 525 |
491 for (var descriptor of process(o, Object.getOwnPropertySymbols(/ ** @type {!Object} */ (o)))) | 526 if (ownProperties || forPreview) |
492 yield descriptor; | |
493 } | |
494 if (ownProperties) { | |
495 var proto = this._objectPrototype(o); | |
496 if (proto && !accessorPropertiesOnly) | |
497 yield { name: "__proto__", value: proto, writable: true, con figurable: true, enumerable: false, isOwn: true, __proto__: null }; | |
498 break; | 527 break; |
499 } | |
500 } | 528 } |
529 return descriptors; | |
501 }, | 530 }, |
502 | 531 |
503 /** | 532 /** |
504 * @param {string|undefined} objectGroupName | 533 * @param {string|undefined} objectGroupName |
505 * @param {*} jsonMLObject | 534 * @param {*} jsonMLObject |
506 * @throws {string} error message | 535 * @throws {string} error message |
507 */ | 536 */ |
508 _substituteObjectTagsInCustomPreview: function(objectGroupName, jsonMLObject ) | 537 _substituteObjectTagsInCustomPreview: function(objectGroupName, jsonMLObject ) |
509 { | 538 { |
510 var maxCustomPreviewRecursionDepth = 20; | 539 var maxCustomPreviewRecursionDepth = 20; |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
856 * @param {?Array.<string>=} firstLevelKeys | 885 * @param {?Array.<string>=} firstLevelKeys |
857 * @param {?Array.<string>=} secondLevelKeys | 886 * @param {?Array.<string>=} secondLevelKeys |
858 * @param {boolean=} isTable | 887 * @param {boolean=} isTable |
859 * @param {boolean=} skipEntriesPreview | 888 * @param {boolean=} skipEntriesPreview |
860 * @return {!RuntimeAgent.ObjectPreview} preview | 889 * @return {!RuntimeAgent.ObjectPreview} preview |
861 */ | 890 */ |
862 _generatePreview: function(object, firstLevelKeys, secondLevelKeys, isTable, skipEntriesPreview) | 891 _generatePreview: function(object, firstLevelKeys, secondLevelKeys, isTable, skipEntriesPreview) |
863 { | 892 { |
864 var preview = this._createEmptyPreview(); | 893 var preview = this._createEmptyPreview(); |
865 var firstLevelKeysCount = firstLevelKeys ? firstLevelKeys.length : 0; | 894 var firstLevelKeysCount = firstLevelKeys ? firstLevelKeys.length : 0; |
866 | 895 var overflow = false; |
867 var propertiesThreshold = { | 896 var propertiesThreshold = { |
868 properties: isTable ? 1000 : max(5, firstLevelKeysCount), | 897 properties: isTable ? 1000 : max(5, firstLevelKeysCount), |
869 indexes: isTable ? 1000 : max(100, firstLevelKeysCount), | 898 indexes: isTable ? 1000 : max(100, firstLevelKeysCount), |
870 __proto__: null | 899 __proto__: null |
871 }; | 900 }; |
872 | 901 |
873 try { | 902 try { |
874 var descriptors = injectedScript._propertyDescriptors(object, undefi ned, undefined, firstLevelKeys); | 903 var descriptors = injectedScript._propertyDescriptors(object, undefi ned, undefined, firstLevelKeys, true, isSpaceAvailable, customPush); |
875 | |
876 this._appendPropertyDescriptors(preview, descriptors, propertiesThre shold, secondLevelKeys, isTable); | |
877 if (propertiesThreshold.indexes < 0 || propertiesThreshold.propertie s < 0) | |
878 return preview; | |
879 | 904 |
880 // Add internal properties to preview. | 905 // Add internal properties to preview. |
881 var rawInternalProperties = InjectedScriptHost.getInternalProperties (object) || []; | 906 var rawInternalProperties = InjectedScriptHost.getInternalProperties (object) || []; |
882 var internalProperties = []; | 907 var internalProperties = []; |
883 var entries = null; | 908 var entries = null; |
884 for (var i = 0; i < rawInternalProperties.length; i += 2) { | 909 for (var i = 0; i < rawInternalProperties.length; i += 2) { |
885 if (rawInternalProperties[i] === "[[Entries]]") { | 910 if (rawInternalProperties[i] === "[[Entries]]") { |
886 entries = /** @type {!Array<*>} */(rawInternalProperties[i + 1]); | 911 entries = /** @type {!Array<*>} */(rawInternalProperties[i + 1]); |
887 continue; | 912 continue; |
888 } | 913 } |
889 push(internalProperties, { | 914 var internalPropertyDescriptor = { |
890 name: rawInternalProperties[i], | 915 name: rawInternalProperties[i], |
891 value: rawInternalProperties[i + 1], | 916 value: rawInternalProperties[i + 1], |
892 isOwn: true, | 917 isOwn: true, |
893 enumerable: true, | 918 enumerable: true, |
894 __proto__: null | 919 __proto__: null |
895 }); | 920 }; |
921 customPush(descriptors, internalPropertyDescriptor); | |
896 } | 922 } |
897 this._appendPropertyDescriptors(preview, internalProperties, propert iesThreshold, secondLevelKeys, isTable); | 923 this._appendPropertyPreviewDescriptors(preview, descriptors, secondL evelKeys, isTable); |
898 | 924 |
899 if (this.subtype === "map" || this.subtype === "set" || this.subtype === "iterator") | 925 if (this.subtype === "map" || this.subtype === "set" || this.subtype === "iterator") |
900 this._appendEntriesPreview(entries, preview, skipEntriesPreview) ; | 926 this._appendEntriesPreview(entries, preview, skipEntriesPreview) ; |
901 | 927 |
902 } catch (e) {} | 928 } catch (e) {} |
929 preview.overflow = preview.overflow || overflow; | |
903 | 930 |
904 return preview; | 931 return preview; |
932 | |
933 /** | |
934 * @return {boolean} | |
935 */ | |
936 function isSpaceAvailable() { | |
937 return propertiesThreshold.indexes >= 0 && propertiesThreshold.prope rties >= 0; | |
938 } | |
939 | |
940 /** | |
941 * @param {!Array<!Object>} descriptors | |
942 * @param {!Object} descriptor | |
943 */ | |
944 function customPush(descriptors, descriptor) { | |
945 if (toString(descriptor.name >>> 0) === descriptor.name) | |
946 propertiesThreshold.indexes--; | |
947 else | |
948 propertiesThreshold.properties--; | |
949 if (!isSpaceAvailable()) | |
950 overflow = true; | |
951 else | |
952 push(descriptors, descriptor); | |
953 } | |
905 }, | 954 }, |
906 | 955 |
907 /** | 956 /** |
908 * @param {!RuntimeAgent.ObjectPreview} preview | 957 * @param {!RuntimeAgent.ObjectPreview} preview |
909 * @param {!Array.<*>|!Iterable.<*>} descriptors | 958 * @param {!Array.<*>|!Iterable.<*>} descriptors |
910 * @param {!Object} propertiesThreshold | |
911 * @param {?Array.<string>=} secondLevelKeys | 959 * @param {?Array.<string>=} secondLevelKeys |
912 * @param {boolean=} isTable | 960 * @param {boolean=} isTable |
913 */ | 961 */ |
914 _appendPropertyDescriptors: function(preview, descriptors, propertiesThresho ld, secondLevelKeys, isTable) | 962 _appendPropertyPreviewDescriptors: function(preview, descriptors, secondLeve lKeys, isTable) |
915 { | 963 { |
916 for (var descriptor of descriptors) { | 964 for (var i = 0; i < descriptors.length; ++i) { |
917 if (propertiesThreshold.indexes < 0 || propertiesThreshold.propertie s < 0) | 965 var descriptor = descriptors[i]; |
918 break; | |
919 if (!descriptor || descriptor.wasThrown) | |
920 continue; | |
921 | |
922 var name = descriptor.name; | 966 var name = descriptor.name; |
923 | |
924 // Ignore __proto__ property. | |
925 if (name === "__proto__") | |
926 continue; | |
927 | |
928 // Ignore length property of array. | |
929 if ((this.subtype === "array" || this.subtype === "typedarray") && n ame === "length") | |
930 continue; | |
931 | |
932 // Ignore size property of map, set. | |
933 if ((this.subtype === "map" || this.subtype === "set") && name === " size") | |
934 continue; | |
935 | |
936 // Never preview prototype properties. | |
937 if (!descriptor.isOwn) | |
938 continue; | |
939 | |
940 // Ignore computed properties unless they have getters. | |
941 if (!("value" in descriptor)) { | |
942 if (descriptor.get) | |
943 this._appendPropertyPreview(preview, { name: name, type: "ac cessor", __proto__: null }, propertiesThreshold); | |
944 continue; | |
945 } | |
946 | |
947 var value = descriptor.value; | 967 var value = descriptor.value; |
948 var type = typeof value; | 968 var type = typeof value; |
949 | 969 |
950 // Special-case HTMLAll. | 970 // Special-case HTMLAll. |
951 if (type === "undefined" && injectedScript._isHTMLAllCollection(valu e)) | 971 if (type === "undefined" && injectedScript._isHTMLAllCollection(valu e)) |
952 type = "object"; | 972 type = "object"; |
953 | 973 |
954 // Render own properties. | 974 // Ignore computed properties unless they have getters. |
955 if (value === null) { | 975 if (descriptor.get && !("value" in descriptor)) { |
956 this._appendPropertyPreview(preview, { name: name, type: "object ", subtype: "null", value: "null", __proto__: null }, propertiesThreshold); | 976 push(preview.properties, { name: name, type: "accessor", __proto __: null }); |
957 continue; | 977 continue; |
958 } | 978 } |
959 | 979 |
980 // Render own properties. | |
981 if (value === null) { | |
982 push(preview.properties, { name: name, type: "object", subtype: "null", value: "null", __proto__: null }); | |
983 continue; | |
984 } | |
985 | |
960 var maxLength = 100; | 986 var maxLength = 100; |
961 if (InjectedScript.primitiveTypes[type]) { | 987 if (InjectedScript.primitiveTypes[type]) { |
962 if (type === "string" && value.length > maxLength) | 988 if (type === "string" && value.length > maxLength) |
963 value = this._abbreviateString(value, maxLength, true); | 989 value = this._abbreviateString(value, maxLength, true); |
964 this._appendPropertyPreview(preview, { name: name, type: type, v alue: toStringDescription(value), __proto__: null }, propertiesThreshold); | 990 push(preview.properties, { name: name, type: type, value: toStri ngDescription(value), __proto__: null }); |
965 continue; | 991 continue; |
966 } | 992 } |
967 | 993 |
968 var property = { name: name, type: type, __proto__: null }; | 994 var property = { name: name, type: type, __proto__: null }; |
969 var subtype = injectedScript._subtype(value); | 995 var subtype = injectedScript._subtype(value); |
970 if (subtype) | 996 if (subtype) |
971 property.subtype = subtype; | 997 property.subtype = subtype; |
972 | 998 |
973 if (secondLevelKeys === null || secondLevelKeys) { | 999 if (secondLevelKeys === null || secondLevelKeys) { |
974 var subPreview = this._generatePreview(value, secondLevelKeys || undefined, undefined, isTable); | 1000 var subPreview = this._generatePreview(value, secondLevelKeys || undefined, undefined, isTable); |
975 property.valuePreview = subPreview; | 1001 property.valuePreview = subPreview; |
976 if (subPreview.overflow) | 1002 if (subPreview.overflow) |
977 preview.overflow = true; | 1003 preview.overflow = true; |
978 } else { | 1004 } else { |
979 var description = ""; | 1005 var description = ""; |
980 if (type !== "function") | 1006 if (type !== "function") |
981 description = this._abbreviateString(/** @type {string} */ ( injectedScript._describe(value)), maxLength, subtype === "regexp"); | 1007 description = this._abbreviateString(/** @type {string} */ ( injectedScript._describe(value)), maxLength, subtype === "regexp"); |
982 property.value = description; | 1008 property.value = description; |
983 } | 1009 } |
984 this._appendPropertyPreview(preview, property, propertiesThreshold); | |
985 } | |
986 }, | |
987 | |
988 /** | |
989 * @param {!RuntimeAgent.ObjectPreview} preview | |
990 * @param {!Object} property | |
991 * @param {!Object} propertiesThreshold | |
992 */ | |
993 _appendPropertyPreview: function(preview, property, propertiesThreshold) | |
994 { | |
995 if (toString(property.name >>> 0) === property.name) | |
996 propertiesThreshold.indexes--; | |
997 else | |
998 propertiesThreshold.properties--; | |
999 if (propertiesThreshold.indexes < 0 || propertiesThreshold.properties < 0) { | |
1000 preview.overflow = true; | |
1001 } else { | |
1002 push(preview.properties, property); | 1010 push(preview.properties, property); |
1003 } | 1011 } |
1004 }, | 1012 }, |
1005 | 1013 |
1006 /** | 1014 /** |
1007 * @param {?Array<*>} entries | 1015 * @param {?Array<*>} entries |
1008 * @param {!RuntimeAgent.ObjectPreview} preview | 1016 * @param {!RuntimeAgent.ObjectPreview} preview |
1009 * @param {boolean=} skipEntriesPreview | 1017 * @param {boolean=} skipEntriesPreview |
1010 */ | 1018 */ |
1011 _appendEntriesPreview: function(entries, preview, skipEntriesPreview) | 1019 _appendEntriesPreview: function(entries, preview, skipEntriesPreview) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1062 return string.substr(0, leftHalf) + "\u2026" + string.substr(string. length - rightHalf, rightHalf); | 1070 return string.substr(0, leftHalf) + "\u2026" + string.substr(string. length - rightHalf, rightHalf); |
1063 } | 1071 } |
1064 return string.substr(0, maxLength) + "\u2026"; | 1072 return string.substr(0, maxLength) + "\u2026"; |
1065 }, | 1073 }, |
1066 | 1074 |
1067 __proto__: null | 1075 __proto__: null |
1068 } | 1076 } |
1069 | 1077 |
1070 return injectedScript; | 1078 return injectedScript; |
1071 }) | 1079 }) |
OLD | NEW |