WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
188672
Web Inspector: Provide $event in the console when paused on an event listener
https://bugs.webkit.org/show_bug.cgi?id=188672
Summary
Web Inspector: Provide $event in the console when paused on an event listener
Devin Rousso
Reported
2018-08-16 13:02:36 PDT
* SUMMARY When pausing on events, it's possible that the registered event listener might not have a parameter for the `event` object. * TEST <script> document.body.addEventListnener("click", () => { debugger; }); </script> * STEPS TO REPRODUCE 1. Inspect test page 2. Add event breakpoint for "click" 3. Click anywhere within the page to pause => should be able to access the `event` value via `$event` even though there was no named parameter for it
Attachments
Patch
(16.99 KB, patch)
2018-08-16 13:59 PDT
,
Devin Rousso
no flags
Details
Formatted Diff
Diff
Patch
(17.58 KB, patch)
2019-03-18 19:22 PDT
,
Devin Rousso
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Nikita Vasilyev
Comment 1
2018-08-16 13:43:54 PDT
Sounds like a good idea. $event = "foo"; document.body.addEventListnener("click", () => { debugger; }); `$event` is defined, we should preserve it. E.g. show "foo" and not the click event object.
Devin Rousso
Comment 2
2018-08-16 13:59:52 PDT
Created
attachment 347302
[details]
Patch
Joseph Pecoraro
Comment 3
2018-08-16 14:04:13 PDT
Comment on
attachment 347302
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=347302&action=review
> Source/JavaScriptCore/inspector/InjectedScriptSource.js:1396 > + this.$event = injectedScript._eventValue;
Given that events are a DOM concept, I don't think BasicCommandLineAPI will end up needing it. Since this is primarily for JSContext inspection (though it might make sense with ITMLKit inspection).
> Source/WebCore/inspector/CommandLineAPIModuleSource.js:50 > + this.$event = injectedScript._eventValue;
I wonder if we can just make this something like: this.__defineGetter__("$event", () => inspectedWindow.event); Is $event ever different from `window.event`? Yes it is possible for the page to have redefined the DOMWindow.prototype.event getter, so this isn't necessarily perfect but I don't think we need to be too concerned.
Joseph Pecoraro
Comment 4
2018-08-16 14:07:31 PDT
(In reply to Nikita Vasilyev from
comment #1
)
> Sounds like a good idea. > > $event = "foo"; > document.body.addEventListnener("click", () => { > debugger; > }); > > `$event` is defined, we should preserve it. E.g. show "foo" and not the > click event object.
Yes, this should be the normal behavior of the CommandLineAPI. The CommandLineAPI functions (keys, values, $0, $n, $exception, $event, etc) are in the background, so if the page has defined their own thing with an equivalent identifier, the page's thing should win out.
Devin Rousso
Comment 5
2018-08-16 16:20:23 PDT
Comment on
attachment 347302
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=347302&action=review
>> Source/WebCore/inspector/CommandLineAPIModuleSource.js:50 >> + this.$event = injectedScript._eventValue; > > I wonder if we can just make this something like: > > this.__defineGetter__("$event", () => inspectedWindow.event); > > Is $event ever different from `window.event`? Yes it is possible for the page to have redefined the DOMWindow.prototype.event getter, so this isn't necessarily perfect but I don't think we need to be too concerned.
I just tried this, and since `window.event` is defined, I'm not even sure that we need this. Typing just `event` will give you the same result as `$event`. I think we should hold off on this until we have a better reason for differentiating between `$event` and `event`/`window.event`.
Devin Rousso
Comment 6
2019-03-18 19:13:25 PDT
Comment on
attachment 347302
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=347302&action=review
>>> Source/WebCore/inspector/CommandLineAPIModuleSource.js:50 >>> + this.$event = injectedScript._eventValue; >> >> I wonder if we can just make this something like: >> >> this.__defineGetter__("$event", () => inspectedWindow.event); >> >> Is $event ever different from `window.event`? Yes it is possible for the page to have redefined the DOMWindow.prototype.event getter, so this isn't necessarily perfect but I don't think we need to be too concerned. > > I just tried this, and since `window.event` is defined, I'm not even sure that we need this. Typing just `event` will give you the same result as `$event`. I think we should hold off on this until we have a better reason for differentiating between `$event` and `event`/`window.event`.
Considering that `window.event` is non-standard, and is more likely to be overridden by the page's JavaScript than `$event`, I think we should consider adding this.
Devin Rousso
Comment 7
2019-03-18 19:22:31 PDT
Created
attachment 365110
[details]
Patch
WebKit Commit Bot
Comment 8
2019-03-19 12:31:36 PDT
Comment on
attachment 365110
[details]
Patch Clearing flags on attachment: 365110 Committed
r243161
: <
https://trac.webkit.org/changeset/243161
>
WebKit Commit Bot
Comment 9
2019-03-19 12:31:38 PDT
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 10
2019-03-19 12:32:16 PDT
<
rdar://problem/49030174
>
Truitt Savell
Comment 11
2019-03-20 09:52:58 PDT
The changes in
https://trac.webkit.org/changeset/243161/webkit
has broken inspector/timeline/line-column.html history:
http://webkit-test-results.webkit.org/dashboards/flakiness_dashboard.html#showAllRuns=true&tests=inspector%2Ftimeline%2Fline-column.html
I confirmed the test was working with the fix in 243155 and then broke in 243161 again.
Devin Rousso
Comment 12
2019-03-20 13:31:58 PDT
(In reply to Truitt Savell from
comment #11
)
> The changes in
https://trac.webkit.org/changeset/243161/webkit
> > has broken inspector/timeline/line-column.html > > history: >
http://webkit-test-results.webkit.org/dashboards/flakiness_dashboard
. > html#showAllRuns=true&tests=inspector%2Ftimeline%2Fline-column.html > > I confirmed the test was working with the fix in 243155 and then broke in > 243161 again.
Fixed test in followup <
https://trac.webkit.org/changeset/243234/webkit
>.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug