Add some explanatory comments to test.rfb.js

This commit is contained in:
Samuel Mannehed 2021-12-10 00:40:59 +01:00
parent a78a7bf8aa
commit a7b96087d7
1 changed files with 10 additions and 3 deletions

View File

@ -74,6 +74,9 @@ describe('Remote Frame Buffer Protocol Client', function () {
let fakeResizeObserver = null; let fakeResizeObserver = null;
const realObserver = window.ResizeObserver; const realObserver = window.ResizeObserver;
// Since we are using fake timers we don't actually want
// to wait for the browser to observe the size change,
// that's why we use a fake ResizeObserver
class FakeResizeObserver { class FakeResizeObserver {
constructor(handler) { constructor(handler) {
this.fire = handler; this.fire = handler;
@ -783,14 +786,18 @@ describe('Remote Frame Buffer Protocol Client', function () {
0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04,
0x00, 0x00, 0x00, 0x00 ]; 0x00, 0x00, 0x00, 0x00 ];
// First message should trigger a resize // This property is indirectly used as a marker for the first update
client._supportsSetDesktopSize = false; client._supportsSetDesktopSize = false;
// First message should trigger a resize
client._sock._websocket._receiveData(new Uint8Array(incoming)); client._sock._websocket._receiveData(new Uint8Array(incoming));
// It should match the current size of the container,
// not the reported size from the server
expect(RFB.messages.setDesktopSize).to.have.been.calledOnce; expect(RFB.messages.setDesktopSize).to.have.been.calledOnce;
expect(RFB.messages.setDesktopSize).to.have.been.calledWith(sinon.match.object, 70, 80, 0, 0); expect(RFB.messages.setDesktopSize).to.have.been.calledWith(
sinon.match.object, 70, 80, 0, 0);
RFB.messages.setDesktopSize.resetHistory(); RFB.messages.setDesktopSize.resetHistory();