From b44b7a9a603477d3d0f9fa6cdafe18d387a36d25 Mon Sep 17 00:00:00 2001 From: crowlKats <13135287+crowlKats@users.noreply.github.com> Date: Mon, 17 Aug 2020 23:46:08 +0200 Subject: Blob.arrayBuffer returns uint8array (#7086) --- cli/rt/20_blob.js | 2 +- cli/tests/unit/blob_test.ts | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'cli') diff --git a/cli/rt/20_blob.js b/cli/rt/20_blob.js index 5b0ef349e..f7309dafb 100644 --- a/cli/rt/20_blob.js +++ b/cli/rt/20_blob.js @@ -151,7 +151,7 @@ bytes.set(chunk, offs); offs += chunk.byteLength; } - return bytes; + return bytes.buffer; } else { throw new TypeError("Invalid reader result."); } diff --git a/cli/tests/unit/blob_test.ts b/cli/tests/unit/blob_test.ts index 79e6f1f8f..494c2ac75 100644 --- a/cli/tests/unit/blob_test.ts +++ b/cli/tests/unit/blob_test.ts @@ -91,6 +91,12 @@ unitTest(async function blobStream(): Promise { assertEquals(decode(bytes), "Hello World"); }); +unitTest(async function blobArrayBuffer(): Promise { + const uint = new Uint8Array([102, 111, 111]); + const blob = new Blob([uint]); + assertEquals(await blob.arrayBuffer(), uint.buffer); +}); + unitTest(function blobConstructorNameIsBlob(): void { const blob = new Blob(); assertEquals(blob.constructor.name, "Blob"); -- cgit v1.2.3