Skip to content

Commit cf54a2a

Browse files
committed
Bug 1966355 - Part 18: Add structured clone support. r=spidermonkey-reviewers,sfink
Spec PR: <whatwg/html#11033> Differential Revision: https://phabricator.services.mozilla.com/D249411 UltraBlame original commit: da0c4055945e2adeb6d7e5d24bc34e0f114364a7
1 parent 37fb3af commit cf54a2a

3 files changed

Lines changed: 1137 additions & 10 deletions

File tree

Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
/
2+
/
3+
|
4+
jit
5+
-
6+
test
7+
|
8+
-
9+
-
10+
enable
11+
-
12+
arraybuffer
13+
-
14+
immutable
15+
;
16+
skip
17+
-
18+
if
19+
:
20+
!
21+
ArrayBuffer
22+
.
23+
prototype
24+
.
25+
transferToImmutable
26+
load
27+
(
28+
libdir
29+
+
30+
"
31+
asserts
32+
.
33+
js
34+
"
35+
)
36+
;
37+
const
38+
scopes
39+
=
40+
[
41+
"
42+
SameProcess
43+
"
44+
"
45+
DifferentProcess
46+
"
47+
"
48+
DifferentProcessForIndexedDB
49+
"
50+
]
51+
;
52+
function
53+
testArrayBufferTransferable
54+
(
55+
scope
56+
)
57+
{
58+
var
59+
length
60+
=
61+
4
62+
;
63+
var
64+
byteLength
65+
=
66+
length
67+
*
68+
Uint8Array
69+
.
70+
BYTES_PER_ELEMENT
71+
;
72+
var
73+
ab
74+
=
75+
new
76+
ArrayBuffer
77+
(
78+
byteLength
79+
)
80+
;
81+
assertEq
82+
(
83+
ab
84+
.
85+
immutable
86+
false
87+
)
88+
;
89+
assertEq
90+
(
91+
ab
92+
.
93+
byteLength
94+
byteLength
95+
)
96+
;
97+
var
98+
ta
99+
=
100+
new
101+
Uint8Array
102+
(
103+
ab
104+
)
105+
;
106+
ta
107+
.
108+
set
109+
(
110+
[
111+
33
112+
44
113+
55
114+
66
115+
]
116+
)
117+
;
118+
var
119+
iab
120+
=
121+
ab
122+
.
123+
transferToImmutable
124+
(
125+
)
126+
;
127+
var
128+
ita
129+
=
130+
new
131+
Uint8Array
132+
(
133+
iab
134+
)
135+
;
136+
assertEq
137+
(
138+
ab
139+
.
140+
detached
141+
true
142+
)
143+
;
144+
assertEq
145+
(
146+
iab
147+
.
148+
detached
149+
false
150+
)
151+
;
152+
assertEq
153+
(
154+
ita
155+
.
156+
toString
157+
(
158+
)
159+
"
160+
33
161+
44
162+
55
163+
66
164+
"
165+
)
166+
;
167+
assertThrowsInstanceOf
168+
(
169+
(
170+
)
171+
=
172+
>
173+
serialize
174+
(
175+
iab
176+
[
177+
iab
178+
]
179+
{
180+
scope
181+
}
182+
)
183+
TypeError
184+
)
185+
;
186+
assertEq
187+
(
188+
ab
189+
.
190+
detached
191+
true
192+
)
193+
;
194+
assertEq
195+
(
196+
iab
197+
.
198+
detached
199+
false
200+
)
201+
;
202+
assertEq
203+
(
204+
ita
205+
.
206+
toString
207+
(
208+
)
209+
"
210+
33
211+
44
212+
55
213+
66
214+
"
215+
)
216+
;
217+
}
218+
scopes
219+
.
220+
forEach
221+
(
222+
testArrayBufferTransferable
223+
)
224+
;

0 commit comments

Comments
 (0)