Skip to content

Commit

Permalink
test passing buffer directly and detached buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
annevk authored and foolip committed Dec 19, 2018
1 parent 965e225 commit 60bfa1e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions encoding/encodeInto.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,17 @@
assert_throws(new TypeError(), () => new TextEncoder().encodeInto("", new view(new ArrayBuffer(0))));
}, "Invalid encodeInto() destination: " + view);
});

test(() => {
assert_throws(new TypeError(), () => new TextEncoder().encodeInto("", new ArrayBuffer(10)));
}, "Invalid encodeInto() destination: ArrayBuffer");

test(() => {
const buffer = new ArrayBuffer(10),
view = new Uint8Array(buffer);
const { read, written } = new TextEncoder().encodeInto("", view);
assert_equals(read, 0);
assert_equals(written, 0);
self.postMessage(buffer, "/", [buffer]);
assert_throws(new TypeError(), () => new TextEncoder().encodeInto("", view));
}, "encodeInto() cannot operate on a detached buffer");

0 comments on commit 60bfa1e

Please sign in to comment.