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

Unified Diff: Source/devtools/front_end/elements/EventListenersWidget.js

Issue 1268353005: [DevTools] Support JQuery event listeners (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased Created 5 years, 4 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
Index: Source/devtools/front_end/elements/EventListenersWidget.js
diff --git a/Source/devtools/front_end/elements/EventListenersWidget.js b/Source/devtools/front_end/elements/EventListenersWidget.js
index d704e0e2f9ab7323ae4f4cfda5d8dc0c70f20eee..277426f5f7d2ae57b06eb9ef767944f66d148a1d 100644
--- a/Source/devtools/front_end/elements/EventListenersWidget.js
+++ b/Source/devtools/front_end/elements/EventListenersWidget.js
@@ -38,8 +38,14 @@ WebInspector.EventListenersWidget = function()
this._showForAncestorsSetting = WebInspector.settings.createSetting("showEventListenersForAncestors", true);
this._showForAncestorsSetting.addChangeListener(this.update.bind(this));
+
+ this._showFrameworkListenersSetting = WebInspector.settings.createSetting("_showFrameworkListeners", true);
+ this._showFrameworkListenersSetting.addChangeListener(this._showFrameworkUserListenersChanged.bind(this));
+
this._eventListenersView = new WebInspector.EventListenersView(this.element);
WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode, this.update, this);
+
+ this._frameworkSupportInitializedSymbol = Symbol("frameworkSupportInitialized");
}
/**
@@ -53,6 +59,7 @@ WebInspector.EventListenersWidget.createSidebarWrapper = function()
refreshButton.addEventListener("click", widget.update.bind(widget));
result.toolbar().appendToolbarItem(refreshButton);
result.toolbar().appendToolbarItem(new WebInspector.ToolbarCheckbox(WebInspector.UIString("Ancestors"), WebInspector.UIString("Show listeners on the ancestors"), widget._showForAncestorsSetting));
+ result.toolbar().appendToolbarItem(new WebInspector.ToolbarCheckbox(WebInspector.UIString("Framework user's listeners"), WebInspector.UIString("Show framework user event listeners"), widget._showFrameworkListenersSetting));
paulirish 2015/08/14 21:03:15 Checkbox: Framework listeners Tooltip: Resolve eve
return result;
}
@@ -79,6 +86,7 @@ WebInspector.EventListenersWidget.prototype = {
}
this._lastRequestedNode = node;
var selectedNodeOnly = !this._showForAncestorsSetting.get();
+ var context = this._nodeExecutionContext(node);
var promises = [];
var listenersView = this._eventListenersView;
promises.push(node.resolveToObjectPromise(WebInspector.EventListenersWidget._objectGroupName));
@@ -88,16 +96,58 @@ WebInspector.EventListenersWidget.prototype = {
promises.push(currentNode.resolveToObjectPromise(WebInspector.EventListenersWidget._objectGroupName));
currentNode = currentNode.parentNode;
}
- promises.push(this._windowObjectInNodeContext(node));
+ promises.push(this._windowObjectInContext(context));
+ }
+ WebInspector.EventListenersFrameworkSupport.initializeOnContext(context).then(addEventListeners.bind(this));
+
+ /**
+ * @this {!WebInspector.EventListenersWidget}
+ */
+ function addEventListeners()
+ {
+ Promise.all(promises).then(this._eventListenersView.addObjects.bind(this._eventListenersView)).then(showResolvedHandlers.bind(this));
+ }
+
+ /**
+ * @this {!WebInspector.EventListenersWidget}
+ */
+ function showResolvedHandlers()
+ {
+ this._showFrameworkUserListenersChanged();
+ finishCallback();
}
- Promise.all(promises).then(this._eventListenersView.addObjects.bind(this._eventListenersView)).then(finishCallback.bind(this, undefined));
+ },
+
+ _showFrameworkUserListenersChanged: function()
+ {
+ this._eventListenersView.showFrameworkUserEventListeners(this._showFrameworkListenersSetting.get());
},
/**
* @param {!WebInspector.DOMNode} node
+ * @return {?WebInspector.ExecutionContext}
+ */
+ _nodeExecutionContext: function(node)
+ {
+ var executionContexts = node.target().runtimeModel.executionContexts();
+ var context = null;
+ if (node.frameId()) {
+ for (var i = 0; i < executionContexts.length; ++i) {
+ var executionContext = executionContexts[i];
+ if (executionContext.frameId === node.frameId() && executionContext.isMainWorldContext)
+ context = executionContext;
+ }
+ } else {
+ context = executionContexts[0];
+ }
+ return context;
+ },
+
+ /**
+ * @param {?WebInspector.ExecutionContext} context
* @return {!Promise<!WebInspector.RemoteObject>}
*/
- _windowObjectInNodeContext: function(node)
+ _windowObjectInContext: function(context)
{
return new Promise(windowObjectInNodeContext);
@@ -107,24 +157,12 @@ WebInspector.EventListenersWidget.prototype = {
*/
function windowObjectInNodeContext(fulfill, reject)
{
- var executionContexts = node.target().runtimeModel.executionContexts();
- var context = null;
- if (node.frameId()) {
- for (var i = 0; i < executionContexts.length; ++i) {
- var executionContext = executionContexts[i];
- if (executionContext.frameId === node.frameId() && executionContext.isMainWorldContext)
- context = executionContext;
- }
- } else {
- context = executionContexts[0];
- }
- context.evaluate("self", WebInspector.EventListenersWidget._objectGroupName, false, true, false, false, fulfill);
+ if (context)
+ context.evaluate("self", WebInspector.EventListenersWidget._objectGroupName, false, true, false, false, fulfill);
+ else
+ reject("Empty context");
}
},
- _eventListenersArrivedForTest: function()
- {
- },
-
__proto__: WebInspector.ThrottledWidget.prototype
}

Powered by Google App Engine
This is Rietveld 408576698