Skip to content

Commit

Permalink
Bug 1623954 [wpt PR 22361] - Encoding: use Wasm to get a SharedArrayB…
Browse files Browse the repository at this point in the history
…uffer instance, a=testonly

Automatic update from web-platform-tests
Encoding: use Wasm to get a SharedArrayBuffer instance

For web-platform-tests/wpt#22358.
--

wpt-commits: 4e83bff9e071561dd10538dda073cd2f43b68e4a
wpt-pr: 22361

UltraBlame original commit: 401be49e000042c8161bbfc88ff20d8a493cb970
  • Loading branch information
marco-c committed Apr 1, 2020
1 parent 1397426 commit de9a7df
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 40 deletions.
105 changes: 105 additions & 0 deletions testing/web-platform/tests/common/sab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
const
createBuffer
=
(
(
)
=
>
{
const
sabConstructor
=
new
WebAssembly
.
Memory
(
{
shared
:
true
initial
:
0
maximum
:
0
}
)
.
buffer
.
constructor
;
return
(
type
length
)
=
>
{
if
(
type
=
=
=
"
ArrayBuffer
"
)
{
return
new
ArrayBuffer
(
length
)
;
}
else
if
(
type
=
=
=
"
SharedArrayBuffer
"
)
{
return
new
sabConstructor
(
length
)
;
}
else
{
throw
new
Error
(
"
type
has
to
be
ArrayBuffer
or
SharedArrayBuffer
"
)
;
}
}
}
)
(
)
;
37 changes: 22 additions & 15 deletions testing/web-platform/tests/encoding/encodeInto.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,37 +366,46 @@ destinationLength
destinationData
.
bufferIncrease
;
const
destinationOffset
=
destinationData
.
destinationOffset
;
const
destinationLength
=
testData
.
destinationLength
;
const
destinationFiller
=
destinationData
.
filler
;
const
encoder
=
new
TextEncoder
(
)
;
const
buffer
=
new
self
[
arrayBufferOrSharedArrayBuffer
]
createBuffer
(
arrayBufferOrSharedArrayBuffer
bufferLength
)
;
const
view
=
new
Expand All @@ -406,13 +415,17 @@ buffer
destinationOffset
destinationLength
)
;
const
fullView
=
new
Uint8Array
(
buffer
)
;
const
control
=
new
Expand Down Expand Up @@ -719,12 +732,9 @@ encodeInto
new
view
(
new
self
[
arrayBufferOrSharedArrayBuffer
]
createBuffer
(
arrayBufferOrSharedArrayBuffer
0
)
)
Expand Down Expand Up @@ -800,12 +810,9 @@ encodeInto
(
"
"
new
self
[
arrayBufferOrSharedArrayBuffer
]
createBuffer
(
arrayBufferOrSharedArrayBuffer
10
)
)
Expand Down
15 changes: 5 additions & 10 deletions testing/web-platform/tests/encoding/streams/decode-utf8.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,16 @@ inputChunkData
109
115
]
;
const
emptyChunk
=
new
Uint8Array
(
new
self
[
arrayBufferOrSharedArrayBuffer
]
createBuffer
(
arrayBufferOrSharedArrayBuffer
0
)
)
Expand All @@ -61,12 +59,9 @@ inputChunk
new
Uint8Array
(
new
self
[
arrayBufferOrSharedArrayBuffer
]
createBuffer
(
arrayBufferOrSharedArrayBuffer
inputChunkData
.
length
Expand Down
22 changes: 12 additions & 10 deletions testing/web-platform/tests/encoding/textdecoder-copy.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,40 @@ test
const
buf
=
new
self
[
arrayBufferOrSharedArrayBuffer
]
createBuffer
(
arrayBufferOrSharedArrayBuffer
2
)
;
const
view
=
new
Uint8Array
(
buf
)
;
const
buf2
=
new
self
[
arrayBufferOrSharedArrayBuffer
]
createBuffer
(
arrayBufferOrSharedArrayBuffer
2
)
;
const
view2
=
new
Uint8Array
(
buf2
)
;
const
decoder
=
new
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,12 +302,9 @@ uintArray
new
Uint8Array
(
new
self
[
arrayBufferOrSharedArrayBuffer
]
createBuffer
(
arrayBufferOrSharedArrayBuffer
sub
.
length
Expand Down

0 comments on commit de9a7df

Please sign in to comment.