TouchEvent is not always defined
Categories
(Core :: DOM: Events, defect, P3)
Tracking
()
People
(Reporter: aritz, Unassigned)
References
Details
User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:85.0) Gecko/20100101 Firefox/85.0
Steps to reproduce:
Attempt to use code using ev instanceof TouchEvent
Actual results:
If the system doesn't have a touch device when the page is loaded, and touch simulation isn't enabled, "ReferenceError: TouchEvent is not defined" is thrown.
Expected results:
TouchEvent should always be defined, instead of only when touch simulation is enabled or a touch device is detected. This is the current behaviour on Chromium.
Updated•3 years ago
|
Comment 1•3 years ago
|
||
Did you file an equivalent bug against Safari? It's not clear to me what should happen here as Chrome does throw for document.createEvent("touchevent")
on desktop.
Comment 2•3 years ago
|
||
We could in theory set the pref to 1, I think
https://searchfox.org/mozilla-central/rev/3f97afc8db535f9b0232222cb48cc4cbf8334c76/modules/libpref/init/StaticPrefList.yaml#3364
The legacy APIs are controlled by a different pref
https://searchfox.org/mozilla-central/rev/3f97afc8db535f9b0232222cb48cc4cbf8334c76/modules/libpref/init/StaticPrefList.yaml#3355-3361
Comment 3•3 years ago
|
||
But it isn't clear to me why Chrome's behavior would be correct. At least it breaks various feature testing mechanisms.
Comment 4•2 years ago
|
||
Given the discussion in bug 1412485 (in particular comment 1 there) it seems like it was somewhat intentional. Hide the "legacy APIs" but expose modern stuff, which would include event constructors presumably. Aligning seems easiest.
Description
•