From 588d7d8381b845711854d224e717905da638e78e Mon Sep 17 00:00:00 2001 From: PekingSpades <180665176+PekingSpades@users.noreply.github.com> Date: Sat, 13 Dec 2025 11:51:13 +0800 Subject: [PATCH] Fix tests to rebuild Websock DataView when swapping buffers --- tests/test.rfb.js | 1 + tests/test.websock.js | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/tests/test.rfb.js b/tests/test.rfb.js index 7aa54cd0..d8aa5e32 100644 --- a/tests/test.rfb.js +++ b/tests/test.rfb.js @@ -107,6 +107,7 @@ describe('Remote Frame Buffer protocol client', function () { Websock.prototype._allocateBuffers = function () { this._sQ = _sQ; this._rQ = rQ; + this._rQdv = new DataView(this._rQ.buffer); }; // Avoiding printing the entire Websock buffer on errors diff --git a/tests/test.websock.js b/tests/test.websock.js index 110e6ad0..58036dde 100644 --- a/tests/test.websock.js +++ b/tests/test.websock.js @@ -580,6 +580,7 @@ describe('Websock', function () { it('should compact the receive queue when fully read', function () { sock._rQ = new Uint8Array([0, 1, 2, 3, 4, 5, 0, 0, 0, 0]); + sock._rQdv = new DataView(sock._rQ.buffer); sock._rQlen = 6; sock._rQi = 6; const msg = { data: new Uint8Array([1, 2, 3]).buffer }; @@ -590,6 +591,7 @@ describe('Websock', function () { it('should compact the receive queue when we reach the end of the buffer', function () { sock._rQ = new Uint8Array(20); + sock._rQdv = new DataView(sock._rQ.buffer); sock._rQbufferSize = 20; sock._rQlen = 20; sock._rQi = 10; @@ -601,6 +603,7 @@ describe('Websock', function () { it('should automatically resize the receive queue if the incoming message is larger than the buffer', function () { sock._rQ = new Uint8Array(20); + sock._rQdv = new DataView(sock._rQ.buffer); sock._rQlen = 0; sock._rQi = 0; sock._rQbufferSize = 20; @@ -613,6 +616,7 @@ describe('Websock', function () { it('should automatically resize the receive queue if the incoming message is larger than 1/8th of the buffer and we reach the end of the buffer', function () { sock._rQ = new Uint8Array(20); + sock._rQdv = new DataView(sock._rQ.buffer); sock._rQlen = 16; sock._rQi = 15; sock._rQbufferSize = 20;