| 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..038af65901414eedba88d3d22e9382eb3d7164b0 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));
|
| 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._initializeFrameworkSupport(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>}
|
| + */
|
| + _initializeFrameworkSupport: function(node)
|
| {
|
| + return new Promise(initializeFrameworksSupport.bind(this));
|
| +
|
| + /**
|
| + * @param {function(?)} fulfill
|
| + * @param {function(*)} reject
|
| + * @this {!WebInspector.EventListenersWidget}
|
| + */
|
| + function initializeFrameworksSupport(fulfill, reject)
|
| + {
|
| + var context = this._nodeExecutionContext(node);
|
| + var initializeFunction = WebInspector.FrameworksSupport.eventListenersInitializeFunction();
|
| + if (!context) {
|
| + reject("Empty context");
|
| + return;
|
| + }
|
| + if (this._frameworkSupportInitializedSymbol in context) {
|
| + fulfill(undefined);
|
| + return;
|
| + }
|
| + context[this._frameworkSupportInitializedSymbol] = true;
|
| + context.evaluate(initializeFunction, WebInspector.EventListenersWidget._objectGroupName, false, false, true, false, fulfill);
|
| + }
|
| },
|
|
|
| __proto__: WebInspector.ThrottledWidget.prototype
|
|
|