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

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

Issue 1950303004: [DevTools] Add additional accessor check in InjectedScriptSource.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 if (accessorPropertiesOnly && !("get" in descriptor || "set" in descriptor))
467 if (accessorPropertiesOnly && !("get" in descriptor || " set" in descriptor))
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; 462 continue;
463
464 var isGetterFunction = typeof descriptor.get === "function";
465 var hasGetterFunctionSource = isGetterFunction ? InjectedScr iptHost.hasFunctionSource(descriptor.get) : false;
lushnikov 2016/05/06 04:28:11 var canFormatAccessorsAsProperty = isGetterFunctio
kozy 2016/05/06 15:24:55 Done.
466 if ("get" in descriptor && "set" in descriptor && name !== " __proto__" && (isGetterFunction && !hasGetterFunctionSource) && !doesAttributeHa veObservableSideEffectOnGet(object, name)) {
467 descriptor.value = InjectedScriptHost.suppressWarningsAn dCallFunction(function(attribute) { return this[attribute]; }, object, [property ]);
468 descriptor.isOwn = true;
469 delete descriptor.get;
470 delete descriptor.set;
488 } 471 }
489 } catch (e) { 472 } catch (e) {
490 if (accessorPropertiesOnly) 473 if (accessorPropertiesOnly)
491 continue; 474 continue;
492 var descriptor = { __proto__: null }; 475 var descriptor = { __proto__: null };
493 descriptor.value = e; 476 descriptor.value = e;
494 descriptor.wasThrown = true; 477 descriptor.wasThrown = true;
495 } 478 }
496 479
497 descriptor.name = name; 480 descriptor.name = name;
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after
1300 /** 1283 /**
1301 * @param {!Event} event 1284 * @param {!Event} event
1302 */ 1285 */
1303 CommandLineAPIImpl._logEvent = function(event) 1286 CommandLineAPIImpl._logEvent = function(event)
1304 { 1287 {
1305 inspectedGlobalObject.console.log(event.type, event); 1288 inspectedGlobalObject.console.log(event.type, event);
1306 } 1289 }
1307 1290
1308 return injectedScript; 1291 return injectedScript;
1309 }) 1292 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698