Open Bug 1693172 Opened 5 years ago Updated 2 months ago

TouchEvent is not always defined

Categories

(Core :: DOM: Events, defect, P3)

defect

Tracking

()

UNCONFIRMED

People

(Reporter: aritz, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: webcompat:platform-bug)

User Story

user-impact-score:30

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.

Component: Untriaged → DOM: Events
Product: Firefox → Core

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.

Version: Firefox 85 → Trunk

But it isn't clear to me why Chrome's behavior would be correct. At least it breaks various feature testing mechanisms.

Severity: -- → S3
Priority: -- → P3

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.

See Also: → 2012789
Blocks: 2012789
See Also: 2012789
User Story: (updated)
User Story: (updated)
You need to log in before you can comment on or make changes to this bug.