Skip to content

Commit 1cd3f74

Browse files
committed
Bug 1966168 [wpt PR 52498] - [source-phase-imports] Support Wasm Source Phase Imports,
Automatic update from web-platform-tests [source-phase-imports] Support Wasm Source Phase Imports Adds ModuleRecord::ResolveSourceCallback to be called when instantiating source phase children of the module graph. Implement HostImportModuleWithPhaseDynamically and register it in the V8 isolate, this is called when executing `import.source`. Add error handling for wasm imports in evaluation phase and non-wasm imports in source phase. Move module instantiation behind the ModuleScript interface to properly throw evaluation phase errors. Bug: 42204365 Change-Id: Ia3e855180f1f740023864b3499dc451278b53d47 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6351556 Reviewed-by: Dominic Farolino <domchromium.org> Commit-Queue: Luis Pardo <lpardosixtosmicrosoft.com> Reviewed-by: Kouhei Ueno <kouheichromium.org> Cr-Commit-Position: refs/heads/main{#1459475} -- wpt-commits: 8e1b3aaae7ebbb333ae0ccb1b67a01b5b2d774bf wpt-pr: 52498 Differential Revision: https://phabricator.services.mozilla.com/D250146 UltraBlame original commit: bb21625d147b61f26f58e5597ca21c7feed88c23
1 parent 59e9184 commit 1cd3f74

10 files changed

+1676
-8
lines changed
Lines changed: 238 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,238 @@
1+
import
2+
source
3+
modSource
4+
from
5+
'
6+
.
7+
/
8+
worker
9+
.
10+
wasm
11+
'
12+
;
13+
class
14+
AudioProcessor
15+
extends
16+
AudioWorkletProcessor
17+
{
18+
constructor
19+
(
20+
.
21+
.
22+
.
23+
args
24+
)
25+
{
26+
super
27+
(
28+
.
29+
.
30+
.
31+
args
32+
)
33+
;
34+
let
35+
port
36+
=
37+
this
38+
.
39+
port
40+
;
41+
port
42+
.
43+
onmessage
44+
=
45+
(
46+
e
47+
)
48+
=
49+
>
50+
{
51+
let
52+
staticCheck
53+
=
54+
false
55+
;
56+
let
57+
dynamicCheck
58+
=
59+
false
60+
;
61+
const
62+
pm
63+
=
64+
(
65+
x
66+
)
67+
=
68+
>
69+
{
70+
const
71+
message
72+
=
73+
{
74+
value
75+
:
76+
x
77+
staticCheck
78+
:
79+
staticCheck
80+
dynamicCheck
81+
:
82+
dynamicCheck
83+
}
84+
;
85+
port
86+
.
87+
postMessage
88+
(
89+
message
90+
)
91+
;
92+
}
93+
staticCheck
94+
=
95+
modSource
96+
instanceof
97+
WebAssembly
98+
.
99+
Module
100+
;
101+
/
102+
/
103+
import
104+
.
105+
source
106+
should
107+
fail
108+
because
109+
dynamic
110+
imports
111+
aren
112+
'
113+
t
114+
supported
115+
/
116+
/
117+
in
118+
worklets
119+
.
120+
let
121+
import_promise
122+
=
123+
import
124+
.
125+
source
126+
(
127+
'
128+
.
129+
/
130+
execute
131+
-
132+
start
133+
.
134+
wasm
135+
'
136+
)
137+
;
138+
import_promise
139+
.
140+
catch
141+
(
142+
(
143+
e
144+
)
145+
=
146+
>
147+
{
148+
dynamicCheck
149+
=
150+
e
151+
instanceof
152+
TypeError
153+
;
154+
}
155+
)
156+
.
157+
then
158+
(
159+
(
160+
)
161+
=
162+
>
163+
{
164+
/
165+
/
166+
worker
167+
.
168+
wasm
169+
will
170+
call
171+
pm
172+
with
173+
the
174+
result
175+
so
176+
instantiate
177+
this
178+
/
179+
/
180+
after
181+
the
182+
dynamic
183+
check
184+
.
185+
WebAssembly
186+
.
187+
instantiate
188+
(
189+
modSource
190+
{
191+
'
192+
.
193+
/
194+
worker
195+
-
196+
helper
197+
.
198+
js
199+
'
200+
:
201+
{
202+
'
203+
pm
204+
'
205+
:
206+
pm
207+
}
208+
}
209+
)
210+
;
211+
}
212+
)
213+
;
214+
}
215+
;
216+
}
217+
process
218+
(
219+
inputs
220+
outputs
221+
parameters
222+
)
223+
{
224+
return
225+
true
226+
;
227+
}
228+
}
229+
registerProcessor
230+
(
231+
'
232+
audio
233+
-
234+
processor
235+
'
236+
AudioProcessor
237+
)
238+
;
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
await
2+
import
3+
.
4+
source
5+
(
6+
'
7+
https
8+
:
9+
/
10+
/
11+
{
12+
{
13+
hosts
14+
[
15+
alt
16+
]
17+
[
18+
]
19+
}
20+
}
21+
:
22+
{
23+
{
24+
ports
25+
[
26+
https
27+
]
28+
[
29+
0
30+
]
31+
}
32+
}
33+
/
34+
resources
35+
/
36+
execute
37+
-
38+
start
39+
.
40+
wasm
41+
'
42+
)
43+
;
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import
2+
source
3+
exportedNamesSource
4+
from
5+
'
6+
https
7+
:
8+
/
9+
/
10+
{
11+
{
12+
hosts
13+
[
14+
alt
15+
]
16+
[
17+
]
18+
}
19+
}
20+
:
21+
{
22+
{
23+
ports
24+
[
25+
https
26+
]
27+
[
28+
0
29+
]
30+
}
31+
}
32+
/
33+
resources
34+
/
35+
exported
36+
-
37+
names
38+
.
39+
wasm
40+
'
41+
;

testing/web-platform/tests/wasm/webapi/esm-integration/resources/worker-helper.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,23 @@ pm
55
x
66
)
77
{
8+
const
9+
message
10+
=
11+
{
12+
value
13+
:
14+
x
15+
checks
16+
:
17+
pm
18+
.
19+
checks
20+
}
21+
;
822
postMessage
923
(
10-
x
24+
message
1125
)
1226
;
1327
}

testing/web-platform/tests/wasm/webapi/esm-integration/resources/worker-source-phase.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,35 +25,36 @@ helper
2525
js
2626
"
2727
;
28-
assert_true
29-
(
28+
pm
29+
.
30+
checks
31+
=
32+
[
3033
modSource
3134
instanceof
3235
WebAssembly
3336
.
3437
Module
35-
)
36-
;
37-
assert_true
3838
(
3939
await
4040
import
4141
.
4242
source
4343
(
44-
"
44+
'
4545
.
4646
/
4747
worker
4848
.
4949
wasm
50-
"
50+
'
5151
)
5252
=
5353
=
5454
=
5555
modSource
5656
)
57+
]
5758
;
5859
await
5960
WebAssembly

0 commit comments

Comments
 (0)