Skip to content

Commit da8d686

Browse files
authored
Avoid failing entire suites when Float16Array is undefined
Followup to #45483. #46278 and #45670 did part of this already.
1 parent d9190d3 commit da8d686

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

FileAPI/blob/Blob-constructor.any.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,14 +290,22 @@ test_blob(function() {
290290
new Int16Array([0x4150, 0x5353]),
291291
new Uint32Array([0x53534150]),
292292
new Int32Array([0x53534150]),
293-
new Float16Array([2.65625, 58.59375]),
294293
new Float32Array([0xD341500000])
295294
]);
296295
}, {
297-
expected: "PASSPASSPASSPASSPASSPASSPASSPASS",
296+
expected: "PASSPASSPASSPASSPASSPASSPASS",
298297
type: "",
299298
desc: "Passing typed arrays as elements of the blobParts array should work."
300299
});
300+
test_blob(function() {
301+
return new Blob([
302+
new Float16Array([2.65625, 58.59375])
303+
]);
304+
}, {
305+
expected: "PASS",
306+
type: "",
307+
desc: "Passing a Float16Array as element of the blobParts array should work."
308+
});
301309
test_blob(function() {
302310
return new Blob([
303311
// 0x535 3415053534150

WebCryptoAPI/getRandomValues.any.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,21 @@ test(function() {
33
assert_throws_dom("TypeMismatchError", function() {
44
self.crypto.getRandomValues(new Float16Array(6))
55
}, "Float16Array")
6+
7+
assert_throws_dom("TypeMismatchError", function() {
8+
const len = 65536 / Float16Array.BYTES_PER_ELEMENT + 1;
9+
self.crypto.getRandomValues(new Float16Array(len));
10+
}, "Float16Array (too long)")
11+
}, "Float16 arrays");
12+
13+
test(function() {
614
assert_throws_dom("TypeMismatchError", function() {
715
self.crypto.getRandomValues(new Float32Array(6))
816
}, "Float32Array")
917
assert_throws_dom("TypeMismatchError", function() {
1018
self.crypto.getRandomValues(new Float64Array(6))
1119
}, "Float64Array")
1220

13-
assert_throws_dom("TypeMismatchError", function() {
14-
const len = 65536 / Float16Array.BYTES_PER_ELEMENT + 1;
15-
self.crypto.getRandomValues(new Float16Array(len));
16-
}, "Float16Array (too long)")
1721
assert_throws_dom("TypeMismatchError", function() {
1822
const len = 65536 / Float32Array.BYTES_PER_ELEMENT + 1;
1923
self.crypto.getRandomValues(new Float32Array(len));

compression/decompression-buffersource.tentative.any.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const bufferSourceChunksForDeflate = [
4949
},
5050
{
5151
name: 'Float16Array',
52-
value: new Float16Array(new Uint8Array(compressedBytesWithDeflate).buffer)
52+
value: () => new Float16Array(new Uint8Array(compressedBytesWithDeflate).buffer)
5353
},
5454
{
5555
name: 'Float32Array',
@@ -100,7 +100,7 @@ const bufferSourceChunksForGzip = [
100100
},
101101
{
102102
name: 'Float16Array',
103-
value: new Float16Array(new Uint8Array(compressedBytesWithGzip).buffer)
103+
value: () => new Float16Array(new Uint8Array(compressedBytesWithGzip).buffer)
104104
},
105105
{
106106
name: 'Float32Array',
@@ -151,7 +151,7 @@ const bufferSourceChunksForDeflateRaw = [
151151
},
152152
{
153153
name: 'Float16Array',
154-
value: new Float16Array(new Uint8Array(compressedBytesWithDeflateRaw).buffer)
154+
value: () => new Float16Array(new Uint8Array(compressedBytesWithDeflateRaw).buffer)
155155
},
156156
{
157157
name: 'Float32Array',
@@ -172,7 +172,7 @@ for (const chunk of bufferSourceChunksForDeflate) {
172172
const ds = new DecompressionStream('deflate');
173173
const reader = ds.readable.getReader();
174174
const writer = ds.writable.getWriter();
175-
const writePromise = writer.write(chunk.value);
175+
const writePromise = writer.write(typeof chunk.value === 'function' ? chunk.value() : chunk.value);
176176
writer.close();
177177
const { value } = await reader.read();
178178
assert_array_equals(Array.from(value), deflateExpectedChunkValue, 'value should match');
@@ -184,7 +184,7 @@ for (const chunk of bufferSourceChunksForGzip) {
184184
const ds = new DecompressionStream('gzip');
185185
const reader = ds.readable.getReader();
186186
const writer = ds.writable.getWriter();
187-
const writePromise = writer.write(chunk.value);
187+
const writePromise = writer.write(typeof chunk.value === 'function' ? chunk.value() : chunk.value);
188188
writer.close();
189189
const { value } = await reader.read();
190190
assert_array_equals(Array.from(value), gzipExpectedChunkValue, 'value should match');
@@ -196,7 +196,7 @@ for (const chunk of bufferSourceChunksForDeflateRaw) {
196196
const ds = new DecompressionStream('deflate-raw');
197197
const reader = ds.readable.getReader();
198198
const writer = ds.writable.getWriter();
199-
const writePromise = writer.write(chunk.value);
199+
const writePromise = writer.write(typeof chunk.value === 'function' ? chunk.value() : chunk.value);
200200
writer.close();
201201
const { value } = await reader.read();
202202
assert_array_equals(Array.from(value), deflateRawExpectedChunkValue, 'value should match');

0 commit comments

Comments
 (0)