While I am implementing whatwg/html#8253 in Firefox, I notice that there are two WPT tests that should be updated
- choice-of-error-1.html
- error-type-1.html
These two tests were added in c7a8ddc
and were added to address whatwg/html#2991
But now with whatwg/html#8253 is merged, those two tests are not valid anymore.
Below I explain them in detail:
- choice-of-error-1.html
With the current spec, if a sub-module script has a parse error
https://html.spec.whatwg.org/#hostloadimportedmodule
Step 14.
3. Otherwise, if moduleScript's parse error is not null, then:
1. Let parseError be moduleScript's parse error.
2. Set completion to ThrowCompletion(parseError).
3. If loadState is not undefined and loadState.[[ErrorToRethrow]] is null, set loadState.[[ErrorToRethrow]] to parseError
..
5. Perform FinishLoadingImportedModule(referrer, moduleRequest, payload, completion).
https://tc39.es/ecma262/#sec-FinishLoadingImportedModule
Step 2. If payload is a GraphLoadingState Record, then
a. Perform ContinueModuleLoading(payload, result).
https://tc39.es/ecma262/#sec-ContinueModuleLoading
Step 3. Else,
a. Set state.[[IsLoading]] to false.
b. Perform ! Call(state.[[PromiseCapability]].[[Reject]], undefined, « moduleCompletion.[[Value]] »).
https://html.spec.whatwg.org/#fetch-the-descendants-of-and-link-a-module-script
Step 7. Upon rejection of loadingPromise, run the following steps
1. If state.[[ErrorToRethrow]] is not null, set moduleScript's error to rethrow to state.[[ErrorToRethrow]] and run onComplete given moduleScript.
The parse error (from syntaxerror.js#1c or syntaxerror.js#1d) will be reported to the two module graphs, choice-of-error-1a.js and choice-of-error-1b.js
Hence, the errors should be identical, meaning that the assert_not_equals(log[0], log[2] should be changed to assert_equals(log[0], log[2]
The test worked because of the legacy behavior, find the first parse error
legacy spec link PR 2991
legacy spec link before PR 8253
will report different parse errors on both the module graphs:
1a.js
1b.js
1a.js (already in discoveredSet, continue)
syntaxerror.js#1d (found first parse error)
1b.js
1a.js
1b.js (already in discoveredSet, continue)
syntaxerror.js#1c (found first parse error)
- error-type-1.html
The module error-type-1.js will import syntaxerror.js and 404.js
And syntaxerror.js has been fetched previously, so the parse error should be reported first.
For syntaxerror.js, the spec link is the same as above.
For the null script of 404.js
https://html.spec.whatwg.org/#hostloadimportedmodule
Step 14.
2. If moduleScript is null, then set completion to [ThrowCompletion](new TypeError)
https://html.spec.whatwg.org/#fetch-the-descendants-of-and-link-a-module-script
Step 7.2. Otherwise, run onComplete given null.
The test was to address the spec text introduced in whatwg/html#2991
fetch a single module script
Step 8. If any of the following conditions are met,... asynchronously complete this algorithm with null, and abort these steps:
response's type is "error"
fetch the descendants of a module script
Step 7. For each url in URLs, perform the internal module script graph fetching procedure ...
...
If any of the invocations of the internal module script graph fetching procedure asynchronously complete with null, asynchronously complete this algorithm with null, aborting these steps.
I also quote the spec before whatwg/html#8253
fetch the descendants of a module script
Step 11.2. If result is null, then set failed to true, run onComplete with null, and abort these steps.
Therefore, for error-type-1.html should be updated as well.
I have uploaded my fixes in
fix for choice-of-error-1.html
fix for error-type-1.html
However, according to wpt.fyi
choice-of-error-1.html
error-type-1.html,
landing those fixes will regress? other browser vendors as well,
So I'd like to request a consensus first
CCing @nicolo-ribaudo @domenic
While I am implementing whatwg/html#8253 in Firefox, I notice that there are two WPT tests that should be updated
These two tests were added in c7a8ddc
and were added to address whatwg/html#2991
But now with whatwg/html#8253 is merged, those two tests are not valid anymore.
Below I explain them in detail:
With the current spec, if a sub-module script has a parse error
https://html.spec.whatwg.org/#hostloadimportedmodule
https://tc39.es/ecma262/#sec-FinishLoadingImportedModule
https://tc39.es/ecma262/#sec-ContinueModuleLoading
https://html.spec.whatwg.org/#fetch-the-descendants-of-and-link-a-module-script
The parse error (from syntaxerror.js#1c or syntaxerror.js#1d) will be reported to the two module graphs, choice-of-error-1a.js and choice-of-error-1b.js
Hence, the errors should be identical, meaning that the assert_not_equals(log[0], log[2] should be changed to assert_equals(log[0], log[2]
The test worked because of the legacy behavior, find the first parse error
legacy spec link PR 2991
legacy spec link before PR 8253
will report different parse errors on both the module graphs:
The module error-type-1.js will import syntaxerror.js and 404.js
And syntaxerror.js has been fetched previously, so the parse error should be reported first.
For syntaxerror.js, the spec link is the same as above.
For the null script of 404.js
https://html.spec.whatwg.org/#hostloadimportedmodule
https://html.spec.whatwg.org/#fetch-the-descendants-of-and-link-a-module-script
The test was to address the spec text introduced in whatwg/html#2991
fetch a single module script
fetch the descendants of a module script
I also quote the spec before whatwg/html#8253
fetch the descendants of a module script
Therefore, for error-type-1.html should be updated as well.
I have uploaded my fixes in
fix for choice-of-error-1.html
fix for error-type-1.html
However, according to wpt.fyi
choice-of-error-1.html
error-type-1.html,
landing those fixes will regress? other browser vendors as well,
So I'd like to request a consensus first
CCing @nicolo-ribaudo @domenic