Skip to content

Commit

Permalink
Avoid failing entire suites when Float16Array is undefined
Browse files Browse the repository at this point in the history
Followup to #45483.

#46278 and #45670 did part of this already.
  • Loading branch information
bakkot authored and sadym-chromium committed Jul 18, 2024
1 parent fc64a9a commit 794a3ae
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
12 changes: 10 additions & 2 deletions FileAPI/blob/Blob-constructor.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,14 +290,22 @@ test_blob(function() {
new Int16Array([0x4150, 0x5353]),
new Uint32Array([0x53534150]),
new Int32Array([0x53534150]),
new Float16Array([2.65625, 58.59375]),
new Float32Array([0xD341500000])
]);
}, {
expected: "PASSPASSPASSPASSPASSPASSPASSPASS",
expected: "PASSPASSPASSPASSPASSPASSPASS",
type: "",
desc: "Passing typed arrays as elements of the blobParts array should work."
});
test_blob(function() {
return new Blob([
new Float16Array([2.65625, 58.59375])
]);
}, {
expected: "PASS",
type: "",
desc: "Passing a Float16Array as element of the blobParts array should work."
});
test_blob(function() {
return new Blob([
// 0x535 3415053534150
Expand Down
12 changes: 8 additions & 4 deletions WebCryptoAPI/getRandomValues.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@ test(function() {
assert_throws_dom("TypeMismatchError", function() {
self.crypto.getRandomValues(new Float16Array(6))
}, "Float16Array")

assert_throws_dom("TypeMismatchError", function() {
const len = 65536 / Float16Array.BYTES_PER_ELEMENT + 1;
self.crypto.getRandomValues(new Float16Array(len));
}, "Float16Array (too long)")
}, "Float16 arrays");

test(function() {
assert_throws_dom("TypeMismatchError", function() {
self.crypto.getRandomValues(new Float32Array(6))
}, "Float32Array")
assert_throws_dom("TypeMismatchError", function() {
self.crypto.getRandomValues(new Float64Array(6))
}, "Float64Array")

assert_throws_dom("TypeMismatchError", function() {
const len = 65536 / Float16Array.BYTES_PER_ELEMENT + 1;
self.crypto.getRandomValues(new Float16Array(len));
}, "Float16Array (too long)")
assert_throws_dom("TypeMismatchError", function() {
const len = 65536 / Float32Array.BYTES_PER_ELEMENT + 1;
self.crypto.getRandomValues(new Float32Array(len));
Expand Down
12 changes: 6 additions & 6 deletions compression/decompression-buffersource.tentative.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const bufferSourceChunksForDeflate = [
},
{
name: 'Float16Array',
value: new Float16Array(new Uint8Array(compressedBytesWithDeflate).buffer)
value: () => new Float16Array(new Uint8Array(compressedBytesWithDeflate).buffer)
},
{
name: 'Float32Array',
Expand Down Expand Up @@ -100,7 +100,7 @@ const bufferSourceChunksForGzip = [
},
{
name: 'Float16Array',
value: new Float16Array(new Uint8Array(compressedBytesWithGzip).buffer)
value: () => new Float16Array(new Uint8Array(compressedBytesWithGzip).buffer)
},
{
name: 'Float32Array',
Expand Down Expand Up @@ -151,7 +151,7 @@ const bufferSourceChunksForDeflateRaw = [
},
{
name: 'Float16Array',
value: new Float16Array(new Uint8Array(compressedBytesWithDeflateRaw).buffer)
value: () => new Float16Array(new Uint8Array(compressedBytesWithDeflateRaw).buffer)
},
{
name: 'Float32Array',
Expand All @@ -172,7 +172,7 @@ for (const chunk of bufferSourceChunksForDeflate) {
const ds = new DecompressionStream('deflate');
const reader = ds.readable.getReader();
const writer = ds.writable.getWriter();
const writePromise = writer.write(chunk.value);
const writePromise = writer.write(typeof chunk.value === 'function' ? chunk.value() : chunk.value);
writer.close();
const { value } = await reader.read();
assert_array_equals(Array.from(value), deflateExpectedChunkValue, 'value should match');
Expand All @@ -184,7 +184,7 @@ for (const chunk of bufferSourceChunksForGzip) {
const ds = new DecompressionStream('gzip');
const reader = ds.readable.getReader();
const writer = ds.writable.getWriter();
const writePromise = writer.write(chunk.value);
const writePromise = writer.write(typeof chunk.value === 'function' ? chunk.value() : chunk.value);
writer.close();
const { value } = await reader.read();
assert_array_equals(Array.from(value), gzipExpectedChunkValue, 'value should match');
Expand All @@ -196,7 +196,7 @@ for (const chunk of bufferSourceChunksForDeflateRaw) {
const ds = new DecompressionStream('deflate-raw');
const reader = ds.readable.getReader();
const writer = ds.writable.getWriter();
const writePromise = writer.write(chunk.value);
const writePromise = writer.write(typeof chunk.value === 'function' ? chunk.value() : chunk.value);
writer.close();
const { value } = await reader.read();
assert_array_equals(Array.from(value), deflateRawExpectedChunkValue, 'value should match');
Expand Down

0 comments on commit 794a3ae

Please sign in to comment.