Skip to content

Commit

Permalink
Add explicit test for copying TypedArrays
Browse files Browse the repository at this point in the history
  • Loading branch information
surma committed Mar 19, 2020
1 parent 58613a2 commit d6f2105
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module.exports = function(config) {
if (process.env.INSIDE_DOCKER) {
return ["DockerChrome"];
} else if (process.env.CHROME_ONLY) {
return ["SafariTechPreview"];
return ["ChromeHeadless"];
} else {
// Filtering SafariTechPreview because I am having
// local issues and I have no idea how to fix them.
Expand Down
23 changes: 23 additions & 0 deletions tests/same_window.comlink.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,29 @@ describe("Comlink in the same realm", function() {
expect(buffer.byteLength).to.equal(0);
});

guardedIt(isNotSafari11_1)("will copy TypedArrays", async function() {
const thing = Comlink.wrap(this.port1);
Comlink.expose(b => b, this.port2);
const array = new Uint8Array([1, 2, 3]);
const receive = await thing(array);
expect(array).to.not.equal(receive);
expect(array.byteLength).to.equal(receive.byteLength);
expect([...array]).to.deep.equal([...receive])
});

guardedIt(isNotSafari11_1)("will copy nested TypedArrays", async function() {
const thing = Comlink.wrap(this.port1);
Comlink.expose(b => b, this.port2);
const array = new Uint8Array([1, 2, 3]);
const receive = await thing({
v: 1,
array
});
expect(array).to.not.equal(receive.array);
expect(array.byteLength).to.equal(receive.array.byteLength);
expect([...array]).to.deep.equal([...receive.array])
});

guardedIt(isNotSafari11_1)(
"will transfer deeply nested buffers",
async function() {
Expand Down

0 comments on commit d6f2105

Please sign in to comment.