Closed Bug 1714485 Opened 3 years ago Closed 3 years ago

Worker.constructor miss checking for the type of options.type param

Categories

(Core :: DOM: Workers, enhancement)

Firefox 88
enhancement

Tracking

()

RESOLVED DUPLICATE of bug 1247687

People

(Reporter: zyscoder, Unassigned)

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 Worker(origin,{type:'any_str'});

(3) Then 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://html.spec.whatwg.org/multipage/workers.html#workertype says, options.type param is of WorkerType: enum WorkerType { "classic", "module" };. Since this code set the type as "any_str", not any member in the WorkerType enum, a TypeError exception should be thrown.

BTW, in my test, both Chrome and Webkit throw TypeRrror exceptions:
For Chrome: VM183:1 Uncaught TypeError: Failed to construct 'Worker': The provided value 'any_str' is not a valid enum value of type WorkerType.
For Webkit: TypeError: Type error

Thanks for the report. Firefox doesn't yet support type, because only "classic" workers are supported at the moment.

Status: UNCONFIRMED → RESOLVED
Closed: 3 years ago
Component: Untriaged → DOM: Workers
Product: Firefox → Core
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.