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

Unified Diff: third_party/WebKit/Source/devtools/front_end/components/ExecutionContextModel.js

Issue 1668603003: Devtools: Switch JS execution context to match inspected node (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 | « no previous file | 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/components/ExecutionContextModel.js
diff --git a/third_party/WebKit/Source/devtools/front_end/components/ExecutionContextModel.js b/third_party/WebKit/Source/devtools/front_end/components/ExecutionContextModel.js
index 95a55893fff06e4d96957ca16999fc01025d86f6..02583fd9f51bc7d5b51aa3d6978cd74b62de214f 100644
--- a/third_party/WebKit/Source/devtools/front_end/components/ExecutionContextModel.js
+++ b/third_party/WebKit/Source/devtools/front_end/components/ExecutionContextModel.js
@@ -152,6 +152,9 @@ WebInspector.ExecutionContextModel.prototype = {
targetAdded: function(target)
{
target.runtimeModel.executionContexts().forEach(this._executionContextCreated, this);
+ var domModel = WebInspector.DOMModel.fromTarget(target);
+ if (domModel)
+ domModel.addEventListener(WebInspector.DOMModel.Events.NodeInspected, this._nodeInspected, this);
pfeldman 2016/02/04 00:18:53 This code should move to the UI level in order to
samli 2016/02/05 19:43:16 Done
},
/**
@@ -165,6 +168,35 @@ WebInspector.ExecutionContextModel.prototype = {
if (executionContexts[i].target() === target)
this._executionContextDestroyed(executionContexts[i]);
}
+ var domModel = WebInspector.DOMModel.fromTarget(target);
+ if (domModel)
+ domModel.removeEventListener(WebInspector.DOMModel.Events.NodeInspected, this._nodeInspected, this);
+ },
+
+ /**
+ * @param {!WebInspector.Event} event
+ */
+ _nodeInspected: function(event)
+ {
+ /**
+ * @param {?WebInspector.DOMNode} domNode
+ * @this {!WebInspector.ExecutionContextModel}
+ */
+ function updateExecutionContext(domNode)
+ {
+ if (!domNode)
+ return;
+ var executionContexts = this._optionByExecutionContext.keysArray();
+ for (var context of executionContexts) {
+ if (context.frameId == domNode.frameId() || (!domNode.frameId() && context.isMainWorldContext)) {
+ WebInspector.context.setFlavor(WebInspector.ExecutionContext, context);
+ return;
+ }
+ }
+ }
+
+ var deferredNode = /** @type {!WebInspector.DeferredDOMNode} */(event.data);
+ deferredNode.resolvePromise().then(updateExecutionContext.bind(this));
},
/**
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698