Bug 81658

Summary: Web Inspector: expose queryEventListeners() to console command line API
Product: WebKit Reporter: Andrey Kosyakov <caseq>
Component: Web Inspector (Deprecated)Assignee: Andrey Kosyakov <caseq>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, apavlov, bweinstein, haraken, japhet, joepeck, keishi, loislo, pfeldman, pmuellr, rik, timothy, webkit.review.bot, yurys
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch
none
Patch
none
Patch yurys: review+, buildbot: commit-queue-

Andrey Kosyakov
Reported 2012-03-20 06:41:01 PDT
This adds queryEventListeners() call to command line API in the inspector console. Only the JS listeners in current world are returned. We primarily want this to be accessible to Web Inspector extensions, although this might be handy for having a closer look at the listeners to the interactive users as well.
Attachments
Patch (23.48 KB, patch)
2012-03-20 06:44 PDT, Andrey Kosyakov
no flags
Patch (25.75 KB, patch)
2012-03-20 07:38 PDT, Andrey Kosyakov
no flags
Patch (24.35 KB, patch)
2012-03-20 08:39 PDT, Andrey Kosyakov
yurys: review+
buildbot: commit-queue-
Andrey Kosyakov
Comment 1 2012-03-20 06:44:16 PDT
Yury Semikhatsky
Comment 2 2012-03-20 07:12:19 PDT
Comment on attachment 132815 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=132815&action=review > Source/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp:231 > + eventListeners->putDirect(exec->globalData(), Identifier(exec, "node"), toJS(exec, globalObject, listenersArray[i].node)); Do we really want to return event listeners for ancestors? > Source/WebCore/inspector/InjectedScriptHost.h:95 > + void queryEventListenersImpl(Node*, Vector<EventListenerInfo>& listenersArray); Why is this Impl suffix?
Build Bot
Comment 3 2012-03-20 07:13:39 PDT
Yury Semikhatsky
Comment 4 2012-03-20 07:17:19 PDT
Comment on attachment 132815 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=132815&action=review > LayoutTests/inspector/console/command-line-api-queryEventListeners.html:20 > +<div id="inner"> Please add a few attribute handlers as they will also be listed as the listeners.
Andrey Kosyakov
Comment 5 2012-03-20 07:36:36 PDT
(In reply to comment #2) > (From update of attachment 132815 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=132815&action=review > > > Source/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp:231 > > + eventListeners->putDirect(exec->globalData(), Identifier(exec, "node"), toJS(exec, globalObject, listenersArray[i].node)); > > Do we really want to return event listeners for ancestors? This is for consistency with what we do in the DOM agent/elements panel -- presumably, caller would be interested in the ancestors, given these may have interceptors or handlers for bubbling event. This could go under a boolean flag, perhaps. > > Source/WebCore/inspector/InjectedScriptHost.h:95 > > + void queryEventListenersImpl(Node*, Vector<EventListenerInfo>& listenersArray); > > Why is this Impl suffix? Just for consistency with inspectImpl(). I'm not particularly attached to it, though, so will gladly drop. > Please add a few attribute handlers as they will also be listed as the listeners. Fixed.
Andrey Kosyakov
Comment 6 2012-03-20 07:38:51 PDT
Build Bot
Comment 7 2012-03-20 08:04:54 PDT
Andrey Kosyakov
Comment 8 2012-03-20 08:37:47 PDT
(In reply to comment #2) > (From update of attachment 132815 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=132815&action=review > > > Source/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp:231 > > + eventListeners->putDirect(exec->globalData(), Identifier(exec, "node"), toJS(exec, globalObject, listenersArray[i].node)); > > Do we really want to return event listeners for ancestors? On a second thought, I'd let the caller do the work of traversing the ancestry -- this will make the interface simpler.
Andrey Kosyakov
Comment 9 2012-03-20 08:39:12 PDT
Build Bot
Comment 10 2012-03-20 09:08:52 PDT
Yury Semikhatsky
Comment 11 2012-03-20 09:32:41 PDT
> > > Source/WebCore/inspector/InjectedScriptHost.h:95 > > > + void queryEventListenersImpl(Node*, Vector<EventListenerInfo>& listenersArray); > > > > Why is this Impl suffix? > > Just for consistency with inspectImpl(). I'm not particularly attached to it, though, so will gladly drop. > Can we remove it from inspectImpl instead. Other methods seem not to use such suffix.
Pavel Feldman
Comment 12 2012-03-20 09:59:33 PDT
(In reply to comment #11) > > > > Source/WebCore/inspector/InjectedScriptHost.h:95 > > > > + void queryEventListenersImpl(Node*, Vector<EventListenerInfo>& listenersArray); > > > > > > Why is this Impl suffix? > > > > Just for consistency with inspectImpl(). I'm not particularly attached to it, though, so will gladly drop. > > > Can we remove it from inspectImpl instead. Other methods seem not to use such suffix. If we drop Impl suffix, there will be no way to tell whether InjectedScriptHost::inspect is custom or not. We used this pattern for all the base implementations of custom members. I think it is useful.
Pavel Feldman
Comment 13 2012-03-20 17:15:19 PDT
Comment on attachment 132833 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=132833&action=review > Source/WebCore/inspector/InjectedScriptSource.js:580 > + "monitorEvents", "unmonitorEvents", "inspect", "copy", "clear", "queryEventListeners" I'd call it getEventListeners, there is no query per se. > Source/WebCore/inspector/InjectedScriptSource.js:690 > + return InjectedScriptHost.queryEventListeners(node); I'd add a request parameter determining whether caller is interested in self node's listeners or hierarchy ones as well.
Andrey Kosyakov
Comment 14 2012-03-21 06:22:34 PDT
Note You need to log in before you can comment on or make changes to this bug.