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

Unified Diff: third_party/WebKit/Source/devtools/front_end/sources/SourceMapNamesResolver.js

Issue 1884213003: DevTools: teach SourceMapNamesResolver to resolve "this" object (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ids
Patch Set: fix tesst Created 4 years, 8 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 | « third_party/WebKit/Source/devtools/front_end/sources/ScopeChainSidebarPane.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/devtools/front_end/sources/SourceMapNamesResolver.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sources/SourceMapNamesResolver.js b/third_party/WebKit/Source/devtools/front_end/sources/SourceMapNamesResolver.js
index 3eca7c8aecee812240d91218459c44a42f44cd1f..a3a1c9aa8e953717c419d751340ddade6f38d2d3 100644
--- a/third_party/WebKit/Source/devtools/front_end/sources/SourceMapNamesResolver.js
+++ b/third_party/WebKit/Source/devtools/front_end/sources/SourceMapNamesResolver.js
@@ -288,6 +288,48 @@ WebInspector.SourceMapNamesResolver._resolveExpression = function(callFrame, uiS
}
/**
+ * @param {?WebInspector.DebuggerModel.CallFrame} callFrame
+ * @return {!Promise<?WebInspector.RemoteObject>}
+ */
+WebInspector.SourceMapNamesResolver.resolveThisObject = function(callFrame)
+{
+ if (!callFrame)
+ return Promise.resolve(/** @type {?WebInspector.RemoteObject} */(null));
+ if (!Runtime.experiments.isEnabled("resolveVariableNames"))
+ return Promise.resolve(callFrame.thisObject());
+
+ return WebInspector.SourceMapNamesResolver._resolveScope(callFrame.scopeChain()[0])
+ .then(onScopeResolved);
+
+ /**
+ * @param {!Map<string, string>} namesMapping
+ * @return {!Promise<?WebInspector.RemoteObject>}
+ */
+ function onScopeResolved(namesMapping)
+ {
+ var thisMappings = namesMapping.inverse().get("this");
+ if (!thisMappings || thisMappings.size !== 1)
+ return Promise.resolve(callFrame.thisObject());
+
+ var thisMapping = thisMappings.valuesArray()[0];
+ var callback;
+ var promise = new Promise(fulfill => callback = fulfill);
+ callFrame.evaluate(thisMapping, "backtrace", false, true, false, true, onEvaluated.bind(null, callback));
+ return promise;
+ }
+
+ /**
+ * @param {function(!WebInspector.RemoteObject)} callback
+ * @param {?RuntimeAgent.RemoteObject} evaluateResult
+ */
+ function onEvaluated(callback, evaluateResult)
+ {
+ var remoteObject = evaluateResult ? callFrame.target().runtimeModel.createRemoteObject(evaluateResult) : callFrame.thisObject();
+ callback(remoteObject);
+ }
+}
+
+/**
* @param {!WebInspector.DebuggerModel.Scope} scope
* @return {!WebInspector.RemoteObject}
*/
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/sources/ScopeChainSidebarPane.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698