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

Side by Side Diff: Source/devtools/front_end/elements/EventListenersSidebarPane.js

Issue 1154703005: [DevTools] Added window listeners to EventListenersSidebar (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@extract-event-listeners-tree-outline
Patch Set: Test fixed Created 5 years, 6 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2009 Joseph Pecoraro 3 * Copyright (C) 2009 Joseph Pecoraro
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 this._eventListenersFilterSetting = WebInspector.settings.createSetting("eve ntListenersFilter", "all"); 53 this._eventListenersFilterSetting = WebInspector.settings.createSetting("eve ntListenersFilter", "all");
54 var filter = this._eventListenersFilterSetting.get(); 54 var filter = this._eventListenersFilterSetting.get();
55 if (filter === "all") 55 if (filter === "all")
56 this.settingsSelectElement[0].selected = true; 56 this.settingsSelectElement[0].selected = true;
57 else if (filter === "selected") 57 else if (filter === "selected")
58 this.settingsSelectElement[1].selected = true; 58 this.settingsSelectElement[1].selected = true;
59 this.settingsSelectElement.addEventListener("click", consumeEvent, false); 59 this.settingsSelectElement.addEventListener("click", consumeEvent, false);
60 this.settingsSelectElement.addEventListener("change", this._changeSetting.bi nd(this), false); 60 this.settingsSelectElement.addEventListener("change", this._changeSetting.bi nd(this), false);
61 61
62 this._eventListenersView = new WebInspector.EventListenersView(this.bodyElem ent, WebInspector.EventListenersSidebarPane._objectGroupName); 62 this._eventListenersView = new WebInspector.EventListenersView(this.bodyElem ent);
63 } 63 }
64 64
65 WebInspector.EventListenersSidebarPane._objectGroupName = "event-listeners-panel "; 65 WebInspector.EventListenersSidebarPane._objectGroupName = "event-listeners-panel ";
66 66
67 WebInspector.EventListenersSidebarPane.prototype = { 67 WebInspector.EventListenersSidebarPane.prototype = {
68 /** 68 /**
69 * @override 69 * @override
70 * @param {!WebInspector.Throttler.FinishCallback} finishCallback 70 * @param {!WebInspector.Throttler.FinishCallback} finishCallback
71 * @protected 71 * @protected
72 */ 72 */
73 doUpdate: function(finishCallback) 73 doUpdate: function(finishCallback)
74 { 74 {
75 if (this._lastRequestedNode) { 75 if (this._lastRequestedNode) {
76 this._lastRequestedNode.target().runtimeAgent().releaseObjectGroup(W ebInspector.EventListenersSidebarPane._objectGroupName); 76 this._lastRequestedNode.target().runtimeAgent().releaseObjectGroup(W ebInspector.EventListenersSidebarPane._objectGroupName);
77 delete this._lastRequestedNode; 77 delete this._lastRequestedNode;
78 } 78 }
79 this._eventListenersView.reset(); 79 this._eventListenersView.reset();
80 var node = this.node(); 80 var node = this.node();
81 if (!node) { 81 if (!node) {
82 this._eventListenersArivedForTest(); 82 this._eventListenersArivedForTest();
83 finishCallback(); 83 finishCallback();
84 return; 84 return;
85 } 85 }
86 86
87 this._lastRequestedNode = node;
87 var selectedNodeOnly = "selected" === this._eventListenersFilterSetting. get(); 88 var selectedNodeOnly = "selected" === this._eventListenersFilterSetting. get();
88 var promises = []; 89 var promises = [];
89 promises.push(this._eventListenersView.addNodeEventListeners(node)); 90 var listenersView = this._eventListenersView;
91 promises.push(node.resolveToObjectPromise(WebInspector.EventListenersSid ebarPane._objectGroupName).then(listenersView.addObjectEventListeners.bind(liste nersView)));
90 if (!selectedNodeOnly) { 92 if (!selectedNodeOnly) {
91 var currentNode = node.parentNode; 93 var currentNode = node.parentNode;
92 while (currentNode) { 94 while (currentNode) {
93 promises.push(this._eventListenersView.addNodeEventListeners(cur rentNode)); 95 promises.push(currentNode.resolveToObjectPromise(WebInspector.Ev entListenersSidebarPane._objectGroupName).then(listenersView.addObjectEventListe ners.bind(listenersView)));
94 currentNode = currentNode.parentNode; 96 currentNode = currentNode.parentNode;
95 } 97 }
98 this._windowObjectInNodeContext(node).then(windowObjectCallback.bind (this));
99 } else {
100 Promise.all(promises).then(mycallback.bind(this));
96 } 101 }
97 Promise.all(promises).then(mycallback.bind(this)); 102 /**
103 * @param {!WebInspector.RemoteObject} object
104 * @this {WebInspector.EventListenersSidebarPane}
105 */
106 function windowObjectCallback(object)
107 {
108 promises.push(this._eventListenersView.addObjectEventListeners(objec t));
109 Promise.all(promises).then(mycallback.bind(this));
110 }
98 /** 111 /**
99 * @this {WebInspector.EventListenersSidebarPane} 112 * @this {WebInspector.EventListenersSidebarPane}
100 */ 113 */
101 function mycallback() 114 function mycallback()
102 { 115 {
103 this._lastRequestedNode = node;
104 this._eventListenersArivedForTest(); 116 this._eventListenersArivedForTest();
105 finishCallback(); 117 finishCallback();
106 } 118 }
107 }, 119 },
108 120
121 /**
122 * @param {!WebInspector.DOMNode} node
123 * @return {!Promise<!WebInspector.RemoteObject>} object
124 */
125 _windowObjectInNodeContext: function(node)
126 {
127 return new Promise(windowObjectInNodeContext);
128
129 /**
130 * @param {function(?)} fulfill
131 * @param {function(*)} reject
132 */
133 function windowObjectInNodeContext(fulfill, reject)
134 {
135 var executionContexts = node.target().runtimeModel.executionContexts ();
136 var context = null;
137 if (node.frameId()) {
138 for (var i = 0; i < executionContexts.length; ++i) {
139 var executionContext = executionContexts[i];
140 if (executionContext.frameId === node.frameId() && execution Context.isMainWorldContext)
141 context = executionContext;
142 }
143 } else {
144 context = executionContexts[0];
145 }
146 context.evaluate("self", WebInspector.EventListenersSidebarPane._obj ectGroupName, false, true, false, false, fulfill);
147 }
148 },
149
109 _changeSetting: function() 150 _changeSetting: function()
110 { 151 {
111 var selectedOption = this.settingsSelectElement[this.settingsSelectEleme nt.selectedIndex]; 152 var selectedOption = this.settingsSelectElement[this.settingsSelectEleme nt.selectedIndex];
112 this._eventListenersFilterSetting.set(selectedOption.value); 153 this._eventListenersFilterSetting.set(selectedOption.value);
113 this.update(); 154 this.update();
114 }, 155 },
115 156
116 _eventListenersArivedForTest: function() 157 _eventListenersArivedForTest: function()
117 { 158 {
118 }, 159 },
119 160
120 __proto__: WebInspector.ElementsSidebarPane.prototype 161 __proto__: WebInspector.ElementsSidebarPane.prototype
121 } 162 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/components/ObjectPropertiesSection.js ('k') | Source/devtools/front_end/sdk/DOMModel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698