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

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

Issue 2190353004: [DevTools] Replace InjectedScriptHost.suppressWarningsAndCallFunction with hasOwnProperty. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 4 years, 4 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 * FireBug's array detection. 108 * FireBug's array detection.
109 * @param {*} obj 109 * @param {*} obj
110 * @return {boolean} 110 * @return {boolean}
111 */ 111 */
112 function isArrayLike(obj) 112 function isArrayLike(obj)
113 { 113 {
114 if (typeof obj !== "object") 114 if (typeof obj !== "object")
115 return false; 115 return false;
116 try { 116 try {
117 if (typeof obj.splice === "function") { 117 if (typeof obj.splice === "function") {
118 if (!InjectedScriptHost.suppressWarningsAndCallFunction(Object.proto type.hasOwnProperty, obj, ["length"])) 118 if (!InjectedScriptHost.objectHasOwnProperty(/** @type {!Object} */ (obj), "length"))
119 return false; 119 return false;
120 var len = obj.length; 120 var len = obj.length;
121 return typeof len === "number" && isUInt32(len); 121 return typeof len === "number" && isUInt32(len);
122 } 122 }
123 } catch (e) { 123 } catch (e) {
124 } 124 }
125 return false; 125 return false;
126 } 126 }
127 127
128 /** 128 /**
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 domAttributesWithObservableSideEffectOnGet["Response"]["body"] = true; 163 domAttributesWithObservableSideEffectOnGet["Response"]["body"] = true;
164 164
165 /** 165 /**
166 * @param {!Object} object 166 * @param {!Object} object
167 * @param {string} attribute 167 * @param {string} attribute
168 * @return {boolean} 168 * @return {boolean}
169 */ 169 */
170 function doesAttributeHaveObservableSideEffectOnGet(object, attribute) 170 function doesAttributeHaveObservableSideEffectOnGet(object, attribute)
171 { 171 {
172 for (var interfaceName in domAttributesWithObservableSideEffectOnGet) { 172 for (var interfaceName in domAttributesWithObservableSideEffectOnGet) {
173 var isInstance = InjectedScriptHost.suppressWarningsAndCallFunction(func tion(object, interfaceName) { 173 var interfaceFunction = inspectedGlobalObject[interfaceName];
174 return /* suppressBlacklist */ typeof inspectedGlobalObject[interfac eName] === "function" && object instanceof inspectedGlobalObject[interfaceName]; 174 var isInstance = typeof interfaceFunction === "function" && object insta nceof interfaceFunction;
175 }, null, [object, interfaceName]); 175 if (isInstance)
176 if (isInstance) {
177 return attribute in domAttributesWithObservableSideEffectOnGet[inter faceName]; 176 return attribute in domAttributesWithObservableSideEffectOnGet[inter faceName];
178 }
179 } 177 }
180 return false; 178 return false;
181 } 179 }
182 180
183 /** 181 /**
184 * @constructor 182 * @constructor
185 */ 183 */
186 var InjectedScript = function() 184 var InjectedScript = function()
187 { 185 {
188 } 186 }
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 if (isSymbol(property)) 388 if (isSymbol(property))
391 name = /** @type {string} */ (injectedScript._describe(prope rty)); 389 name = /** @type {string} */ (injectedScript._describe(prope rty));
392 else 390 else
393 name = typeof property === "number" ? ("" + property) : /** @type {string} */(property); 391 name = typeof property === "number" ? ("" + property) : /** @type {string} */(property);
394 392
395 if (propertyProcessed[property]) 393 if (propertyProcessed[property])
396 continue; 394 continue;
397 395
398 try { 396 try {
399 propertyProcessed[property] = true; 397 propertyProcessed[property] = true;
400 var descriptor = nullifyObjectProto(InjectedScriptHost.suppr essWarningsAndCallFunction(Object.getOwnPropertyDescriptor, Object, [o, property ])); 398 var descriptor = nullifyObjectProto(Object.getOwnPropertyDes criptor(o, property));
401 if (descriptor) { 399 if (descriptor) {
402 if (accessorPropertiesOnly && !("get" in descriptor || " set" in descriptor)) 400 if (accessorPropertiesOnly && !("get" in descriptor || " set" in descriptor))
403 continue; 401 continue;
404 if ("get" in descriptor && "set" in descriptor && name ! = "__proto__" && InjectedScriptHost.formatAccessorsAsProperties(object, descript or.get) && !doesAttributeHaveObservableSideEffectOnGet(object, name)) { 402 if ("get" in descriptor && "set" in descriptor && name ! = "__proto__" && InjectedScriptHost.formatAccessorsAsProperties(object, descript or.get) && !doesAttributeHaveObservableSideEffectOnGet(object, name)) {
405 descriptor.value = InjectedScriptHost.suppressWarnin gsAndCallFunction(function(attribute) { return this[attribute]; }, object, [prop erty]); 403 descriptor.value = object[property];
406 descriptor.isOwn = true; 404 descriptor.isOwn = true;
407 delete descriptor.get; 405 delete descriptor.get;
408 delete descriptor.set; 406 delete descriptor.set;
409 } 407 }
410 } else { 408 } else {
411 // Not all bindings provide proper descriptors. Fall bac k to the writable, configurable property. 409 // Not all bindings provide proper descriptors. Fall bac k to the writable, configurable property.
412 if (accessorPropertiesOnly) 410 if (accessorPropertiesOnly)
413 continue; 411 continue;
414 try { 412 try {
415 descriptor = { name: name, value: o[property], writa ble: false, configurable: false, enumerable: false, __proto__: null }; 413 descriptor = { name: name, value: o[property], writa ble: false, configurable: false, enumerable: false, __proto__: null };
(...skipping 19 matching lines...) Expand all
435 if (isSymbol(property)) 433 if (isSymbol(property))
436 descriptor.symbol = property; 434 descriptor.symbol = property;
437 yield descriptor; 435 yield descriptor;
438 } 436 }
439 } 437 }
440 438
441 if (propertyNamesOnly) { 439 if (propertyNamesOnly) {
442 for (var i = 0; i < propertyNamesOnly.length; ++i) { 440 for (var i = 0; i < propertyNamesOnly.length; ++i) {
443 var name = propertyNamesOnly[i]; 441 var name = propertyNamesOnly[i];
444 for (var o = object; this._isDefined(o); o = InjectedScriptHost. prototype(o)) { 442 for (var o = object; this._isDefined(o); o = InjectedScriptHost. prototype(o)) {
445 if (InjectedScriptHost.suppressWarningsAndCallFunction(Objec t.prototype.hasOwnProperty, o, [name])) { 443 if (InjectedScriptHost.objectHasOwnProperty(o, name)) {
446 for (var descriptor of process(o, [name])) 444 for (var descriptor of process(o, [name]))
447 yield descriptor; 445 yield descriptor;
448 break; 446 break;
449 } 447 }
450 if (ownProperties) 448 if (ownProperties)
451 break; 449 break;
452 } 450 }
453 } 451 }
454 return; 452 return;
455 } 453 }
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 if (typeof obj.length === "number") 615 if (typeof obj.length === "number")
618 className += "[" + obj.length + "]"; 616 className += "[" + obj.length + "]";
619 return className; 617 return className;
620 } 618 }
621 619
622 if (typeof obj === "function") 620 if (typeof obj === "function")
623 return toString(obj); 621 return toString(obj);
624 622
625 if (isSymbol(obj)) { 623 if (isSymbol(obj)) {
626 try { 624 try {
627 return /** @type {string} */ (InjectedScriptHost.suppressWarning sAndCallFunction(Symbol.prototype.toString, obj)) || "Symbol"; 625 return obj.toString() || "Symbol";
628 } catch (e) { 626 } catch (e) {
629 return "Symbol"; 627 return "Symbol";
630 } 628 }
631 } 629 }
632 630
633 if (InjectedScriptHost.subtype(obj) === "error") { 631 if (InjectedScriptHost.subtype(obj) === "error") {
634 try { 632 try {
635 var stack = obj.stack; 633 var stack = obj.stack;
636 var message = obj.message && obj.message.length ? ": " + obj.mes sage : ""; 634 var message = obj.message && obj.message.length ? ": " + obj.mes sage : "";
637 var firstCallFrame = /^\s+at\s/m.exec(stack); 635 var firstCallFrame = /^\s+at\s/m.exec(stack);
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 } 782 }
785 783
786 /** 784 /**
787 * @suppressReceiverCheck 785 * @suppressReceiverCheck
788 * @param {*} object 786 * @param {*} object
789 * @param {*=} customObjectConfig 787 * @param {*=} customObjectConfig
790 * @return {*} 788 * @return {*}
791 */ 789 */
792 function wrap(object, customObjectConfig) 790 function wrap(object, customObjectConfig)
793 { 791 {
794 return InjectedScriptHost.suppressWarningsAndCallFunction(injectedSc ript._wrapObject, injectedScript, [ object, objectGroupName, false, false, null, false, false, customObjectConfig ]); 792 return injectedScript._wrapObject(object, objectGroupName, false, fa lse, null, false, false, customObjectConfig);
795 } 793 }
796 794
797 try { 795 try {
798 var formatters = inspectedGlobalObject["devtoolsFormatters"]; 796 var formatters = inspectedGlobalObject["devtoolsFormatters"];
799 if (!formatters || !isArrayLike(formatters)) 797 if (!formatters || !isArrayLike(formatters))
800 return null; 798 return null;
801 799
802 for (var i = 0; i < formatters.length; ++i) { 800 for (var i = 0; i < formatters.length; ++i) {
803 try { 801 try {
804 var formatted = formatters[i].header(object, customObjectCon fig); 802 var formatted = formatters[i].header(object, customObjectCon fig);
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
1052 return string.substr(0, leftHalf) + "\u2026" + string.substr(string. length - rightHalf, rightHalf); 1050 return string.substr(0, leftHalf) + "\u2026" + string.substr(string. length - rightHalf, rightHalf);
1053 } 1051 }
1054 return string.substr(0, maxLength) + "\u2026"; 1052 return string.substr(0, maxLength) + "\u2026";
1055 }, 1053 },
1056 1054
1057 __proto__: null 1055 __proto__: null
1058 } 1056 }
1059 1057
1060 return injectedScript; 1058 return injectedScript;
1061 }) 1059 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698