Open Bug 1714240 Opened 3 years ago Updated 8 months ago

PointerEvent.constructor misses checking the type of PointerEventInit.width param

Categories

(Core :: DOM: Events, defect)

Firefox 88
defect

Tracking

()

Tracking Status
firefox89 --- affected
firefox90 --- affected
firefox91 --- affected

People

(Reporter: zyscoder, Unassigned)

References

(Depends on 1 open bug, Blocks 1 open bug)

Details

User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36

Steps to reproduce:

(1) Open a tab and navigate to any URL;
(2) Run the following code in the Console of Devtools:

new PointerEvent('',{width:NaN});

(3) This code would be evaluated successfully without throwing any exceptions.

Actual results:

This code would be evaluated successfully without throwing any exceptions.

Expected results:

As https://w3c.github.io/pointerevents/#pointerevent-interface says, the width is of double type. Thus this code should throw an exception since we set the width param as NaN.

In my test, both Chrome and Webkit throw exceptions:
For Chrome: Uncaught TypeError: Failed to construct 'PointerEvent': The provided double value is non-finite.
For Webkit: TypeError: The provided value is non-finite

Thanks for filling this! I can also reproduce this on MacOS 10.15 on the latest Firefox versions. Moving it over to a component so developers can check it out.

Severity: -- → S4
Status: UNCONFIRMED → NEW
Type: enhancement → defect
Component: Untriaged → DOM: Events
Ever confirmed: true
Product: Firefox → Core

I think it is because width is a long webidl type, which convert a NaN to 0 in https://webidl.spec.whatwg.org/#abstract-opdef-converttoint, in Gecko. But it should be a double, which throws a TypeError for NaN in https://webidl.spec.whatwg.org/#es-double, per spec.

You need to log in before you can comment on or make changes to this bug.