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..440309759940e4763fb88302fd412475271b83ae 100644 |
--- a/Source/devtools/front_end/elements/EventListenersWidget.js |
+++ b/Source/devtools/front_end/elements/EventListenersWidget.js |
@@ -38,6 +38,10 @@ WebInspector.EventListenersWidget = function() |
this._showForAncestorsSetting = WebInspector.settings.createSetting("showEventListenersForAncestors", true); |
this._showForAncestorsSetting.addChangeListener(this.update.bind(this)); |
+ |
+ this._resolveFrameworkHandlersSetting = WebInspector.settings.createSetting("resolveFrameworkHandlers", true); |
+ this._resolveFrameworkHandlersSetting.addChangeListener(this._resolveFrameworkHandlersChanged.bind(this)); |
+ |
this._eventListenersView = new WebInspector.EventListenersView(this.element); |
WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode, this.update, this); |
} |
@@ -53,6 +57,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("Resolve frameworks' handlers"), WebInspector.UIString("Resolve framework's event handlers"), widget._resolveFrameworkHandlersSetting)); |
return result; |
} |
@@ -90,7 +95,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._setupFrameworksSupport(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._resolveFrameworkHandlersChanged(); |
+ finishCallback(); |
+ } |
+ }, |
+ |
+ _resolveFrameworkHandlersChanged: function() |
+ { |
+ this._eventListenersView.showResolvedHandlers(this._resolveFrameworkHandlersSetting.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 +146,45 @@ 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>} |
+ */ |
+ _setupFrameworksSupport: 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) |
+ context.evaluate(setupFunction, WebInspector.EventListenersWidget._objectGroupName, false, false, true, false, fulfill); |
+ else |
+ reject("Empty context"); |
+ } |
}, |
__proto__: WebInspector.ThrottledWidget.prototype |