initKeyEvent on KeyboardEvent should return undefined
Categories
(Core :: DOM: Events, enhancement, P3)
Tracking
()
People
(Reporter: karlcow, Assigned: masayuki)
References
(Blocks 1 open bug, )
Details
(Keywords: dev-doc-complete)
Attachments
(2 files)
Test
var i = document.createEvent("KeyboardEvent");
typeof i.initKeyEvent;
On Firefox it returns function
On Blink and WebKit browsers, it returns undefined
This creates at least a webcompat issue on startrack.com.au
Given that it is not implemented in Safari, Chrome and Edge, I have the feeling we can safely unship it. We could try on Nightly, and discover if any sites break.
I see Masayuki mentioning initKeyEvent()
in Bug 1479964 Comment #25
I wonder if it's the relevant code.
https://searchfox.org/mozilla-central/rev/f351e19360729b351bfc7c1386d6e4ca4ea676e2/dom/events/KeyboardEvent.cpp#313-328
It's also not specified in the DOM Specification.
https://dom.spec.whatwg.org/
And defined as non standard and deprecated on MDN
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/initKeyEvent
Comment 1•3 years ago
|
||
Masayuki, do you want to take this? I would suggest we add a preference that's false-by-default and use that to hide the method in IDL. Then if we don't notice anything we can remove it entirely after a couple of releases. Let's also do an intent to unship just in case.
Updated•3 years ago
|
Assignee | ||
Comment 2•3 years ago
|
||
Hmm, it's an old API, so, I bet that there are some web apps in the wild which use it for detecting Firefox...
Assignee | ||
Updated•3 years ago
|
Assignee | ||
Comment 3•3 years ago
|
||
122,392 code results
https://github.com/search?q=initKeyEvent&type=Code
sigh... perhaps, we should do it with an allowed list, isn't it?
Comment 4•3 years ago
|
||
I'm not sure what that means? A lot of the code there seems to make usage conditional though and uses initKeyboardEvent()
if not available, which is something all browsers expose.
Comment 5•3 years ago
|
||
Yeah, I do see some code that calls initKeyEvent
without existence check but those are just a few, and others are mostly from happen.js and jquery.simulate.js that have workarounds.
Assignee | ||
Comment 6•3 years ago
|
||
Okay, I'll post a patch which just disables it with a pref.
Assignee | ||
Comment 7•3 years ago
|
||
Assignee | ||
Comment 8•3 years ago
|
||
Now, Gecko is the only browser to support undocumented KeyEvent.initKeyEvent
.
We should drop it by default because typeof KeyboardEvent.initKeyEvent
is
used at least in a major web-site and which causes not working the web-site.
Depends on D121028
Reporter | ||
Comment 9•3 years ago
|
||
The webcompat team will watch out if there is new breakage where initKeyEvent would be used to identify/target Firefox.
Comment 10•3 years ago
|
||
Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/2ee20e58b0f1 Stop using `KeyEvent.initKeyEvent` in our tests r=smaug https://hg.mozilla.org/integration/autoland/rev/81a7baecf0cb Disable `KeyEvent.initKeyEvent` by default r=smaug
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/29963 for changes under testing/web-platform/tests
Comment 12•3 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/2ee20e58b0f1
https://hg.mozilla.org/mozilla-central/rev/81a7baecf0cb
Updated•3 years ago
|
Upstream PR merged by moz-wptsync-bot
Comment 14•3 years ago
|
||
Since the status are different for nightly and release, what's the status for beta?
For more information, please visit auto_nag documentation.
Updated•3 years ago
|
Comment 15•3 years ago
|
||
We just emailed affected developers to let them know .initKeyEvent is deprecated as of Firefox 93 and will be unshipped in Firefox 96.
Updated•3 years ago
|
Comment 16•3 years ago
|
||
FYI FF93 MDN docs for this can be tracked in https://github.com/mdn/content/issues/8623. This is just addition of release note, and making information about the deprecation and the preference more clear on the page.
When you actually remove it we'll need to do a little more work in cleanup.
Description
•