| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 | 107 |
| 108 /** | 108 /** |
| 109 * FireBug's array detection. | 109 * FireBug's array detection. |
| 110 * @param {*} obj | 110 * @param {*} obj |
| 111 * @return {boolean} | 111 * @return {boolean} |
| 112 */ | 112 */ |
| 113 function isArrayLike(obj) | 113 function isArrayLike(obj) |
| 114 { | 114 { |
| 115 if (typeof obj !== "object") | 115 if (typeof obj !== "object") |
| 116 return false; | 116 return false; |
| 117 try { | 117 var splice = InjectedScriptHost.getProperty(obj, "splice"); |
| 118 if (typeof obj.splice === "function") { | 118 if (typeof splice === "function") { |
| 119 if (!InjectedScriptHost.objectHasOwnProperty(/** @type {!Object} */
(obj), "length")) | 119 if (!InjectedScriptHost.objectHasOwnProperty(/** @type {!Object} */ (obj
), "length")) |
| 120 return false; | 120 return false; |
| 121 var len = obj.length; | 121 var len = InjectedScriptHost.getProperty(obj, "length"); |
| 122 return typeof len === "number" && isUInt32(len); | 122 return typeof len === "number" && isUInt32(len); |
| 123 } | |
| 124 } catch (e) { | |
| 125 } | 123 } |
| 126 return false; | 124 return false; |
| 127 } | 125 } |
| 128 | 126 |
| 129 /** | 127 /** |
| 130 * @param {number} a | 128 * @param {number} a |
| 131 * @param {number} b | 129 * @param {number} b |
| 132 * @return {number} | 130 * @return {number} |
| 133 */ | 131 */ |
| 134 function max(a, b) | 132 function max(a, b) |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 * @param {!Object} object | 383 * @param {!Object} object |
| 386 * @param {!function(!Array<!Object>, !Object)} addPropertyIfNeeded | 384 * @param {!function(!Array<!Object>, !Object)} addPropertyIfNeeded |
| 387 * @param {boolean=} ownProperties | 385 * @param {boolean=} ownProperties |
| 388 * @param {boolean=} accessorPropertiesOnly | 386 * @param {boolean=} accessorPropertiesOnly |
| 389 * @param {?Array<string>=} propertyNamesOnly | 387 * @param {?Array<string>=} propertyNamesOnly |
| 390 * @return {!Array<!Object>} | 388 * @return {!Array<!Object>} |
| 391 */ | 389 */ |
| 392 _propertyDescriptors: function(object, addPropertyIfNeeded, ownProperties, a
ccessorPropertiesOnly, propertyNamesOnly) | 390 _propertyDescriptors: function(object, addPropertyIfNeeded, ownProperties, a
ccessorPropertiesOnly, propertyNamesOnly) |
| 393 { | 391 { |
| 394 var descriptors = []; | 392 var descriptors = []; |
| 395 descriptors.__proto__ = null; | 393 InjectedScriptHost.nullifyPrototype(descriptors); |
| 396 var propertyProcessed = { __proto__: null }; | 394 var propertyProcessed = { __proto__: null }; |
| 397 var subtype = InjectedScriptHost.subtype(object); | 395 var subtype = InjectedScriptHost.subtype(object); |
| 398 | 396 |
| 399 /** | 397 /** |
| 400 * @param {!Object} o | 398 * @param {!Object} o |
| 401 * @param {!Array<string|number|symbol>=} properties | 399 * @param {!Array<string|number|symbol>=} properties |
| 402 * @param {number=} objectLength | 400 * @param {number=} objectLength |
| 403 * @return {boolean} | 401 * @return {boolean} |
| 404 */ | 402 */ |
| 405 function process(o, properties, objectLength) | 403 function process(o, properties, objectLength) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 416 name = /** @type {string} */ (injectedScript._describe(prope
rty)); | 414 name = /** @type {string} */ (injectedScript._describe(prope
rty)); |
| 417 else | 415 else |
| 418 name = typeof property === "number" ? ("" + property) : /**
@type {string} */(property); | 416 name = typeof property === "number" ? ("" + property) : /**
@type {string} */(property); |
| 419 | 417 |
| 420 if (subtype === "internal#scopeList" && name === "length") | 418 if (subtype === "internal#scopeList" && name === "length") |
| 421 continue; | 419 continue; |
| 422 | 420 |
| 423 var descriptor; | 421 var descriptor; |
| 424 try { | 422 try { |
| 425 descriptor = Object.getOwnPropertyDescriptor(o, property); | 423 descriptor = Object.getOwnPropertyDescriptor(o, property); |
| 424 InjectedScriptHost.nullifyPrototype(descriptor); |
| 426 var isAccessorProperty = descriptor && ("get" in descriptor
|| "set" in descriptor); | 425 var isAccessorProperty = descriptor && ("get" in descriptor
|| "set" in descriptor); |
| 427 if (accessorPropertiesOnly && !isAccessorProperty) | 426 if (accessorPropertiesOnly && !isAccessorProperty) |
| 428 continue; | 427 continue; |
| 429 if (descriptor && "get" in descriptor && "set" in descriptor
&& name !== "__proto__" && | 428 if (descriptor && "get" in descriptor && "set" in descriptor
&& name !== "__proto__" && |
| 430 InjectedScriptHost.formatAccessorsAsProperties(objec
t, descriptor.get) && | 429 InjectedScriptHost.formatAccessorsAsProperties(objec
t, descriptor.get) && |
| 431 !doesAttributeHaveObservableSideEffectOnGet(object,
name)) { | 430 !doesAttributeHaveObservableSideEffectOnGet(object,
name)) { |
| 432 descriptor.value = object[property]; | 431 descriptor.value = object[property]; |
| 433 descriptor.isOwn = true; | 432 descriptor.isOwn = true; |
| 434 delete descriptor.get; | 433 delete descriptor.get; |
| 435 delete descriptor.set; | 434 delete descriptor.set; |
| 436 } | 435 } |
| 437 } catch (e) { | 436 } catch (e) { |
| 438 if (accessorPropertiesOnly) | 437 if (accessorPropertiesOnly) |
| 439 continue; | 438 continue; |
| 440 descriptor = { value: e, wasThrown: true }; | 439 descriptor = { value: e, wasThrown: true, __proto__: null }; |
| 441 } | 440 } |
| 442 | 441 |
| 443 // Not all bindings provide proper descriptors. Fall back to the
non-configurable, non-enumerable, | 442 // Not all bindings provide proper descriptors. Fall back to the
non-configurable, non-enumerable, |
| 444 // non-writable property. | 443 // non-writable property. |
| 445 if (!descriptor) { | 444 if (!descriptor) { |
| 446 try { | 445 try { |
| 447 descriptor = { value: o[property], writable: false }; | 446 descriptor = { value: o[property], writable: false, __pr
oto__: null }; |
| 448 } catch (e) { | 447 } catch (e) { |
| 449 // Silent catch. | 448 // Silent catch. |
| 450 continue; | 449 continue; |
| 451 } | 450 } |
| 452 } | 451 } |
| 453 | 452 |
| 454 descriptor.name = name; | 453 descriptor.name = name; |
| 455 if (o === object) | 454 if (o === object) |
| 456 descriptor.isOwn = true; | 455 descriptor.isOwn = true; |
| 457 if (isSymbol(property)) | 456 if (isSymbol(property)) |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1086 return string.substr(0, leftHalf) + "\u2026" + string.substr(string.
length - rightHalf, rightHalf); | 1085 return string.substr(0, leftHalf) + "\u2026" + string.substr(string.
length - rightHalf, rightHalf); |
| 1087 } | 1086 } |
| 1088 return string.substr(0, maxLength) + "\u2026"; | 1087 return string.substr(0, maxLength) + "\u2026"; |
| 1089 }, | 1088 }, |
| 1090 | 1089 |
| 1091 __proto__: null | 1090 __proto__: null |
| 1092 } | 1091 } |
| 1093 | 1092 |
| 1094 return injectedScript; | 1093 return injectedScript; |
| 1095 }) | 1094 }) |
| OLD | NEW |