DedicatedWorker should fire an event of type "Event" instead of "ErrorEvent" when the script has error to rethrow.
Categories
(Core :: DOM: Workers, defect, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox118 | --- | fixed |
People
(Reporter: allstars.chh, Assigned: allstars.chh)
References
(Blocks 1 open bug)
Details
Attachments
(5 files)
https://html.spec.whatwg.org/multipage/workers.html#run-a-worker
Step 14
In both cases, let onComplete given script be the following steps:
If script is null or if script's error to rethrow is non-null, then:
Queue a global task on the DOM manipulation task source given worker's relevant global object to fire an event named error at worker.
Run the environment discarding steps for inside settings.
Abort these steps.
and
https://dom.spec.whatwg.org/#concept-event-fire
1. If eventConstructor is not given, then let eventConstructor be Event.
Currently, our implementation will create an ErrorEvent for this
This causes the WPT failure in /workers/modules/dedicated-worker-parse-error-failure.html
We cannot simply change it to use Event because in other cases we need ErrorEvent.
See https://html.spec.whatwg.org/multipage/workers.html#runtime-script-errors-2
The other bug for SharedWorker is in bug 1627938
Updated•2 years ago
|
Updated•2 years ago
|
Assignee | ||
Updated•2 years ago
|
Comment 1•1 year ago
|
||
This is true for both of these WPTs, so for both shared and dedicated workers:
Comment 2•1 year ago
|
||
Ah, I didn't realize we have separate bugs for the shared and dedicated workers, I'll change the bug's title back.
Assignee | ||
Updated•1 year ago
|
Assignee | ||
Comment 3•1 year ago
|
||
According to the spec,
https://html.spec.whatwg.org/#run-a-worker
- In both cases, let onComplete given script be the following steps:
- If script is null or if script's error to rethrow is non-null, then:
1. Queue a global task on the DOM manipulation task source given worker's relevant global object to fire an event named error at worker.
2. Run the environment discarding steps for inside settings.
3. Abort these steps.
Check if the module worker script has a parse error or an error to
rethrow. If it has, assign an error code to mRv and return false.
The error will be reported in CompileScriptRunnable
https://searchfox.org/mozilla-central/rev/892475f3ba2b959aeaef19d1d8602494e3f2ae32/dom/workers/WorkerPrivate.cpp#417
Assignee | ||
Comment 4•1 year ago
|
||
According to the spec,
https://html.spec.whatwg.org/#run-a-worker
- In both cases, let onComplete given script be the following steps:
- If script is null or if script's error to rethrow is non-null, then:
1. Queue a global task on the DOM manipulation task source given worker's relevant global object to fire an event named error at worker.
2. Run the environment discarding steps for inside settings.
3. Abort these steps.
Split EvaluateSourceBuffer into JS::Compile and JS_ExecuteScript.
So if we found the script cannot be compiled and it is a top-level script,
we assign a non-JS-Exception error code to it.
If the script cannot be compiled and it's not a top-level script, this
means it's a script which is loaded by importScripts(), according to the
spec, https://html.spec.whatwg.org/#import-scripts-into-worker-global-scope
the exception will be rethrown.
Assignee | ||
Comment 5•1 year ago
|
||
AbstractWorker.onerror.js has a SyntaxError, so according to the spec
"Event" should be fired instead of "ErrorEvent".
Assignee | ||
Comment 6•1 year ago
|
||
Assignee | ||
Comment 7•1 year ago
|
||
Updated•1 year ago
|
Assignee | ||
Updated•1 year ago
|
Assignee | ||
Comment 8•1 year ago
|
||
Oh, asked HTML spec author about the correctness of the spec,
there is an open issue https://github.com/whatwg/html/issues/2289, which is discussing whether fire an Event or an ErrorEvent.
https://github.com/whatwg/html/issues/2289#issuecomment-1670679677
Assignee | ||
Comment 9•1 year ago
|
||
(In reply to Yoshi Cheng-Hao Huang [:allstars.chh][:allstarschh][:yoshi] from comment #8)
Oh, asked HTML spec author about the correctness of the spec,
there is an open issue https://github.com/whatwg/html/issues/2289, which is discussing whether fire an Event or an ErrorEvent.
https://github.com/whatwg/html/issues/2289#issuecomment-1670679677
Domenic just confirms the spec is correct in https://github.com/whatwg/html/issues/2289#issuecomment-1676721412
Although he still doesn't explain the failed WPT test
https://wpt.fyi/results/workers?label=master&label=experimental&aligned&q=worker-parse-error-failure
Even Chrome only passes the WPTs in worker/modules
https://wpt.fyi/results/workers/modules?label=master&label=experimental&aligned&q=worker-parse-error-failure
For the classic worker tests, all browsers still failed.
https://wpt.fyi/results/workers?label=master&label=experimental&aligned&q=worker-parse-error-failure
AbstractWorker.onerror.html
https://wpt.fyi/results/workers/constructors/Worker/AbstractWorker.onerror.html?label=experimental&label=master&aligned
which is using ErrorEvent, but is passed in all browsers.
Hi smaug
So what do you think in this case?
You said maybe the spec is wrong, but now the spec author confirms the spec is correct......
Comment 10•1 year ago
|
||
"that spec is correct" :) That is just an opinion.
Domenic doesn't say what is correct and what is not. It is browser engine vendors who say, at least two out of tree. (He does represent one)
Using Event should be fine, but we need to ask other browser vendors if they are ok to change the behavior. It is after all a bit unusual to break a case where all the engines work the same way.
But in practice, since Google seems to favor Event, and so do we, we could just change the WPTs and our behavior.
And I don't think we ever report anything useful in these ErrorEvents so breaking existing websites should be unlikely.
Updated•1 year ago
|
Comment 11•1 year ago
|
||
Comment 13•1 year ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/1695ada26bb4
https://hg.mozilla.org/mozilla-central/rev/df2d96840c43
https://hg.mozilla.org/mozilla-central/rev/47a3e3dc971e
https://hg.mozilla.org/mozilla-central/rev/14e55a816cfa
https://hg.mozilla.org/mozilla-central/rev/ff922cf6a8ea
Description
•