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

Unified Diff: third_party/WebKit/Source/devtools/front_end/sdk/RuntimeModel.js

Issue 2878053003: DevTools: Find executionContextId for console message from scriptId (Closed)
Patch Set: move into runtime Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/console_model/ConsoleModel.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/sdk/RuntimeModel.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/RuntimeModel.js b/third_party/WebKit/Source/devtools/front_end/sdk/RuntimeModel.js
index b0e1dbc5bf881f93960942b6dcf5350fe2262a76..795f6d63b10cf2f4761b0c0e0467e22e7ac56a72 100644
--- a/third_party/WebKit/Source/devtools/front_end/sdk/RuntimeModel.js
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/RuntimeModel.js
@@ -411,6 +411,27 @@ SDK.RuntimeModel = class extends SDK.SDKModel {
{type: type, args: args, executionContextId: executionContextId, timestamp: timestamp, stackTrace: stackTrace};
this.dispatchEventToListeners(SDK.RuntimeModel.Events.ConsoleAPICalled, consoleAPICall);
}
+
+ /**
+ * @param {!Protocol.Runtime.ScriptId} scriptId
+ * @return {number}
+ */
+ executionContextIdForScriptId(scriptId) {
+ var script = this.debuggerModel().scriptForId(scriptId);
+ return script ? script.executionContextId : 0;
+ }
+
+ /**
+ * @param {!Protocol.Runtime.StackTrace} stackTrace
+ * @return {number}
+ */
+ executionContextForStackTrace(stackTrace) {
+ while (stackTrace && !stackTrace.callFrames.length)
+ stackTrace = stackTrace.parent;
+ if (!stackTrace || !stackTrace.callFrames.length)
+ return 0;
+ return this.executionContextIdForScriptId(stackTrace.callFrames[0].scriptId);
+ }
};
SDK.SDKModel.register(SDK.RuntimeModel, SDK.Target.Capability.JS, true);
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/console_model/ConsoleModel.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698