diff --git a/core/rfb.js b/core/rfb.js index d8e2de74..ea8dc0ff 100644 --- a/core/rfb.js +++ b/core/rfb.js @@ -1864,7 +1864,6 @@ export default class RFB extends EventTargetMixin { } }) .then(() => { - this.dispatchEvent(new CustomEvent('securityresult')); this._rfbInitState = "SecurityResult"; return true; }).finally(() => { diff --git a/tests/test.rfb.js b/tests/test.rfb.js index ef2c6491..f3939151 100644 --- a/tests/test.rfb.js +++ b/tests/test.rfb.js @@ -1631,10 +1631,20 @@ describe('Remote Frame Buffer Protocol Client', function () { client.addEventListener("credentialsrequired", (e) => { client.sendCredentials({ "password": "123456" }); clock.tick(); - }); - client.addEventListener("securityresult", (event) => { - expect(client._sock).to.have.sent(sendData); - done(); + // FIXME: We don't have a good way to know when + // the async stuff is done, so we hook in + // to this internal function that is + // called at the end + new Promise((resolve, reject) => { + sinon.stub(client._sock._websocket, "send") + .callsFake((data) => { + FakeWebSocket.prototype.send.call(client._sock._websocket, data); + resolve(); + }); + }).then(() => { + expect(client._sock).to.have.sent(sendData); + done(); + }); }); client._sock._websocket._receiveData(receiveData); });