Bug 246207 - Modules with invalid "type" assertion should throw
Summary: Modules with invalid "type" assertion should throw
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore JavaScript (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Yusuke Suzuki
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-10-07 03:14 PDT by Nicolò Ribaudo
Modified: 2022-10-15 01:26 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nicolò Ribaudo 2022-10-07 03:14:47 PDT
Consider these two files:

    // main.js
    await import("./dep.js", { assert: { type: "<invalid>" } });


    // dep.js
    console.log("Hi from dep!");

Step 6 of https://html.spec.whatwg.org/#fetch-an-import()-module-script-graph stops the import process if "type" is not a supported type assertion, so dep.js shouldn't be fetched and executed.
However, WebKit ignores the "type" assertions and loads dep.js as JavaScript.

Tested in Epiphani TP 43.0-12.

I believe that this bug comes from the .value_or call at https://github.com/WebKit/WebKit/blob/5d0f369579801f91293bcae0845cca26c816ea44/Source/WebCore/bindings/js/ScriptModuleLoader.cpp#L318.
Comment 1 Radar WebKit Bug Importer 2022-10-14 03:15:18 PDT
<rdar://problem/101166148>
Comment 2 Yusuke Suzuki 2022-10-14 15:35:44 PDT
Pull request: https://github.com/WebKit/WebKit/pull/5399
Comment 3 EWS 2022-10-15 01:26:00 PDT
Committed 255574@main (902de48a7da9): <https://commits.webkit.org/255574@main>

Reviewed commits have been landed. Closing PR #5399 and removing active labels.