From 4c0d76d24db064b9468d08f23908e23e9d233c99 Mon Sep 17 00:00:00 2001 From: Abhay Agarwal Date: Thu, 15 Oct 2026 18:14:09 +0200 Subject: [PATCH] test: handle host endianness in FileAPI Blob WPT tests --- .../wpt/FileAPI/blob/Blob-constructor.any.js | 19 +++++++++++-------- test/wpt/status/FileAPI/blob.cjs | 14 +------------- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/test/fixtures/wpt/FileAPI/blob/Blob-constructor.any.js b/test/fixtures/wpt/FileAPI/blob/Blob-constructor.any.js index 03155b99cb20..bdcc19416003 100644 --- a/test/fixtures/wpt/FileAPI/blob/Blob-constructor.any.js +++ b/test/fixtures/wpt/FileAPI/blob/Blob-constructor.any.js @@ -335,6 +335,8 @@ test_blob(function() { desc: "ArrayBuffer elements of the blobParts array should be supported." }); +var isLittleEndian = new Uint8Array(new Uint16Array([1]).buffer)[0] === 1; + test_blob(function() { return new Blob([ new Uint8Array([0x50, 0x41, 0x53, 0x53]), @@ -346,7 +348,7 @@ test_blob(function() { new Float32Array([0xD341500000]) ]); }, { - expected: "PASSPASSPASSPASSPASSPASSPASS", + expected: isLittleEndian ? "PASSPASSPASSPASSPASSPASSPASS" : "PASSPASSAPSSAPSSSSAPSSAPSSAP", type: "", desc: "Passing typed arrays as elements of the blobParts array should work." }); @@ -355,20 +357,20 @@ test_blob(function() { new Float16Array([2.65625, 58.59375]) ]); }, { - expected: "PASS", + expected: isLittleEndian ? "PASS" : "APSS", type: "", desc: "Passing a Float16Array as element of the blobParts array should work." }); test_blob(function() { + // 0x535 3415053534150 + // 0x535 = 0b010100110101 -> Sign = +, Exponent = 1333 - 1023 = 310 + // 0x13415053534150 * 2**(-52) + // ==> 0x13415053534150 * 2**258 = 2510297372767036725005267563121821874921913208671273727396467555337665343087229079989707079680 return new Blob([ - // 0x535 3415053534150 - // 0x535 = 0b010100110101 -> Sign = +, Exponent = 1333 - 1023 = 310 - // 0x13415053534150 * 2**(-52) - // ==> 0x13415053534150 * 2**258 = 2510297372767036725005267563121821874921913208671273727396467555337665343087229079989707079680 new Float64Array([2510297372767036725005267563121821874921913208671273727396467555337665343087229079989707079680]) ]); }, { - expected: "PASSPASS", + expected: isLittleEndian ? "PASSPASS" : "SSAPSSAP", type: "", desc: "Passing a Float64Array as element of the blobParts array should work." }); @@ -379,7 +381,7 @@ test_blob(function() { new BigUint64Array([BigInt("0x5353415053534150")]) ]); }, { - expected: "PASSPASSPASSPASS", + expected: isLittleEndian ? "PASSPASSPASSPASS" : "SSAPSSAPSSAPSSAP", type: "", desc: "Passing BigInt typed arrays as elements of the blobParts array should work." }); @@ -528,3 +530,4 @@ type_tests.forEach(function(t) { assert_equals(b.type, t[2]); }, "Blob with type " + format_value(t[1])); }); + diff --git a/test/wpt/status/FileAPI/blob.cjs b/test/wpt/status/FileAPI/blob.cjs index c59516ca1dc5..730e8a2b59b8 100644 --- a/test/wpt/status/FileAPI/blob.cjs +++ b/test/wpt/status/FileAPI/blob.cjs @@ -23,17 +23,5 @@ module.exports = { 'Blob-constructor-dom.window.js': { skip: 'Depends on DOM API', }, - ...(os.endianness() === 'BE' ? { - 'Blob-constructor.any.js': { - fail: { - note: 'The expected bytes assume a little-endian platform', - expected: [ - 'Passing typed arrays as elements of the blobParts array should work.', - 'Passing a Float16Array as element of the blobParts array should work.', - 'Passing a Float64Array as element of the blobParts array should work.', - 'Passing BigInt typed arrays as elements of the blobParts array should work.', - ], - }, - }, - } : {}), }; +