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

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: 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..36e9364452a76f9b2a344ae269eee8322274588e 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._isFrameworkSupportSetup = Symbol("isFrameworkEventListenerSupportSetup");
yurys 2015/08/14 17:24:21 _frameworkSupportInitializedSymbol
kozy 2015/08/14 18:15:45 Done.
}
/**
@@ -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("Show framework user's listeners"), WebInspector.UIString("Show framework user event listeners"), widget._showFrameworkListenersSetting));
yurys 2015/08/14 17:24:21 Framework user listeners
kozy 2015/08/14 18:15:45 Done.
return result;
}
@@ -90,7 +97,49 @@ WebInspector.EventListenersWidget.prototype = {
}
promises.push(this._windowObjectInNodeContext(node));
}
- Promise.all(promises).then(this._eventListenersView.addObjects.bind(this._eventListenersView)).then(finishCallback.bind(this, undefined));
+ this._setupFrameworkSupport(node).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();
+ }
+ },
+
+ _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;
},
/**
@@ -99,31 +148,51 @@ WebInspector.EventListenersWidget.prototype = {
*/
_windowObjectInNodeContext: function(node)
{
- return new Promise(windowObjectInNodeContext);
+ return new Promise(windowObjectInNodeContext.bind(this));
/**
* @param {function(?)} fulfill
* @param {function(*)} reject
+ * @this {!WebInspector.EventListenersWidget}
*/
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);
+ var context = this._nodeExecutionContext(node);
+ if (context)
+ context.evaluate("self", WebInspector.EventListenersWidget._objectGroupName, false, true, false, false, fulfill);
+ else
+ reject("Empty context");
}
},
- _eventListenersArrivedForTest: function()
+ /**
+ * @param {!WebInspector.DOMNode} node
+ * @return {!Promise<void>}
+ */
+ _setupFrameworkSupport: function(node)
{
+ return new Promise(setupFrameworksSupport.bind(this));
+
+ /**
+ * @param {function(?)} fulfill
+ * @param {function(*)} reject
+ * @this {!WebInspector.EventListenersWidget}
+ */
+ function setupFrameworksSupport(fulfill, reject)
+ {
+ var context = this._nodeExecutionContext(node);
+ var setupFunction = WebInspector.FrameworksSupport.eventListenersSetupFunction();
+ if (!context) {
+ reject("Empty context");
+ return;
+ }
+ if (this._isFrameworkSupportSetup in context) {
+ fulfill(undefined);
yurys 2015/08/14 17:24:21 fulfil()
kozy 2015/08/14 18:15:46 Acknowledged.
+ return;
+ }
+ context[this._isFrameworkSupportSetup] = true;
+ context.evaluate(setupFunction, WebInspector.EventListenersWidget._objectGroupName, false, false, true, false, fulfill);
+ }
},
__proto__: WebInspector.ThrottledWidget.prototype

Powered by Google App Engine
This is Rietveld 408576698