diff options
author | Pierre Ossman <ossman@cendio.se> | 2021-04-18 13:53:43 +0200 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2021-04-18 14:26:28 +0200 |
commit | 9376191fc4500b9001bc0dc3ff9f0e0351797319 (patch) | |
tree | 2b77c27a764e34138bec8f1f20155b7d93cbe81f /tests | |
parent | b7b7e4e26b1f93f56471419f5b6ca5069fd1e4b2 (diff) | |
download | novnc-9376191fc4500b9001bc0dc3ff9f0e0351797319.tar.gz |
Refuse to use already closed WebSocket objects
We can't do anything useful with them anyway.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test.rfb.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/test.rfb.js b/tests/test.rfb.js index 5a1b713..2c112f3 100644 --- a/tests/test.rfb.js +++ b/tests/test.rfb.js @@ -183,6 +183,17 @@ describe('Remote Frame Buffer Protocol Client', function () { expect(attach).to.have.been.calledOnceWithExactly(sock); }); + it('should refuse closed WebSocket/RTCDataChannel objects', function () { + let sock = new FakeWebSocket('ws://HOST:8675/PATH', []); + sock.readyState = WebSocket.CLOSED; + const client = new RFB(document.createElement('div'), sock); + let callback = sinon.spy(); + client.addEventListener('disconnect', callback); + this.clock.tick(); + expect(callback).to.have.been.calledOnce; + expect(callback.args[0][0].detail.clean).to.be.false; + }); + it('should report attach problems via event', function () { attach.restore(); attach = sinon.stub(Websock.prototype, 'attach'); |