| 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 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 /** | 32 /** |
| 33 * @param {!InjectedScriptHostClass} InjectedScriptHost | 33 * @param {!InjectedScriptHostClass} InjectedScriptHost |
| 34 * @param {!Window|!WorkerGlobalScope} inspectedGlobalObject | 34 * @param {!Window|!WorkerGlobalScope} inspectedGlobalObject |
| 35 * @param {number} injectedScriptId | 35 * @param {number} injectedScriptId |
| 36 * @suppress {uselessCode} | 36 * @suppress {uselessCode} |
| 37 */ | 37 */ |
| 38 (function (InjectedScriptHost, inspectedGlobalObject, injectedScriptId) { | 38 (function (InjectedScriptHost, inspectedGlobalObject, injectedScriptId) { |
| 39 | 39 |
| 40 /** | 40 /** |
| 41 * Protect against Object overwritten by the user code. | |
| 42 * @suppress {duplicate} | |
| 43 */ | |
| 44 var Object = /** @type {function(new:Object, *=)} */ ({}.constructor); | |
| 45 | |
| 46 /** | |
| 47 * @param {!Array.<T>} array | 41 * @param {!Array.<T>} array |
| 48 * @param {...} var_args | 42 * @param {...} var_args |
| 49 * @template T | 43 * @template T |
| 50 */ | 44 */ |
| 51 function push(array, var_args) | 45 function push(array, var_args) |
| 52 { | 46 { |
| 53 for (var i = 1; i < arguments.length; ++i) | 47 for (var i = 1; i < arguments.length; ++i) |
| 54 array[array.length] = arguments[i]; | 48 array[array.length] = arguments[i]; |
| 55 } | 49 } |
| 56 | 50 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 | 174 |
| 181 /** | 175 /** |
| 182 * @constructor | 176 * @constructor |
| 183 */ | 177 */ |
| 184 var InjectedScript = function() | 178 var InjectedScript = function() |
| 185 { | 179 { |
| 186 } | 180 } |
| 187 InjectedScriptHost.nullifyPrototype(InjectedScript); | 181 InjectedScriptHost.nullifyPrototype(InjectedScript); |
| 188 | 182 |
| 189 /** | 183 /** |
| 190 * @type {!Object.<string, boolean>} | 184 * @type {!Object<string, boolean>} |
| 191 * @const | 185 * @const |
| 192 */ | 186 */ |
| 193 InjectedScript.primitiveTypes = { | 187 InjectedScript.primitiveTypes = { |
| 194 "undefined": true, | 188 "undefined": true, |
| 195 "boolean": true, | 189 "boolean": true, |
| 196 "number": true, | 190 "number": true, |
| 197 "string": true, | 191 "string": true, |
| 198 __proto__: null | 192 __proto__: null |
| 199 } | 193 } |
| 200 | 194 |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 | 360 |
| 367 /** | 361 /** |
| 368 * @param {!Object} object | 362 * @param {!Object} object |
| 369 * @return {?Object} | 363 * @return {?Object} |
| 370 */ | 364 */ |
| 371 _objectPrototype: function(object) | 365 _objectPrototype: function(object) |
| 372 { | 366 { |
| 373 if (InjectedScriptHost.subtype(object) === "proxy") | 367 if (InjectedScriptHost.subtype(object) === "proxy") |
| 374 return null; | 368 return null; |
| 375 try { | 369 try { |
| 376 return Object.getPrototypeOf(object); | 370 return InjectedScriptHost.getPrototypeOf(object); |
| 377 } catch (e) { | 371 } catch (e) { |
| 378 return null; | 372 return null; |
| 379 } | 373 } |
| 380 }, | 374 }, |
| 381 | 375 |
| 382 /** | 376 /** |
| 383 * @param {!Object} object | 377 * @param {!Object} object |
| 384 * @param {!function(!Array<!Object>, !Object)} addPropertyIfNeeded | 378 * @param {!function(!Array<!Object>, !Object)} addPropertyIfNeeded |
| 385 * @param {boolean=} ownProperties | 379 * @param {boolean=} ownProperties |
| 386 * @param {boolean=} accessorPropertiesOnly | 380 * @param {boolean=} accessorPropertiesOnly |
| (...skipping 26 matching lines...) Expand all Loading... |
| 413 if (isSymbol(property)) | 407 if (isSymbol(property)) |
| 414 name = /** @type {string} */ (injectedScript._describe(prope
rty)); | 408 name = /** @type {string} */ (injectedScript._describe(prope
rty)); |
| 415 else | 409 else |
| 416 name = typeof property === "number" ? ("" + property) : /**
@type {string} */(property); | 410 name = typeof property === "number" ? ("" + property) : /**
@type {string} */(property); |
| 417 | 411 |
| 418 if (subtype === "internal#scopeList" && name === "length") | 412 if (subtype === "internal#scopeList" && name === "length") |
| 419 continue; | 413 continue; |
| 420 | 414 |
| 421 var descriptor; | 415 var descriptor; |
| 422 try { | 416 try { |
| 423 descriptor = Object.getOwnPropertyDescriptor(o, property); | 417 descriptor = InjectedScriptHost.getOwnPropertyDescriptor(o,
property); |
| 424 InjectedScriptHost.nullifyPrototype(descriptor); | 418 InjectedScriptHost.nullifyPrototype(descriptor); |
| 425 var isAccessorProperty = descriptor && ("get" in descriptor
|| "set" in descriptor); | 419 var isAccessorProperty = descriptor && ("get" in descriptor
|| "set" in descriptor); |
| 426 if (accessorPropertiesOnly && !isAccessorProperty) | 420 if (accessorPropertiesOnly && !isAccessorProperty) |
| 427 continue; | 421 continue; |
| 428 if (descriptor && "get" in descriptor && "set" in descriptor
&& name !== "__proto__" && | 422 if (descriptor && "get" in descriptor && "set" in descriptor
&& name !== "__proto__" && |
| 429 InjectedScriptHost.formatAccessorsAsProperties(objec
t, descriptor.get) && | 423 InjectedScriptHost.formatAccessorsAsProperties(objec
t, descriptor.get) && |
| 430 !doesAttributeHaveObservableSideEffectOnGet(object,
name)) { | 424 !doesAttributeHaveObservableSideEffectOnGet(object,
name)) { |
| 431 descriptor.value = object[property]; | 425 descriptor.value = object[property]; |
| 432 descriptor.isOwn = true; | 426 descriptor.isOwn = true; |
| 433 delete descriptor.get; | 427 delete descriptor.get; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 o = /** @type {!Object} */ (o); | 483 o = /** @type {!Object} */ (o); |
| 490 if (InjectedScriptHost.subtype(o) === "proxy") | 484 if (InjectedScriptHost.subtype(o) === "proxy") |
| 491 continue; | 485 continue; |
| 492 | 486 |
| 493 try { | 487 try { |
| 494 if (skipGetOwnPropertyNames && o === object) { | 488 if (skipGetOwnPropertyNames && o === object) { |
| 495 if (!process(o, undefined, o.length)) | 489 if (!process(o, undefined, o.length)) |
| 496 return descriptors; | 490 return descriptors; |
| 497 } else { | 491 } else { |
| 498 // First call Object.keys() to enforce ordering of the prope
rty descriptors. | 492 // First call Object.keys() to enforce ordering of the prope
rty descriptors. |
| 499 if (!process(o, Object.keys(o))) | 493 if (!process(o, InjectedScriptHost.keys(o))) |
| 500 return descriptors; | 494 return descriptors; |
| 501 if (!process(o, Object.getOwnPropertyNames(o))) | 495 if (!process(o, InjectedScriptHost.getOwnPropertyNames(o))) |
| 502 return descriptors; | 496 return descriptors; |
| 503 } | 497 } |
| 504 if (Object.getOwnPropertySymbols) { | 498 if (!process(o, InjectedScriptHost.getOwnPropertySymbols(o))) |
| 505 if (!process(o, Object.getOwnPropertySymbols(o))) | 499 return descriptors; |
| 506 return descriptors; | |
| 507 } | |
| 508 | 500 |
| 509 if (ownProperties) { | 501 if (ownProperties) { |
| 510 var proto = this._objectPrototype(o); | 502 var proto = this._objectPrototype(o); |
| 511 if (proto && !accessorPropertiesOnly) { | 503 if (proto && !accessorPropertiesOnly) { |
| 512 var descriptor = { name: "__proto__", value: proto, writ
able: true, configurable: true, enumerable: false, isOwn: true, __proto__: null
}; | 504 var descriptor = { name: "__proto__", value: proto, writ
able: true, configurable: true, enumerable: false, isOwn: true, __proto__: null
}; |
| 513 if (!addPropertyIfNeeded(descriptors, descriptor)) | 505 if (!addPropertyIfNeeded(descriptors, descriptor)) |
| 514 return descriptors; | 506 return descriptors; |
| 515 } | 507 } |
| 516 } | 508 } |
| 517 } catch (e) { | 509 } catch (e) { |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1085 return string.substr(0, leftHalf) + "\u2026" + string.substr(string.
length - rightHalf, rightHalf); | 1077 return string.substr(0, leftHalf) + "\u2026" + string.substr(string.
length - rightHalf, rightHalf); |
| 1086 } | 1078 } |
| 1087 return string.substr(0, maxLength) + "\u2026"; | 1079 return string.substr(0, maxLength) + "\u2026"; |
| 1088 }, | 1080 }, |
| 1089 | 1081 |
| 1090 __proto__: null | 1082 __proto__: null |
| 1091 } | 1083 } |
| 1092 | 1084 |
| 1093 return injectedScript; | 1085 return injectedScript; |
| 1094 }) | 1086 }) |
| OLD | NEW |