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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/inspector/InjectedScriptHost.idl ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/inspector/InjectedScriptSource.js
diff --git a/Source/core/inspector/InjectedScriptSource.js b/Source/core/inspector/InjectedScriptSource.js
index 234c0a831a3eb73c6ac57de6a3ba89256daebddb..c525812381befdfbe1d9c2410abee8fef6b81342 100644
--- a/Source/core/inspector/InjectedScriptSource.js
+++ b/Source/core/inspector/InjectedScriptSource.js
@@ -220,6 +220,40 @@ function indexOf(str, searchElement, fromIndex)
}
/**
+ * DOM Attributes which have observable side effect on getter, in the form of
+ * {interfaceName1: {attributeName1: true,
+ * attributeName2: true,
+ * ...},
+ * interfaceName2: {...},
+ * ...}
+ * @type {!Object<string, !Object<string, boolean>>}
+ * @const
+ */
+var domAttributesWithObservableSideEffectOnGet = nullifyObjectProto({});
+domAttributesWithObservableSideEffectOnGet["Request"] = nullifyObjectProto({});
+domAttributesWithObservableSideEffectOnGet["Request"]["body"] = true;
+domAttributesWithObservableSideEffectOnGet["Response"] = nullifyObjectProto({});
+domAttributesWithObservableSideEffectOnGet["Response"]["body"] = true;
+
+/**
+ * @param {!Object} object
+ * @param {!string} attribute
+ * @return {boolean}
+ */
+function doesAttributeHaveObservableSideEffectOnGet(object, attribute)
+{
+ for (var interfaceName in domAttributesWithObservableSideEffectOnGet) {
+ var isInstance = InjectedScriptHost.suppressWarningsAndCallFunction(function(object, interfaceName) {
+ return typeof window[interfaceName] === "function" && object instanceof window[interfaceName];
+ }, null, [object, interfaceName]);
+ if (isInstance) {
+ return attribute in domAttributesWithObservableSideEffectOnGet[interfaceName];
+ }
+ }
+ return false;
+}
+
+/**
* @constructor
*/
var InjectedScript = function()
@@ -555,7 +589,7 @@ InjectedScript.prototype = {
if (descriptor) {
if (accessorPropertiesOnly && !("get" in descriptor || "set" in descriptor))
continue;
- if ("get" in descriptor && "set" in descriptor && InjectedScriptHost.isPopularDOMObject(object) && name != "__proto__") {
+ if ("get" in descriptor && "set" in descriptor && name != "__proto__" && InjectedScriptHost.isDOMWrapper(object) && !doesAttributeHaveObservableSideEffectOnGet(object, name)) {
descriptor.value = InjectedScriptHost.suppressWarningsAndCallFunction(function(attribute) { return this[attribute]; }, object, [name]);
delete descriptor.get;
delete descriptor.set;
@@ -1516,6 +1550,7 @@ InjectedScript.RemoteObject.prototype = {
__proto__: null
}
+
/**
* @constructor
* @param {number} ordinal
« 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