+ it('should respond correctly to ServerFence', function () {
+ var expected_msg = {_sQ: new Uint8Array(16), _sQlen: 0, flush: function() {}};
+ var incoming_msg = {_sQ: new Uint8Array(16), _sQlen: 0, flush: function() {}};
+
+ var payload = "foo\x00ab9";
+
+ // ClientFence and ServerFence are identical in structure
+ RFB.messages.clientFence(expected_msg, (1<<0) | (1<<1), payload);
+ RFB.messages.clientFence(incoming_msg, 0xffffffff, payload);
+
+ client._sock._websocket._receive_data(incoming_msg._sQ);
+
+ expect(client._sock).to.have.sent(expected_msg._sQ);
+
+ expected_msg._sQlen = 0;
+ incoming_msg._sQlen = 0;
+
+ RFB.messages.clientFence(expected_msg, (1<<0), payload);
+ RFB.messages.clientFence(incoming_msg, (1<<0) | (1<<31), payload);
+
+ client._sock._websocket._receive_data(incoming_msg._sQ);
+
+ expect(client._sock).to.have.sent(expected_msg._sQ);
+ });
+
+ it('should enable continuous updates on first EndOfContinousUpdates', function () {
+ var expected_msg = {_sQ: new Uint8Array(10), _sQlen: 0, flush: function() {}};
+
+ RFB.messages.enableContinuousUpdates(expected_msg, true, 0, 0, 640, 20);
+
+ expect(client._enabledContinuousUpdates).to.be.false;
+
+ client._sock._websocket._receive_data(new Uint8Array([150]));
+
+ expect(client._enabledContinuousUpdates).to.be.true;
+ expect(client._sock).to.have.sent(expected_msg._sQ);
+ });
+
+ it('should disable continuous updates on subsequent EndOfContinousUpdates', function () {
+ client._enabledContinuousUpdates = true;
+ client._supportsContinuousUpdates = true;
+
+ client._sock._websocket._receive_data(new Uint8Array([150]));
+
+ expect(client._enabledContinuousUpdates).to.be.false;
+ });
+
+ it('should update continuous updates on resize', function () {
+ var expected_msg = {_sQ: new Uint8Array(10), _sQlen: 0, flush: function() {}};
+ RFB.messages.enableContinuousUpdates(expected_msg, true, 0, 0, 90, 700);
+
+ client._resize(450, 160);
+
+ expect(client._sock._websocket._get_sent_data()).to.have.length(0);
+
+ client._enabledContinuousUpdates = true;
+
+ client._resize(90, 700);
+
+ expect(client._sock).to.have.sent(expected_msg._sQ);
+ });
+