Skip to content

Commit 6e916b1

Browse files
committed
Bug 1996014 [wpt PR 55619] - [OriginAPI] Delegate origin extraction for ExtendableMessageEvent., a=testonly
Automatic update from web-platform-tests [OriginAPI] Delegate origin extraction for `ExtendableMessageEvent`. We can't directly work with an `ExtendableMessageEvent` from within `DOMOrigin::from()`, as the former is defined in //modules, while the latter is defined in //core. This CL teaches `Event` (the first ancestor in `ExtendableMessageEvent`'s prototype chain) to support origin extraction, and overrides its default no-op implementation in both `MessageEvent` and `ExtendableMessageEvent`. Bug: 434131026 Change-Id: I605b770c460ea97ca22545f94bae65bcbab5c01e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7074832 Reviewed-by: Antonio Sartori <antoniosartorichromium.org> Commit-Queue: Mike West <mkwstchromium.org> Cr-Commit-Position: refs/heads/main{#1534317} -- wpt-commits: b6c0aa940eb81d0963200e30340a798862b3716b wpt-pr: 55619 UltraBlame original commit: 59555042addc6c7dadf1736961fc8d4f5d6ccf93
1 parent 00ca601 commit 6e916b1

File tree

1 file changed

+301
-0
lines changed

1 file changed

+301
-0
lines changed
Lines changed: 301 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,301 @@
1+
/
2+
/
3+
META
4+
:
5+
title
6+
=
7+
Origin
8+
.
9+
from
10+
(
11+
ExtendableMessageEvent
12+
)
13+
/
14+
/
15+
META
16+
:
17+
global
18+
=
19+
serviceworker
20+
/
21+
/
22+
META
23+
:
24+
script
25+
=
26+
/
27+
common
28+
/
29+
get
30+
-
31+
host
32+
-
33+
info
34+
.
35+
sub
36+
.
37+
js
38+
function
39+
WorkerActivationPromise
40+
(
41+
)
42+
{
43+
return
44+
new
45+
Promise
46+
(
47+
(
48+
resolve
49+
)
50+
=
51+
>
52+
{
53+
if
54+
(
55+
registration
56+
.
57+
active
58+
)
59+
{
60+
resolve
61+
(
62+
)
63+
;
64+
return
65+
;
66+
}
67+
self
68+
.
69+
addEventListener
70+
(
71+
'
72+
activate
73+
'
74+
(
75+
)
76+
=
77+
>
78+
{
79+
resolve
80+
(
81+
)
82+
;
83+
}
84+
)
85+
;
86+
}
87+
)
88+
;
89+
}
90+
test
91+
(
92+
t
93+
=
94+
>
95+
{
96+
const
97+
e
98+
=
99+
new
100+
ExtendableMessageEvent
101+
(
102+
"
103+
message
104+
"
105+
{
106+
origin
107+
:
108+
get_host_info
109+
(
110+
)
111+
.
112+
ORIGIN
113+
}
114+
)
115+
;
116+
const
117+
origin
118+
=
119+
Origin
120+
.
121+
from
122+
(
123+
e
124+
)
125+
;
126+
assert_true
127+
(
128+
!
129+
!
130+
origin
131+
"
132+
It
133+
'
134+
s
135+
not
136+
null
137+
!
138+
"
139+
)
140+
;
141+
assert_false
142+
(
143+
origin
144+
.
145+
opaque
146+
"
147+
It
148+
'
149+
s
150+
not
151+
opaque
152+
!
153+
"
154+
)
155+
;
156+
assert_true
157+
(
158+
origin
159+
.
160+
isSameOrigin
161+
(
162+
Origin
163+
.
164+
from
165+
(
166+
self
167+
)
168+
)
169+
"
170+
It
171+
'
172+
s
173+
same
174+
-
175+
origin
176+
with
177+
an
178+
Origin
179+
!
180+
"
181+
)
182+
;
183+
}
184+
"
185+
Constructed
186+
ExtendableMessageEvent
187+
objects
188+
have
189+
origins
190+
.
191+
"
192+
)
193+
;
194+
promise_test
195+
(
196+
async
197+
t
198+
=
199+
>
200+
{
201+
await
202+
WorkerActivationPromise
203+
(
204+
)
205+
;
206+
return
207+
new
208+
Promise
209+
(
210+
resolve
211+
=
212+
>
213+
{
214+
self
215+
.
216+
addEventListener
217+
(
218+
"
219+
message
220+
"
221+
e
222+
=
223+
>
224+
{
225+
const
226+
origin
227+
=
228+
Origin
229+
.
230+
from
231+
(
232+
e
233+
)
234+
;
235+
assert_true
236+
(
237+
!
238+
!
239+
origin
240+
)
241+
;
242+
assert_false
243+
(
244+
origin
245+
.
246+
opaque
247+
)
248+
;
249+
assert_true
250+
(
251+
origin
252+
.
253+
isSameOrigin
254+
(
255+
Origin
256+
.
257+
from
258+
(
259+
self
260+
)
261+
)
262+
)
263+
;
264+
resolve
265+
(
266+
)
267+
;
268+
}
269+
)
270+
;
271+
self
272+
.
273+
registration
274+
.
275+
active
276+
.
277+
postMessage
278+
(
279+
{
280+
type
281+
:
282+
"
283+
Hi
284+
"
285+
}
286+
)
287+
;
288+
}
289+
)
290+
;
291+
}
292+
"
293+
Posted
294+
ExtendableMessageEvent
295+
objects
296+
have
297+
origins
298+
.
299+
"
300+
)
301+
;

0 commit comments

Comments
 (0)