From de9a7df4ed7e360dd9b35f1139dd7306cba9f72f Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Wed, 1 Apr 2020 13:19:57 +0000 Subject: [PATCH] Bug 1623954 [wpt PR 22361] - Encoding: use Wasm to get a SharedArrayBuffer instance, a=testonly Automatic update from web-platform-tests Encoding: use Wasm to get a SharedArrayBuffer instance For https://github.com/web-platform-tests/wpt/issues/22358. -- wpt-commits: 4e83bff9e071561dd10538dda073cd2f43b68e4a wpt-pr: 22361 UltraBlame original commit: 401be49e000042c8161bbfc88ff20d8a493cb970 --- testing/web-platform/tests/common/sab.js | 105 ++++++++++++++++++ .../tests/encoding/encodeInto.any.js | 37 +++--- .../tests/encoding/streams/decode-utf8.any.js | 15 +-- .../tests/encoding/textdecoder-copy.any.js | 22 ++-- .../encoding/textdecoder-streaming.any.js | 7 +- 5 files changed, 146 insertions(+), 40 deletions(-) create mode 100644 testing/web-platform/tests/common/sab.js diff --git a/testing/web-platform/tests/common/sab.js b/testing/web-platform/tests/common/sab.js new file mode 100644 index 0000000000000..ff8a86b77691d --- /dev/null +++ b/testing/web-platform/tests/common/sab.js @@ -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 +" +) +; +} +} +} +) +( +) +; diff --git a/testing/web-platform/tests/encoding/encodeInto.any.js b/testing/web-platform/tests/encoding/encodeInto.any.js index c69a62d0ec962..a2e2c61d2b8b6 100644 --- a/testing/web-platform/tests/encoding/encodeInto.any.js +++ b/testing/web-platform/tests/encoding/encodeInto.any.js @@ -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 @@ -406,6 +415,8 @@ buffer destinationOffset destinationLength ) +; +const fullView = new @@ -413,6 +424,8 @@ Uint8Array ( buffer ) +; +const control = new @@ -719,12 +732,9 @@ encodeInto new view ( -new -self -[ -arrayBufferOrSharedArrayBuffer -] +createBuffer ( +arrayBufferOrSharedArrayBuffer 0 ) ) @@ -800,12 +810,9 @@ encodeInto ( " " -new -self -[ -arrayBufferOrSharedArrayBuffer -] +createBuffer ( +arrayBufferOrSharedArrayBuffer 10 ) ) diff --git a/testing/web-platform/tests/encoding/streams/decode-utf8.any.js b/testing/web-platform/tests/encoding/streams/decode-utf8.any.js index 8ad78e4640e37..dfbe0dcc607ef 100644 --- a/testing/web-platform/tests/encoding/streams/decode-utf8.any.js +++ b/testing/web-platform/tests/encoding/streams/decode-utf8.any.js @@ -39,18 +39,16 @@ inputChunkData 109 115 ] +; const emptyChunk = new Uint8Array ( -new -self -[ -arrayBufferOrSharedArrayBuffer -] +createBuffer ( +arrayBufferOrSharedArrayBuffer 0 ) ) @@ -61,12 +59,9 @@ inputChunk new Uint8Array ( -new -self -[ -arrayBufferOrSharedArrayBuffer -] +createBuffer ( +arrayBufferOrSharedArrayBuffer inputChunkData . length diff --git a/testing/web-platform/tests/encoding/textdecoder-copy.any.js b/testing/web-platform/tests/encoding/textdecoder-copy.any.js index 17c3738768635..b4d5231013059 100644 --- a/testing/web-platform/tests/encoding/textdecoder-copy.any.js +++ b/testing/web-platform/tests/encoding/textdecoder-copy.any.js @@ -23,14 +23,13 @@ test const buf = -new -self -[ -arrayBufferOrSharedArrayBuffer -] +createBuffer ( +arrayBufferOrSharedArrayBuffer 2 ) +; +const view = new @@ -38,16 +37,17 @@ Uint8Array ( buf ) +; +const buf2 = -new -self -[ -arrayBufferOrSharedArrayBuffer -] +createBuffer ( +arrayBufferOrSharedArrayBuffer 2 ) +; +const view2 = new @@ -55,6 +55,8 @@ Uint8Array ( buf2 ) +; +const decoder = new diff --git a/testing/web-platform/tests/encoding/textdecoder-streaming.any.js b/testing/web-platform/tests/encoding/textdecoder-streaming.any.js index 4a580fac25fa1..da157957a0123 100644 --- a/testing/web-platform/tests/encoding/textdecoder-streaming.any.js +++ b/testing/web-platform/tests/encoding/textdecoder-streaming.any.js @@ -302,12 +302,9 @@ uintArray new Uint8Array ( -new -self -[ -arrayBufferOrSharedArrayBuffer -] +createBuffer ( +arrayBufferOrSharedArrayBuffer sub . length