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

Side by Side Diff: Source/core/inspector/InjectedScriptSource.js

Issue 978233002: bindings,devtools: Shows DOM attributes' values in DevTools. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Addressed review comments. Created 5 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/inspector/InjectedScriptHost.idl ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 213
214 while (k < len) { 214 while (k < len) {
215 if (str[k] === searchElement) 215 if (str[k] === searchElement)
216 return k; 216 return k;
217 ++k; 217 ++k;
218 } 218 }
219 return -1; 219 return -1;
220 } 220 }
221 221
222 /** 222 /**
223 * DOM Attributes which have observable side effect on getter, in the form of
224 * {interfaceName1: {attributeName1: true,
225 * attributeName2: true,
226 * ...},
227 * interfaceName2: {...},
228 * ...}
229 * @type {!Object<string, !Object<string, boolean>>}
230 * @const
231 */
232 var domAttributesWithObservableSideEffectOnGet = nullifyObjectProto({});
233 domAttributesWithObservableSideEffectOnGet["Request"] = nullifyObjectProto({});
234 domAttributesWithObservableSideEffectOnGet["Request"]["body"] = true;
235 domAttributesWithObservableSideEffectOnGet["Response"] = nullifyObjectProto({});
236 domAttributesWithObservableSideEffectOnGet["Response"]["body"] = true;
237
238 /**
239 * @param {!Object} object
240 * @param {!string} attribute
241 * @return {boolean}
242 */
243 function doesAttributeHaveObservableSideEffectOnGet(object, attribute)
244 {
245 for (var interfaceName in domAttributesWithObservableSideEffectOnGet) {
246 var isInstance = InjectedScriptHost.suppressWarningsAndCallFunction(func tion(object, interfaceName) {
247 return typeof window[interfaceName] === "function" && object instanc eof window[interfaceName];
248 }, null, [object, interfaceName]);
249 if (isInstance) {
250 return attribute in domAttributesWithObservableSideEffectOnGet[inter faceName];
251 }
252 }
253 return false;
254 }
255
256 /**
223 * @constructor 257 * @constructor
224 */ 258 */
225 var InjectedScript = function() 259 var InjectedScript = function()
226 { 260 {
227 /** @type {!Object.<string, !Object>} */ 261 /** @type {!Object.<string, !Object>} */
228 this._modules = { __proto__: null }; 262 this._modules = { __proto__: null };
229 } 263 }
230 264
231 /** 265 /**
232 * @type {!Object.<string, boolean>} 266 * @type {!Object.<string, boolean>}
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 var name = property; 582 var name = property;
549 if (isSymbol(property)) 583 if (isSymbol(property))
550 name = injectedScript._describe(property); 584 name = injectedScript._describe(property);
551 585
552 try { 586 try {
553 propertyProcessed[property] = true; 587 propertyProcessed[property] = true;
554 var descriptor = nullifyObjectProto(InjectedScriptHost.suppr essWarningsAndCallFunction(Object.getOwnPropertyDescriptor, Object, [o, property ])); 588 var descriptor = nullifyObjectProto(InjectedScriptHost.suppr essWarningsAndCallFunction(Object.getOwnPropertyDescriptor, Object, [o, property ]));
555 if (descriptor) { 589 if (descriptor) {
556 if (accessorPropertiesOnly && !("get" in descriptor || " set" in descriptor)) 590 if (accessorPropertiesOnly && !("get" in descriptor || " set" in descriptor))
557 continue; 591 continue;
558 if ("get" in descriptor && "set" in descriptor && Inject edScriptHost.isPopularDOMObject(object) && name != "__proto__") { 592 if ("get" in descriptor && "set" in descriptor && name ! = "__proto__" && InjectedScriptHost.isDOMWrapper(object) && !doesAttributeHaveOb servableSideEffectOnGet(object, name)) {
559 descriptor.value = InjectedScriptHost.suppressWarnin gsAndCallFunction(function(attribute) { return this[attribute]; }, object, [name ]); 593 descriptor.value = InjectedScriptHost.suppressWarnin gsAndCallFunction(function(attribute) { return this[attribute]; }, object, [name ]);
560 delete descriptor.get; 594 delete descriptor.get;
561 delete descriptor.set; 595 delete descriptor.set;
562 } 596 }
563 } else { 597 } else {
564 // Not all bindings provide proper descriptors. Fall bac k to the writable, configurable property. 598 // Not all bindings provide proper descriptors. Fall bac k to the writable, configurable property.
565 if (accessorPropertiesOnly) 599 if (accessorPropertiesOnly)
566 continue; 600 continue;
567 try { 601 try {
568 descriptor = { name: name, value: o[property], writa ble: false, configurable: false, enumerable: false, __proto__: null }; 602 descriptor = { name: name, value: o[property], writa ble: false, configurable: false, enumerable: false, __proto__: null };
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after
1509 if (middle) { 1543 if (middle) {
1510 var leftHalf = maxLength >> 1; 1544 var leftHalf = maxLength >> 1;
1511 var rightHalf = maxLength - leftHalf - 1; 1545 var rightHalf = maxLength - leftHalf - 1;
1512 return string.substr(0, leftHalf) + "\u2026" + string.substr(string. length - rightHalf, rightHalf); 1546 return string.substr(0, leftHalf) + "\u2026" + string.substr(string. length - rightHalf, rightHalf);
1513 } 1547 }
1514 return string.substr(0, maxLength) + "\u2026"; 1548 return string.substr(0, maxLength) + "\u2026";
1515 }, 1549 },
1516 1550
1517 __proto__: null 1551 __proto__: null
1518 } 1552 }
1553
1519 /** 1554 /**
1520 * @constructor 1555 * @constructor
1521 * @param {number} ordinal 1556 * @param {number} ordinal
1522 * @param {!JavaScriptCallFrame} callFrame 1557 * @param {!JavaScriptCallFrame} callFrame
1523 * @param {number} asyncOrdinal 1558 * @param {number} asyncOrdinal
1524 */ 1559 */
1525 InjectedScript.CallFrameProxy = function(ordinal, callFrame, asyncOrdinal) 1560 InjectedScript.CallFrameProxy = function(ordinal, callFrame, asyncOrdinal)
1526 { 1561 {
1527 this.callFrameId = "{\"ordinal\":" + ordinal + ",\"injectedScriptId\":" + in jectedScriptId + (asyncOrdinal ? ",\"asyncOrdinal\":" + asyncOrdinal : "") + "}" ; 1562 this.callFrameId = "{\"ordinal\":" + ordinal + ",\"injectedScriptId\":" + in jectedScriptId + (asyncOrdinal ? ",\"asyncOrdinal\":" + asyncOrdinal : "") + "}" ;
1528 this.functionName = (callFrame.type === "function" ? callFrame.functionName : ""); 1563 this.functionName = (callFrame.type === "function" ? callFrame.functionName : "");
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
1929 */ 1964 */
1930 _logEvent: function(event) 1965 _logEvent: function(event)
1931 { 1966 {
1932 inspectedWindow.console.log(event.type, event); 1967 inspectedWindow.console.log(event.type, event);
1933 } 1968 }
1934 } 1969 }
1935 1970
1936 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); 1971 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl();
1937 return injectedScript; 1972 return injectedScript;
1938 }) 1973 })
OLDNEW
« no previous file with comments | « Source/core/inspector/InjectedScriptHost.idl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698