Bug 262994

Summary: Safari 17 accidentally ships `assert` in dynamic import
Product: WebKit Reporter: nicolo.ribaudo
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: mark.lam, webkit-bug-importer, ysuzuki
Priority: P2 Keywords: InRadar
Version: Safari 17   
Hardware: Unspecified   
OS: Unspecified   

Description nicolo.ribaudo 2023-10-10 19:11:34 PDT
Given this test case (it can be copy-pasted in Safari's devtools):

```js
await Promise.allSettled([
  import("data:application/json,1", { with: { type: "json" } }),
  import("data:application/json,2", { assert: { type: "json" } }),
  import(`data:application/javascript,
    export { default } from "data:application/json,3" with { type: "json" }
  `),
  import(`data:application/javascript,
    export { default } from "data:application/json,4" assert { type: "json" }
  `)
])
```

there are four possible outputs that make sense:
1. all the promises are rejected, because import attributes are not supported (neither the new syntax nor the deprecated one)
2. the fist and third promises are resolved, because the engine only supports import attributes with the new syntax
3. the second and the fourth promises are resolved, because the engine only supports import attributes (assertions) with the deprecated syntax
4. all the promises are resolved, because the engine supports both the new and the deprecated syntax

The best possible behavior is (2).

Safari 16.6 does (1), Safari TP does (2), Chrome does (3) and is working on a (3)->(4)->(2) migration.

Somehow, in Safari 17 only the second promise is resolved and all the others are rejected, leading to a partial-(2) state. I would expect it to either behave like Safari 16 (and not ship import attributes yet) or like Safari TP (and fully ship the new syntax).

I don't think I can CC people, but please cc ysuzuki@apple.com (author of https://github.com/WebKit/WebKit/pull/16730).
Comment 1 nicolo.ribaudo 2023-10-10 23:08:38 PDT
In the original message I meant to write that Safari 17 is in a partial-(3) state, not partial-(2).
Comment 2 Radar WebKit Bug Importer 2023-10-11 15:02:33 PDT
<rdar://problem/116831377>
Comment 3 Mark Lam 2023-10-11 16:12:10 PDT

*** This bug has been marked as a duplicate of bug 260238 ***
Comment 4 nicolo.ribaudo 2023-10-11 18:01:31 PDT
I don't think this is a duplicate of bug 260238. bug 260238 was tracking going from "ship nothing" to "ship the right thing", and as I mentioned Safari TP has that behaviour and already had it before the Safari 17 release.

However, Safari 17 was shipped with the wrong version of the proposal partially enabled.

There was agreement among browsers to try to remove the `assert` version from the proposed specification, and Safari shipping `assert` and only `assert` goes actively against that goal.
Comment 5 nicolo.ribaudo 2023-10-12 01:53:44 PDT
I just realized that I previously tested on an older Safari version and the latest Safari 16 version behaves exactly the same as Safari 17. This is indeed a duplicate, sorry for the confusion!