From 9e02f4d01d85390b565cb041ad8f6c1a033d1740 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Mon, 29 May 2023 09:33:30 +0200 Subject: [PATCH] Return a copy of the data from FakeWebSocket The caller might hang on to the data for multiple calls, so we make sure the returned buffer might not get overwritten. --- tests/fake.websocket.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fake.websocket.js b/tests/fake.websocket.js index e5a2b2d6..a929a71f 100644 --- a/tests/fake.websocket.js +++ b/tests/fake.websocket.js @@ -42,7 +42,7 @@ export default class FakeWebSocket { } _getSentData() { - const res = new Uint8Array(this._sendQueue.buffer, 0, this.bufferedAmount); + const res = this._sendQueue.slice(0, this.bufferedAmount); this.bufferedAmount = 0; return res; }