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.
This commit is contained in:
Pierre Ossman 2023-05-29 09:33:30 +02:00
parent 9c7576a587
commit 9e02f4d01d
1 changed files with 1 additions and 1 deletions

View File

@ -42,7 +42,7 @@ export default class FakeWebSocket {
} }
_getSentData() { _getSentData() {
const res = new Uint8Array(this._sendQueue.buffer, 0, this.bufferedAmount); const res = this._sendQueue.slice(0, this.bufferedAmount);
this.bufferedAmount = 0; this.bufferedAmount = 0;
return res; return res;
} }