Merge f3b8732771 into 24231f1ae3
This commit is contained in:
commit
6ec924878b
|
|
@ -312,6 +312,9 @@ RFB.prototype = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
get connectionState() { return this._rfb_connection_state; },
|
||||||
|
set connectionState(val) { Log.Error("Cannot assign value " + val + " to get-only property connectionState"); },
|
||||||
|
|
||||||
// ===== PUBLIC METHODS =====
|
// ===== PUBLIC METHODS =====
|
||||||
|
|
||||||
disconnect: function () {
|
disconnect: function () {
|
||||||
|
|
@ -646,6 +649,8 @@ RFB.prototype = {
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case 'connecting':
|
case 'connecting':
|
||||||
|
var event = new CustomEvent("connecting", { detail: {} });
|
||||||
|
this.dispatchEvent(event);
|
||||||
this._connect();
|
this._connect();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -823,6 +823,23 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
||||||
this.clock.tick();
|
this.clock.tick();
|
||||||
expect(client._sock.open).to.have.been.calledOnce;
|
expect(client._sock.open).to.have.been.calledOnce;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should result in a connecting event if state is updated to connecting through the correct function', function () {
|
||||||
|
var client = make_rfb();
|
||||||
|
var spy = sinon.spy();
|
||||||
|
client.addEventListener("connecting", spy);
|
||||||
|
client._rfb_connection_state = '';
|
||||||
|
client._updateConnectionState('connecting');
|
||||||
|
expect(spy).to.have.been.calledOnce;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not result in a connecting event if state is updated to connecting via direct assignment', function () {
|
||||||
|
var client = make_rfb();
|
||||||
|
var spy = sinon.spy();
|
||||||
|
client.addEventListener("connecting", spy);
|
||||||
|
client._rfb_connection_state = 'connecting';
|
||||||
|
expect(spy).to.not.have.been.called;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('connected', function () {
|
describe('connected', function () {
|
||||||
|
|
@ -912,6 +929,27 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
||||||
expect(spy.args[0].length).to.equal(1);
|
expect(spy.args[0].length).to.equal(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('connectionState getter', function () {
|
||||||
|
var client;
|
||||||
|
beforeEach(function () {
|
||||||
|
client = new RFB(document.createElement('div'), 'ws://HOST:8675/PATH');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should get the internal connection state', function () {
|
||||||
|
client._rfb_connection_state = 'connecting';
|
||||||
|
client._updateConnectionState('connected');
|
||||||
|
var state = client.connectionState;
|
||||||
|
expect(state).to.equal('connected');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should disallow manually changing the state', function () {
|
||||||
|
client._rfb_connection_state = 'connecting';
|
||||||
|
client.connectionState = 'connected';
|
||||||
|
var state = client.connectionState;
|
||||||
|
expect(state).to.equal('connecting');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Protocol Initialization States', function () {
|
describe('Protocol Initialization States', function () {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue