<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>246207</bug_id>
          
          <creation_ts>2022-10-07 03:14:47 -0700</creation_ts>
          <short_desc>Modules with invalid &quot;type&quot; assertion should throw</short_desc>
          <delta_ts>2022-10-15 01:26:02 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebCore JavaScript</component>
          <version>Other</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Nicolò Ribaudo">nribaudo</reporter>
          <assigned_to name="Yusuke Suzuki">ysuzuki</assigned_to>
          <cc>mark.lam</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1904004</commentid>
    <comment_count>0</comment_count>
    <who name="Nicolò Ribaudo">nribaudo</who>
    <bug_when>2022-10-07 03:14:47 -0700</bug_when>
    <thetext>Consider these two files:

    // main.js
    await import(&quot;./dep.js&quot;, { assert: { type: &quot;&lt;invalid&gt;&quot; } });


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

Step 6 of https://html.spec.whatwg.org/#fetch-an-import()-module-script-graph stops the import process if &quot;type&quot; is not a supported type assertion, so dep.js shouldn&apos;t be fetched and executed.
However, WebKit ignores the &quot;type&quot; 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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1905574</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-10-14 03:15:18 -0700</bug_when>
    <thetext>&lt;rdar://problem/101166148&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1905759</commentid>
    <comment_count>2</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2022-10-14 15:35:44 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/5399</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1905843</commentid>
    <comment_count>3</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2022-10-15 01:26:00 -0700</bug_when>
    <thetext>Committed 255574@main (902de48a7da9): &lt;https://commits.webkit.org/255574@main&gt;

Reviewed commits have been landed. Closing PR #5399 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>