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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/InjectedScriptSource.js

Issue 1948583003: [DevTools] Runtime.getProperties on proxy object doesn't call traps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 7 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
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 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 * @param {boolean=} ownProperties 439 * @param {boolean=} ownProperties
440 * @param {boolean=} accessorPropertiesOnly 440 * @param {boolean=} accessorPropertiesOnly
441 * @param {?Array.<string>=} propertyNamesOnly 441 * @param {?Array.<string>=} propertyNamesOnly
442 */ 442 */
443 _propertyDescriptors: function*(object, ownProperties, accessorPropertiesOnl y, propertyNamesOnly) 443 _propertyDescriptors: function*(object, ownProperties, accessorPropertiesOnl y, propertyNamesOnly)
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>|!Array.<string|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;
455 if (isSymbol(property))
pfeldman 2016/05/04 23:01:48 Are changes in this file related to your change? D
456 name = /** @type {string} */ (injectedScript._describe(prope rty));
457 else
458 name = typeof property === "number" ? ("" + property) : /** @type {string} */(property);
459
454 if (propertyProcessed[property]) 460 if (propertyProcessed[property])
455 continue; 461 continue;
456 462
457 var name = property;
458 if (isSymbol(property))
459 name = /** @type {string} */ (injectedScript._describe(prope rty));
460
461 try { 463 try {
462 propertyProcessed[property] = true; 464 propertyProcessed[property] = true;
463 var descriptor = nullifyObjectProto(InjectedScriptHost.suppr essWarningsAndCallFunction(Object.getOwnPropertyDescriptor, Object, [o, property ])); 465 var descriptor = nullifyObjectProto(InjectedScriptHost.suppr essWarningsAndCallFunction(Object.getOwnPropertyDescriptor, Object, [o, property ]));
464 if (descriptor) { 466 if (descriptor) {
465 if (accessorPropertiesOnly && !("get" in descriptor || " set" in descriptor)) 467 if (accessorPropertiesOnly && !("get" in descriptor || " set" in descriptor))
466 continue; 468 continue;
467 if ("get" in descriptor && "set" in descriptor && name ! = "__proto__" && InjectedScriptHost.formatAccessorsAsProperties(object) && !does AttributeHaveObservableSideEffectOnGet(object, name)) { 469 if ("get" in descriptor && "set" in descriptor && name ! = "__proto__" && InjectedScriptHost.formatAccessorsAsProperties(object) && !does AttributeHaveObservableSideEffectOnGet(object, name)) {
468 descriptor.value = InjectedScriptHost.suppressWarnin gsAndCallFunction(function(attribute) { return this[attribute]; }, object, [name ]); 470 descriptor.value = InjectedScriptHost.suppressWarnin gsAndCallFunction(function(attribute) { return this[attribute]; }, object, [prop erty]);
469 descriptor.isOwn = true; 471 descriptor.isOwn = true;
470 delete descriptor.get; 472 delete descriptor.get;
471 delete descriptor.set; 473 delete descriptor.set;
472 } 474 }
473 } else { 475 } else {
474 // Not all bindings provide proper descriptors. Fall bac k to the writable, configurable property. 476 // Not all bindings provide proper descriptors. Fall bac k to the writable, configurable property.
475 if (accessorPropertiesOnly) 477 if (accessorPropertiesOnly)
476 continue; 478 continue;
477 try { 479 try {
478 descriptor = { name: name, value: o[property], writa ble: false, configurable: false, enumerable: false, __proto__: null }; 480 descriptor = { name: name, value: o[property], writa ble: false, configurable: false, enumerable: false, __proto__: null };
(...skipping 15 matching lines...) Expand all
494 496
495 descriptor.name = name; 497 descriptor.name = name;
496 if (o === object) 498 if (o === object)
497 descriptor.isOwn = true; 499 descriptor.isOwn = true;
498 if (isSymbol(property)) 500 if (isSymbol(property))
499 descriptor.symbol = property; 501 descriptor.symbol = property;
500 yield descriptor; 502 yield descriptor;
501 } 503 }
502 } 504 }
503 505
504 /**
505 * @param {number} length
506 */
507 function* arrayIndexNames(length)
508 {
509 for (var i = 0; i < length; ++i)
510 yield "" + i;
511 }
512
513 if (propertyNamesOnly) { 506 if (propertyNamesOnly) {
514 for (var i = 0; i < propertyNamesOnly.length; ++i) { 507 for (var i = 0; i < propertyNamesOnly.length; ++i) {
515 var name = propertyNamesOnly[i]; 508 var name = propertyNamesOnly[i];
516 for (var o = object; this._isDefined(o); o = o.__proto__) { 509 for (var o = object; this._isDefined(o); o = InjectedScriptHost. prototype(o)) {
517 if (InjectedScriptHost.suppressWarningsAndCallFunction(Objec t.prototype.hasOwnProperty, o, [name])) { 510 if (InjectedScriptHost.suppressWarningsAndCallFunction(Objec t.prototype.hasOwnProperty, o, [name])) {
518 for (var descriptor of process(o, [name])) 511 for (var descriptor of process(o, [name]))
519 yield descriptor; 512 yield descriptor;
520 break; 513 break;
521 } 514 }
522 if (ownProperties) 515 if (ownProperties)
523 break; 516 break;
524 } 517 }
525 } 518 }
526 return; 519 return;
527 } 520 }
528 521
529 var skipGetOwnPropertyNames; 522 for (var o = object; this._isDefined(o); o = InjectedScriptHost.prototyp e(o)) {
530 try { 523 for (var property of process(o, InjectedScriptHost.ownPropertyNames( o)))
531 skipGetOwnPropertyNames = InjectedScriptHost.isTypedArray(object) && object.length > 500000; 524 yield property;
532 } catch (e) {
533 }
534
535 for (var o = object; this._isDefined(o); o = o.__proto__) {
536 if (skipGetOwnPropertyNames && o === object) {
537 // Avoid OOM crashes from getting all own property names of a la rge TypedArray.
538 for (var descriptor of process(o, arrayIndexNames(o.length)))
539 yield descriptor;
540 } else {
541 // First call Object.keys() to enforce ordering of the property descriptors.
542 for (var descriptor of process(o, Object.keys(/** @type {!Object } */ (o))))
543 yield descriptor;
544 for (var descriptor of process(o, Object.getOwnPropertyNames(/** @type {!Object} */ (o))))
545 yield descriptor;
546 }
547 if (Object.getOwnPropertySymbols) {
548 for (var descriptor of process(o, Object.getOwnPropertySymbols(/ ** @type {!Object} */ (o))))
549 yield descriptor;
550 }
551 if (ownProperties) { 525 if (ownProperties) {
552 if (object.__proto__ && !accessorPropertiesOnly) 526 var proto = InjectedScriptHost.prototype(o);
553 yield { name: "__proto__", value: object.__proto__, writable : true, configurable: true, enumerable: false, isOwn: true, __proto__: null }; 527 if (proto && !accessorPropertiesOnly)
528 yield { name: "__proto__", value: proto, writable: true, con figurable: true, enumerable: false, isOwn: true, __proto__: null };
554 break; 529 break;
555 } 530 }
556 } 531 }
557 }, 532 },
558 533
559 /** 534 /**
560 * @param {string|undefined} objectGroupName 535 * @param {string|undefined} objectGroupName
561 * @param {*} jsonMLObject 536 * @param {*} jsonMLObject
562 * @throws {string} error message 537 * @throws {string} error message
563 */ 538 */
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 /** 1300 /**
1326 * @param {!Event} event 1301 * @param {!Event} event
1327 */ 1302 */
1328 CommandLineAPIImpl._logEvent = function(event) 1303 CommandLineAPIImpl._logEvent = function(event)
1329 { 1304 {
1330 inspectedGlobalObject.console.log(event.type, event); 1305 inspectedGlobalObject.console.log(event.type, event);
1331 } 1306 }
1332 1307
1333 return injectedScript; 1308 return injectedScript;
1334 }) 1309 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698