Chromium Code Reviews| 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 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 444 { | 444 { |
| 445 var propertyProcessed = { __proto__: null }; | 445 var propertyProcessed = { __proto__: null }; |
| 446 | 446 |
| 447 /** | 447 /** |
| 448 * @param {?Object} o | 448 * @param {?Object} o |
| 449 * @param {!Iterable<string|symbol|number>|!Array<string|number|symbol>} properties | 449 * @param {!Iterable<string|symbol|number>|!Array<string|number|symbol>} properties |
| 450 */ | 450 */ |
| 451 function* process(o, properties) | 451 function* process(o, properties) |
| 452 { | 452 { |
| 453 for (var property of properties) { | 453 for (var property of properties) { |
| 454 var name; | 454 var name = isSymbol(property) ? (/** @type {string} */ (injected Script._describe(property))) : "" + property; |
| 455 if (isSymbol(property)) | |
| 456 name = /** @type {string} */ (injectedScript._describe(prope rty)); | |
| 457 else | |
| 458 name = typeof property === "number" ? ("" + property) : /** @type {string} */(property); | |
| 459 | |
| 460 if (propertyProcessed[property]) | 455 if (propertyProcessed[property]) |
| 461 continue; | 456 continue; |
| 462 | 457 |
| 463 try { | 458 try { |
| 464 propertyProcessed[property] = true; | 459 propertyProcessed[property] = true; |
| 465 var descriptor = nullifyObjectProto(InjectedScriptHost.suppr essWarningsAndCallFunction(Object.getOwnPropertyDescriptor, Object, [o, property ])); | 460 var descriptor = nullifyObjectProto(InjectedScriptHost.suppr essWarningsAndCallFunction(Object.getOwnPropertyDescriptor, Object, [o, property ])); |
| 466 if (descriptor) { | 461 var isAccessor = "get" in descriptor || "set" in descriptor; |
| 467 if (accessorPropertiesOnly && !("get" in descriptor || " set" in descriptor)) | 462 if (accessorPropertiesOnly && !isAccessor) |
| 468 continue; | |
| 469 if ("get" in descriptor && "set" in descriptor && name ! = "__proto__" && InjectedScriptHost.formatAccessorsAsProperties(object) && !does AttributeHaveObservableSideEffectOnGet(object, name)) { | |
| 470 descriptor.value = InjectedScriptHost.suppressWarnin gsAndCallFunction(function(attribute) { return this[attribute]; }, object, [prop erty]); | |
| 471 descriptor.isOwn = true; | |
| 472 delete descriptor.get; | |
| 473 delete descriptor.set; | |
| 474 } | |
| 475 } else { | |
| 476 // Not all bindings provide proper descriptors. Fall bac k to the writable, configurable property. | |
| 477 if (accessorPropertiesOnly) | |
| 478 continue; | |
| 479 try { | |
| 480 descriptor = { name: name, value: o[property], writa ble: false, configurable: false, enumerable: false, __proto__: null }; | |
| 481 if (o === object) | |
| 482 descriptor.isOwn = true; | |
| 483 yield descriptor; | |
| 484 } catch (e) { | |
| 485 // Silent catch. | |
| 486 } | |
| 487 continue; | 463 continue; |
| 464 | |
| 465 var isGetterFunction = typeof descriptor.get === "function"; | |
| 466 var canFormatAccessorsAsProperty = !(isGetterFunction ? Inje ctedScriptHost.hasFunctionSource(descriptor.get) : true); | |
|
lushnikov
2016/05/06 17:58:56
can we inline "!"
kozy
2016/05/06 18:02:19
Done.
| |
| 467 if (isAccessor && name !== "__proto__" && canFormatAccessors AsProperty && !doesAttributeHaveObservableSideEffectOnGet(object, name)) { | |
| 468 descriptor.value = InjectedScriptHost.suppressWarningsAn dCallFunction(function(attribute) { return this[attribute]; }, object, [property ]); | |
| 469 descriptor.isOwn = true; | |
| 470 delete descriptor.get; | |
| 471 delete descriptor.set; | |
| 488 } | 472 } |
| 489 } catch (e) { | 473 } catch (e) { |
| 490 if (accessorPropertiesOnly) | 474 if (accessorPropertiesOnly) |
| 491 continue; | 475 continue; |
| 492 var descriptor = { __proto__: null }; | 476 var descriptor = { __proto__: null }; |
| 493 descriptor.value = e; | 477 descriptor.value = e; |
| 494 descriptor.wasThrown = true; | 478 descriptor.wasThrown = true; |
| 495 } | 479 } |
| 496 | 480 |
| 497 descriptor.name = name; | 481 descriptor.name = name; |
| (...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1300 /** | 1284 /** |
| 1301 * @param {!Event} event | 1285 * @param {!Event} event |
| 1302 */ | 1286 */ |
| 1303 CommandLineAPIImpl._logEvent = function(event) | 1287 CommandLineAPIImpl._logEvent = function(event) |
| 1304 { | 1288 { |
| 1305 inspectedGlobalObject.console.log(event.type, event); | 1289 inspectedGlobalObject.console.log(event.type, event); |
| 1306 } | 1290 } |
| 1307 | 1291 |
| 1308 return injectedScript; | 1292 return injectedScript; |
| 1309 }) | 1293 }) |
| OLD | NEW |