mirror of
https://github.com/kasmtech/KasmVNC.git
synced 2024-11-23 00:23:13 +01:00
Standardize on camelCase in tests
This commit is contained in:
parent
59f5648592
commit
da228af778
@ -1,32 +1,32 @@
|
|||||||
// noVNC specific assertions
|
// noVNC specific assertions
|
||||||
chai.use(function (_chai, utils) {
|
chai.use(function (_chai, utils) {
|
||||||
_chai.Assertion.addMethod('displayed', function (target_data) {
|
_chai.Assertion.addMethod('displayed', function (targetData) {
|
||||||
const obj = this._obj;
|
const obj = this._obj;
|
||||||
const ctx = obj._target.getContext('2d');
|
const ctx = obj._target.getContext('2d');
|
||||||
const data_cl = ctx.getImageData(0, 0, obj._target.width, obj._target.height).data;
|
const dataCl = ctx.getImageData(0, 0, obj._target.width, obj._target.height).data;
|
||||||
// NB(directxman12): PhantomJS 1.x doesn't implement Uint8ClampedArray, so work around that
|
// NB(directxman12): PhantomJS 1.x doesn't implement Uint8ClampedArray, so work around that
|
||||||
const data = new Uint8Array(data_cl);
|
const data = new Uint8Array(dataCl);
|
||||||
const len = data_cl.length;
|
const len = dataCl.length;
|
||||||
new chai.Assertion(len).to.be.equal(target_data.length, "unexpected display size");
|
new chai.Assertion(len).to.be.equal(targetData.length, "unexpected display size");
|
||||||
let same = true;
|
let same = true;
|
||||||
for (let i = 0; i < len; i++) {
|
for (let i = 0; i < len; i++) {
|
||||||
if (data[i] != target_data[i]) {
|
if (data[i] != targetData[i]) {
|
||||||
same = false;
|
same = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!same) {
|
if (!same) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log("expected data: %o, actual data: %o", target_data, data);
|
console.log("expected data: %o, actual data: %o", targetData, data);
|
||||||
}
|
}
|
||||||
this.assert(same,
|
this.assert(same,
|
||||||
"expected #{this} to have displayed the image #{exp}, but instead it displayed #{act}",
|
"expected #{this} to have displayed the image #{exp}, but instead it displayed #{act}",
|
||||||
"expected #{this} not to have displayed the image #{act}",
|
"expected #{this} not to have displayed the image #{act}",
|
||||||
target_data,
|
targetData,
|
||||||
data);
|
data);
|
||||||
});
|
});
|
||||||
|
|
||||||
_chai.Assertion.addMethod('sent', function (target_data) {
|
_chai.Assertion.addMethod('sent', function (targetData) {
|
||||||
const obj = this._obj;
|
const obj = this._obj;
|
||||||
obj.inspect = () => {
|
obj.inspect = () => {
|
||||||
const res = { _websocket: obj._websocket, rQi: obj._rQi, _rQ: new Uint8Array(obj._rQ.buffer, 0, obj._rQlen),
|
const res = { _websocket: obj._websocket, rQi: obj._rQi, _rQ: new Uint8Array(obj._rQ.buffer, 0, obj._rQlen),
|
||||||
@ -34,13 +34,13 @@ chai.use(function (_chai, utils) {
|
|||||||
res.prototype = obj;
|
res.prototype = obj;
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
const data = obj._websocket._get_sent_data();
|
const data = obj._websocket._getSentData();
|
||||||
let same = true;
|
let same = true;
|
||||||
if (data.length != target_data.length) {
|
if (data.length != targetData.length) {
|
||||||
same = false;
|
same = false;
|
||||||
} else {
|
} else {
|
||||||
for (let i = 0; i < data.length; i++) {
|
for (let i = 0; i < data.length; i++) {
|
||||||
if (data[i] != target_data[i]) {
|
if (data[i] != targetData[i]) {
|
||||||
same = false;
|
same = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -48,12 +48,12 @@ chai.use(function (_chai, utils) {
|
|||||||
}
|
}
|
||||||
if (!same) {
|
if (!same) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log("expected data: %o, actual data: %o", target_data, data);
|
console.log("expected data: %o, actual data: %o", targetData, data);
|
||||||
}
|
}
|
||||||
this.assert(same,
|
this.assert(same,
|
||||||
"expected #{this} to have sent the data #{exp}, but it actually sent #{act}",
|
"expected #{this} to have sent the data #{exp}, but it actually sent #{act}",
|
||||||
"expected #{this} not to have sent the data #{act}",
|
"expected #{this} not to have sent the data #{act}",
|
||||||
Array.prototype.slice.call(target_data),
|
Array.prototype.slice.call(targetData),
|
||||||
Array.prototype.slice.call(data));
|
Array.prototype.slice.call(data));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import Base64 from '../core/base64.js';
|
import Base64 from '../core/base64.js';
|
||||||
|
|
||||||
// PhantomJS can't create Event objects directly, so we need to use this
|
// PhantomJS can't create Event objects directly, so we need to use this
|
||||||
function make_event(name, props) {
|
function makeEvent(name, props) {
|
||||||
const evt = document.createEvent('Event');
|
const evt = document.createEvent('Event');
|
||||||
evt.initEvent(name, true, true);
|
evt.initEvent(name, true, true);
|
||||||
if (props) {
|
if (props) {
|
||||||
@ -24,18 +24,18 @@ export default class FakeWebSocket {
|
|||||||
this.protocol = protocols[0];
|
this.protocol = protocols[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
this._send_queue = new Uint8Array(20000);
|
this._sendQueue = new Uint8Array(20000);
|
||||||
|
|
||||||
this.readyState = FakeWebSocket.CONNECTING;
|
this.readyState = FakeWebSocket.CONNECTING;
|
||||||
this.bufferedAmount = 0;
|
this.bufferedAmount = 0;
|
||||||
|
|
||||||
this.__is_fake = true;
|
this._isFake = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
close(code, reason) {
|
close(code, reason) {
|
||||||
this.readyState = FakeWebSocket.CLOSED;
|
this.readyState = FakeWebSocket.CLOSED;
|
||||||
if (this.onclose) {
|
if (this.onclose) {
|
||||||
this.onclose(make_event("close", { 'code': code, 'reason': reason, 'wasClean': true }));
|
this.onclose(makeEvent("close", { 'code': code, 'reason': reason, 'wasClean': true }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,12 +45,12 @@ export default class FakeWebSocket {
|
|||||||
} else {
|
} else {
|
||||||
data = new Uint8Array(data);
|
data = new Uint8Array(data);
|
||||||
}
|
}
|
||||||
this._send_queue.set(data, this.bufferedAmount);
|
this._sendQueue.set(data, this.bufferedAmount);
|
||||||
this.bufferedAmount += data.length;
|
this.bufferedAmount += data.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
_get_sent_data() {
|
_getSentData() {
|
||||||
const res = new Uint8Array(this._send_queue.buffer, 0, this.bufferedAmount);
|
const res = new Uint8Array(this._sendQueue.buffer, 0, this.bufferedAmount);
|
||||||
this.bufferedAmount = 0;
|
this.bufferedAmount = 0;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -58,16 +58,16 @@ export default class FakeWebSocket {
|
|||||||
_open() {
|
_open() {
|
||||||
this.readyState = FakeWebSocket.OPEN;
|
this.readyState = FakeWebSocket.OPEN;
|
||||||
if (this.onopen) {
|
if (this.onopen) {
|
||||||
this.onopen(make_event('open'));
|
this.onopen(makeEvent('open'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_receive_data(data) {
|
_receiveData(data) {
|
||||||
// Break apart the data to expose bugs where we assume data is
|
// Break apart the data to expose bugs where we assume data is
|
||||||
// neatly packaged
|
// neatly packaged
|
||||||
for (let i = 0;i < data.length;i++) {
|
for (let i = 0;i < data.length;i++) {
|
||||||
let buf = data.subarray(i, i+1);
|
let buf = data.subarray(i, i+1);
|
||||||
this.onmessage(make_event("message", { 'data': buf }));
|
this.onmessage(makeEvent("message", { 'data': buf }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -77,20 +77,20 @@ FakeWebSocket.CONNECTING = WebSocket.CONNECTING;
|
|||||||
FakeWebSocket.CLOSING = WebSocket.CLOSING;
|
FakeWebSocket.CLOSING = WebSocket.CLOSING;
|
||||||
FakeWebSocket.CLOSED = WebSocket.CLOSED;
|
FakeWebSocket.CLOSED = WebSocket.CLOSED;
|
||||||
|
|
||||||
FakeWebSocket.__is_fake = true;
|
FakeWebSocket._isFake = true;
|
||||||
|
|
||||||
FakeWebSocket.replace = () => {
|
FakeWebSocket.replace = () => {
|
||||||
if (!WebSocket.__is_fake) {
|
if (!WebSocket._isFake) {
|
||||||
const real_version = WebSocket;
|
const realVersion = WebSocket;
|
||||||
// eslint-disable-next-line no-global-assign
|
// eslint-disable-next-line no-global-assign
|
||||||
WebSocket = FakeWebSocket;
|
WebSocket = FakeWebSocket;
|
||||||
FakeWebSocket.__real_version = real_version;
|
FakeWebSocket._realVersion = realVersion;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
FakeWebSocket.restore = () => {
|
FakeWebSocket.restore = () => {
|
||||||
if (WebSocket.__is_fake) {
|
if (WebSocket._isFake) {
|
||||||
// eslint-disable-next-line no-global-assign
|
// eslint-disable-next-line no-global-assign
|
||||||
WebSocket = WebSocket.__real_version;
|
WebSocket = WebSocket._realVersion;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* global VNC_frame_data, VNC_frame_encoding */
|
/* global vncFrameData, vncFrameEncoding */
|
||||||
|
|
||||||
import * as WebUtil from '../app/webutil.js';
|
import * as WebUtil from '../app/webutil.js';
|
||||||
import RecordingPlayer from './playback.js';
|
import RecordingPlayer from './playback.js';
|
||||||
@ -41,7 +41,7 @@ function enableUI() {
|
|||||||
document.getElementById('mode1').checked = true;
|
document.getElementById('mode1').checked = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
message("Loaded " + VNC_frame_data.length + " frames");
|
message("Loaded " + vncFrameData.length + " frames");
|
||||||
|
|
||||||
const startButton = document.getElementById('startButton');
|
const startButton = document.getElementById('startButton');
|
||||||
startButton.disabled = false;
|
startButton.disabled = false;
|
||||||
@ -49,12 +49,12 @@ function enableUI() {
|
|||||||
|
|
||||||
message("Converting...");
|
message("Converting...");
|
||||||
|
|
||||||
frames = VNC_frame_data;
|
frames = vncFrameData;
|
||||||
|
|
||||||
let encoding;
|
let encoding;
|
||||||
// Only present in older recordings
|
// Only present in older recordings
|
||||||
if (window.VNC_frame_encoding) {
|
if (window.vncFrameEncoding) {
|
||||||
encoding = VNC_frame_encoding;
|
encoding = vncFrameEncoding;
|
||||||
} else {
|
} else {
|
||||||
let frame = frames[0];
|
let frame = frames[0];
|
||||||
let start = frame.indexOf('{', 1) + 1;
|
let start = frame.indexOf('{', 1) + 1;
|
||||||
@ -102,7 +102,7 @@ class IterationPlayer {
|
|||||||
this._iteration = undefined;
|
this._iteration = undefined;
|
||||||
this._player = undefined;
|
this._player = undefined;
|
||||||
|
|
||||||
this._start_time = undefined;
|
this._startTime = undefined;
|
||||||
|
|
||||||
this._frames = frames;
|
this._frames = frames;
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ class IterationPlayer {
|
|||||||
|
|
||||||
start(realtime) {
|
start(realtime) {
|
||||||
this._iteration = 0;
|
this._iteration = 0;
|
||||||
this._start_time = (new Date()).getTime();
|
this._startTime = (new Date()).getTime();
|
||||||
|
|
||||||
this._realtime = realtime;
|
this._realtime = realtime;
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ class IterationPlayer {
|
|||||||
|
|
||||||
_finish() {
|
_finish() {
|
||||||
const endTime = (new Date()).getTime();
|
const endTime = (new Date()).getTime();
|
||||||
const totalDuration = endTime - this._start_time;
|
const totalDuration = endTime - this._startTime;
|
||||||
|
|
||||||
const evt = new CustomEvent('finish',
|
const evt = new CustomEvent('finish',
|
||||||
{ detail:
|
{ detail:
|
||||||
|
@ -49,10 +49,10 @@ export default class RecordingPlayer {
|
|||||||
this._disconnected = disconnected;
|
this._disconnected = disconnected;
|
||||||
|
|
||||||
this._rfb = undefined;
|
this._rfb = undefined;
|
||||||
this._frame_length = this._frames.length;
|
this._frameLength = this._frames.length;
|
||||||
|
|
||||||
this._frame_index = 0;
|
this._frameIndex = 0;
|
||||||
this._start_time = undefined;
|
this._startTime = undefined;
|
||||||
this._realtime = true;
|
this._realtime = true;
|
||||||
this._trafficManagement = true;
|
this._trafficManagement = true;
|
||||||
|
|
||||||
@ -72,8 +72,8 @@ export default class RecordingPlayer {
|
|||||||
this._enablePlaybackMode();
|
this._enablePlaybackMode();
|
||||||
|
|
||||||
// reset the frame index and timer
|
// reset the frame index and timer
|
||||||
this._frame_index = 0;
|
this._frameIndex = 0;
|
||||||
this._start_time = (new Date()).getTime();
|
this._startTime = (new Date()).getTime();
|
||||||
|
|
||||||
this._realtime = realtime;
|
this._realtime = realtime;
|
||||||
this._trafficManagement = (trafficManagement === undefined) ? !realtime : trafficManagement;
|
this._trafficManagement = (trafficManagement === undefined) ? !realtime : trafficManagement;
|
||||||
@ -97,22 +97,22 @@ export default class RecordingPlayer {
|
|||||||
_queueNextPacket() {
|
_queueNextPacket() {
|
||||||
if (!this._running) { return; }
|
if (!this._running) { return; }
|
||||||
|
|
||||||
let frame = this._frames[this._frame_index];
|
let frame = this._frames[this._frameIndex];
|
||||||
|
|
||||||
// skip send frames
|
// skip send frames
|
||||||
while (this._frame_index < this._frame_length && frame.fromClient) {
|
while (this._frameIndex < this._frameLength && frame.fromClient) {
|
||||||
this._frame_index++;
|
this._frameIndex++;
|
||||||
frame = this._frames[this._frame_index];
|
frame = this._frames[this._frameIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._frame_index >= this._frame_length) {
|
if (this._frameIndex >= this._frameLength) {
|
||||||
Log.Debug('Finished, no more frames');
|
Log.Debug('Finished, no more frames');
|
||||||
this._finish();
|
this._finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._realtime) {
|
if (this._realtime) {
|
||||||
const toffset = (new Date()).getTime() - this._start_time;
|
const toffset = (new Date()).getTime() - this._startTime;
|
||||||
let delay = frame.timestamp - toffset;
|
let delay = frame.timestamp - toffset;
|
||||||
if (delay < 1) delay = 1;
|
if (delay < 1) delay = 1;
|
||||||
|
|
||||||
@ -134,10 +134,10 @@ export default class RecordingPlayer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const frame = this._frames[this._frame_index];
|
const frame = this._frames[this._frameIndex];
|
||||||
|
|
||||||
this._rfb._sock._recv_message({'data': frame.data});
|
this._rfb._sock._recv_message({'data': frame.data});
|
||||||
this._frame_index++;
|
this._frameIndex++;
|
||||||
|
|
||||||
this._queueNextPacket();
|
this._queueNextPacket();
|
||||||
}
|
}
|
||||||
@ -155,13 +155,13 @@ export default class RecordingPlayer {
|
|||||||
this._running = false;
|
this._running = false;
|
||||||
this._rfb._sock._eventHandlers.close({code: 1000, reason: ""});
|
this._rfb._sock._eventHandlers.close({code: 1000, reason: ""});
|
||||||
delete this._rfb;
|
delete this._rfb;
|
||||||
this.onfinish((new Date()).getTime() - this._start_time);
|
this.onfinish((new Date()).getTime() - this._startTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_handleDisconnect(evt) {
|
_handleDisconnect(evt) {
|
||||||
this._running = false;
|
this._running = false;
|
||||||
this._disconnected(evt.detail.clean, this._frame_index);
|
this._disconnected(evt.detail.clean, this._frameIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
_handleCredentials(evt) {
|
_handleCredentials(evt) {
|
||||||
|
@ -352,7 +352,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
push32(data, toUnsigned32bit(-8));
|
push32(data, toUnsigned32bit(-8));
|
||||||
data = data.concat(flags);
|
data = data.concat(flags);
|
||||||
data = data.concat(fileSizes);
|
data = data.concat(fileSizes);
|
||||||
client._sock._websocket._receive_data(new Uint8Array(data));
|
client._sock._websocket._receiveData(new Uint8Array(data));
|
||||||
|
|
||||||
client.clipboardPasteFrom('extended test');
|
client.clipboardPasteFrom('extended test');
|
||||||
expect(RFB.messages.extendedClipboardNotify).to.have.been.calledOnce;
|
expect(RFB.messages.extendedClipboardNotify).to.have.been.calledOnce;
|
||||||
@ -450,7 +450,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
|
|
||||||
sinon.spy(client._display, "viewportChangeSize");
|
sinon.spy(client._display, "viewportChangeSize");
|
||||||
|
|
||||||
client._sock._websocket._receive_data(new Uint8Array(incoming));
|
client._sock._websocket._receiveData(new Uint8Array(incoming));
|
||||||
|
|
||||||
// FIXME: Display implicitly calls viewportChangeSize() when
|
// FIXME: Display implicitly calls viewportChangeSize() when
|
||||||
// resizing the framebuffer, hence calledTwice.
|
// resizing the framebuffer, hence calledTwice.
|
||||||
@ -647,7 +647,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
|
|
||||||
sinon.spy(client._display, "autoscale");
|
sinon.spy(client._display, "autoscale");
|
||||||
|
|
||||||
client._sock._websocket._receive_data(new Uint8Array(incoming));
|
client._sock._websocket._receiveData(new Uint8Array(incoming));
|
||||||
|
|
||||||
expect(client._display.autoscale).to.have.been.calledOnce;
|
expect(client._display.autoscale).to.have.been.calledOnce;
|
||||||
expect(client._display.autoscale).to.have.been.calledWith(70, 80);
|
expect(client._display.autoscale).to.have.been.calledWith(70, 80);
|
||||||
@ -702,7 +702,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
|
|
||||||
client._supportsSetDesktopSize = false;
|
client._supportsSetDesktopSize = false;
|
||||||
|
|
||||||
client._sock._websocket._receive_data(new Uint8Array(incoming));
|
client._sock._websocket._receiveData(new Uint8Array(incoming));
|
||||||
|
|
||||||
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);
|
||||||
@ -711,7 +711,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
|
|
||||||
// Second message should not trigger a resize
|
// Second message should not trigger a resize
|
||||||
|
|
||||||
client._sock._websocket._receive_data(new Uint8Array(incoming));
|
client._sock._websocket._receiveData(new Uint8Array(incoming));
|
||||||
|
|
||||||
expect(RFB.messages.setDesktopSize).to.not.have.been.called;
|
expect(RFB.messages.setDesktopSize).to.not.have.been.called;
|
||||||
});
|
});
|
||||||
@ -794,7 +794,7 @@ 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 ];
|
||||||
|
|
||||||
client._sock._websocket._receive_data(new Uint8Array(incoming));
|
client._sock._websocket._receiveData(new Uint8Array(incoming));
|
||||||
|
|
||||||
expect(RFB.messages.setDesktopSize).to.not.have.been.called;
|
expect(RFB.messages.setDesktopSize).to.not.have.been.called;
|
||||||
});
|
});
|
||||||
@ -1012,7 +1012,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
}
|
}
|
||||||
arr[0] = 'R'; arr[1] = 'F'; arr[2] = 'B'; arr[3] = ' ';
|
arr[0] = 'R'; arr[1] = 'F'; arr[2] = 'B'; arr[3] = ' ';
|
||||||
arr[11] = '\n';
|
arr[11] = '\n';
|
||||||
client._sock._websocket._receive_data(arr);
|
client._sock._websocket._receiveData(arr);
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('version parsing', function () {
|
describe('version parsing', function () {
|
||||||
@ -1090,7 +1090,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
sendVer('000.000', client);
|
sendVer('000.000', client);
|
||||||
expect(client._rfbVersion).to.equal(0);
|
expect(client._rfbVersion).to.equal(0);
|
||||||
|
|
||||||
const sentData = client._sock._websocket._get_sent_data();
|
const sentData = client._sock._websocket._getSentData();
|
||||||
expect(new Uint8Array(sentData.buffer, 0, 9)).to.array.equal(new Uint8Array([73, 68, 58, 49, 50, 51, 52, 53, 0]));
|
expect(new Uint8Array(sentData.buffer, 0, 9)).to.array.equal(new Uint8Array([73, 68, 58, 49, 50, 51, 52, 53, 0]));
|
||||||
expect(sentData).to.have.length(250);
|
expect(sentData).to.have.length(250);
|
||||||
});
|
});
|
||||||
@ -1113,14 +1113,14 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
const authSchemeRaw = [1, 2, 3, 4];
|
const authSchemeRaw = [1, 2, 3, 4];
|
||||||
const authScheme = (authSchemeRaw[0] << 24) + (authSchemeRaw[1] << 16) +
|
const authScheme = (authSchemeRaw[0] << 24) + (authSchemeRaw[1] << 16) +
|
||||||
(authSchemeRaw[2] << 8) + authSchemeRaw[3];
|
(authSchemeRaw[2] << 8) + authSchemeRaw[3];
|
||||||
client._sock._websocket._receive_data(new Uint8Array(authSchemeRaw));
|
client._sock._websocket._receiveData(new Uint8Array(authSchemeRaw));
|
||||||
expect(client._rfbAuthScheme).to.equal(authScheme);
|
expect(client._rfbAuthScheme).to.equal(authScheme);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should prefer no authentication is possible', function () {
|
it('should prefer no authentication is possible', function () {
|
||||||
client._rfbVersion = 3.7;
|
client._rfbVersion = 3.7;
|
||||||
const authSchemes = [2, 1, 3];
|
const authSchemes = [2, 1, 3];
|
||||||
client._sock._websocket._receive_data(new Uint8Array(authSchemes));
|
client._sock._websocket._receiveData(new Uint8Array(authSchemes));
|
||||||
expect(client._rfbAuthScheme).to.equal(1);
|
expect(client._rfbAuthScheme).to.equal(1);
|
||||||
expect(client._sock).to.have.sent(new Uint8Array([1, 1]));
|
expect(client._sock).to.have.sent(new Uint8Array([1, 1]));
|
||||||
});
|
});
|
||||||
@ -1128,7 +1128,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
it('should choose for the most prefered scheme possible for versions >= 3.7', function () {
|
it('should choose for the most prefered scheme possible for versions >= 3.7', function () {
|
||||||
client._rfbVersion = 3.7;
|
client._rfbVersion = 3.7;
|
||||||
const authSchemes = [2, 22, 16];
|
const authSchemes = [2, 22, 16];
|
||||||
client._sock._websocket._receive_data(new Uint8Array(authSchemes));
|
client._sock._websocket._receiveData(new Uint8Array(authSchemes));
|
||||||
expect(client._rfbAuthScheme).to.equal(22);
|
expect(client._rfbAuthScheme).to.equal(22);
|
||||||
expect(client._sock).to.have.sent(new Uint8Array([22]));
|
expect(client._sock).to.have.sent(new Uint8Array([22]));
|
||||||
});
|
});
|
||||||
@ -1137,7 +1137,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
sinon.spy(client, "_fail");
|
sinon.spy(client, "_fail");
|
||||||
client._rfbVersion = 3.7;
|
client._rfbVersion = 3.7;
|
||||||
const authSchemes = [1, 32];
|
const authSchemes = [1, 32];
|
||||||
client._sock._websocket._receive_data(new Uint8Array(authSchemes));
|
client._sock._websocket._receiveData(new Uint8Array(authSchemes));
|
||||||
expect(client._fail).to.have.been.calledOnce;
|
expect(client._fail).to.have.been.calledOnce;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1145,7 +1145,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
client._rfbVersion = 3.7;
|
client._rfbVersion = 3.7;
|
||||||
const failureData = [0, 0, 0, 0, 6, 119, 104, 111, 111, 112, 115];
|
const failureData = [0, 0, 0, 0, 6, 119, 104, 111, 111, 112, 115];
|
||||||
sinon.spy(client, '_fail');
|
sinon.spy(client, '_fail');
|
||||||
client._sock._websocket._receive_data(new Uint8Array(failureData));
|
client._sock._websocket._receiveData(new Uint8Array(failureData));
|
||||||
|
|
||||||
expect(client._fail).to.have.been.calledOnce;
|
expect(client._fail).to.have.been.calledOnce;
|
||||||
expect(client._fail).to.have.been.calledWith(
|
expect(client._fail).to.have.been.calledWith(
|
||||||
@ -1156,7 +1156,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
client._rfbVersion = 3.7;
|
client._rfbVersion = 3.7;
|
||||||
const authSchemes = [1, 1];
|
const authSchemes = [1, 1];
|
||||||
client._negotiateAuthentication = sinon.spy();
|
client._negotiateAuthentication = sinon.spy();
|
||||||
client._sock._websocket._receive_data(new Uint8Array(authSchemes));
|
client._sock._websocket._receiveData(new Uint8Array(authSchemes));
|
||||||
expect(client._rfbInitState).to.equal('Authentication');
|
expect(client._rfbInitState).to.equal('Authentication');
|
||||||
expect(client._negotiateAuthentication).to.have.been.calledOnce;
|
expect(client._negotiateAuthentication).to.have.been.calledOnce;
|
||||||
});
|
});
|
||||||
@ -1168,7 +1168,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function sendSecurity(type, cl) {
|
function sendSecurity(type, cl) {
|
||||||
cl._sock._websocket._receive_data(new Uint8Array([1, type]));
|
cl._sock._websocket._receiveData(new Uint8Array([1, type]));
|
||||||
}
|
}
|
||||||
|
|
||||||
it('should fail on auth scheme 0 (pre 3.7) with the given message', function () {
|
it('should fail on auth scheme 0 (pre 3.7) with the given message', function () {
|
||||||
@ -1182,7 +1182,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sinon.spy(client, '_fail');
|
sinon.spy(client, '_fail');
|
||||||
client._sock._websocket._receive_data(new Uint8Array(data));
|
client._sock._websocket._receiveData(new Uint8Array(data));
|
||||||
expect(client._fail).to.have.been.calledWith(
|
expect(client._fail).to.have.been.calledWith(
|
||||||
'Security negotiation failed on authentication scheme (reason: Whoopsies)');
|
'Security negotiation failed on authentication scheme (reason: Whoopsies)');
|
||||||
});
|
});
|
||||||
@ -1219,7 +1219,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
|
|
||||||
const challenge = [];
|
const challenge = [];
|
||||||
for (let i = 0; i < 16; i++) { challenge[i] = i; }
|
for (let i = 0; i < 16; i++) { challenge[i] = i; }
|
||||||
client._sock._websocket._receive_data(new Uint8Array(challenge));
|
client._sock._websocket._receiveData(new Uint8Array(challenge));
|
||||||
|
|
||||||
expect(client._rfbCredentials).to.be.empty;
|
expect(client._rfbCredentials).to.be.empty;
|
||||||
expect(spy).to.have.been.calledOnce;
|
expect(spy).to.have.been.calledOnce;
|
||||||
@ -1229,11 +1229,11 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
it('should encrypt the password with DES and then send it back', function () {
|
it('should encrypt the password with DES and then send it back', function () {
|
||||||
client._rfbCredentials = { password: 'passwd' };
|
client._rfbCredentials = { password: 'passwd' };
|
||||||
sendSecurity(2, client);
|
sendSecurity(2, client);
|
||||||
client._sock._websocket._get_sent_data(); // skip the choice of auth reply
|
client._sock._websocket._getSentData(); // skip the choice of auth reply
|
||||||
|
|
||||||
const challenge = [];
|
const challenge = [];
|
||||||
for (let i = 0; i < 16; i++) { challenge[i] = i; }
|
for (let i = 0; i < 16; i++) { challenge[i] = i; }
|
||||||
client._sock._websocket._receive_data(new Uint8Array(challenge));
|
client._sock._websocket._receiveData(new Uint8Array(challenge));
|
||||||
|
|
||||||
const desPass = RFB.genDES('passwd', challenge);
|
const desPass = RFB.genDES('passwd', challenge);
|
||||||
expect(client._sock).to.have.sent(new Uint8Array(desPass));
|
expect(client._sock).to.have.sent(new Uint8Array(desPass));
|
||||||
@ -1245,7 +1245,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
|
|
||||||
const challenge = [];
|
const challenge = [];
|
||||||
for (let i = 0; i < 16; i++) { challenge[i] = i; }
|
for (let i = 0; i < 16; i++) { challenge[i] = i; }
|
||||||
client._sock._websocket._receive_data(new Uint8Array(challenge));
|
client._sock._websocket._receiveData(new Uint8Array(challenge));
|
||||||
|
|
||||||
expect(client._rfbInitState).to.equal('SecurityResult');
|
expect(client._rfbInitState).to.equal('SecurityResult');
|
||||||
});
|
});
|
||||||
@ -1308,7 +1308,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
client._rfbInitState = 'Security';
|
client._rfbInitState = 'Security';
|
||||||
client._rfbVersion = 3.8;
|
client._rfbVersion = 3.8;
|
||||||
sendSecurity(16, client);
|
sendSecurity(16, client);
|
||||||
client._sock._websocket._get_sent_data(); // skip the security reply
|
client._sock._websocket._getSentData(); // skip the security reply
|
||||||
});
|
});
|
||||||
|
|
||||||
function sendNumStrPairs(pairs, client) {
|
function sendNumStrPairs(pairs, client) {
|
||||||
@ -1325,11 +1325,11 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
client._sock._websocket._receive_data(new Uint8Array(data));
|
client._sock._websocket._receiveData(new Uint8Array(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
it('should skip tunnel negotiation if no tunnels are requested', function () {
|
it('should skip tunnel negotiation if no tunnels are requested', function () {
|
||||||
client._sock._websocket._receive_data(new Uint8Array([0, 0, 0, 0]));
|
client._sock._websocket._receiveData(new Uint8Array([0, 0, 0, 0]));
|
||||||
expect(client._rfbTightVNC).to.be.true;
|
expect(client._rfbTightVNC).to.be.true;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1351,7 +1351,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
|
|
||||||
it('should continue to sub-auth negotiation after tunnel negotiation', function () {
|
it('should continue to sub-auth negotiation after tunnel negotiation', function () {
|
||||||
sendNumStrPairs([[0, 'TGHT', 'NOTUNNEL']], client);
|
sendNumStrPairs([[0, 'TGHT', 'NOTUNNEL']], client);
|
||||||
client._sock._websocket._get_sent_data(); // skip the tunnel choice here
|
client._sock._websocket._getSentData(); // skip the tunnel choice here
|
||||||
sendNumStrPairs([[1, 'STDV', 'NOAUTH__']], client);
|
sendNumStrPairs([[1, 'STDV', 'NOAUTH__']], client);
|
||||||
expect(client._sock).to.have.sent(new Uint8Array([0, 0, 0, 1]));
|
expect(client._sock).to.have.sent(new Uint8Array([0, 0, 0, 1]));
|
||||||
expect(client._rfbInitState).to.equal('SecurityResult');
|
expect(client._rfbInitState).to.equal('SecurityResult');
|
||||||
@ -1397,7 +1397,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should fall through to ServerInitialisation on a response code of 0', function () {
|
it('should fall through to ServerInitialisation on a response code of 0', function () {
|
||||||
client._sock._websocket._receive_data(new Uint8Array([0, 0, 0, 0]));
|
client._sock._websocket._receiveData(new Uint8Array([0, 0, 0, 0]));
|
||||||
expect(client._rfbInitState).to.equal('ServerInitialisation');
|
expect(client._rfbInitState).to.equal('ServerInitialisation');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1405,7 +1405,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
client._rfbVersion = 3.8;
|
client._rfbVersion = 3.8;
|
||||||
sinon.spy(client, '_fail');
|
sinon.spy(client, '_fail');
|
||||||
const failureData = [0, 0, 0, 1, 0, 0, 0, 6, 119, 104, 111, 111, 112, 115];
|
const failureData = [0, 0, 0, 1, 0, 0, 0, 6, 119, 104, 111, 111, 112, 115];
|
||||||
client._sock._websocket._receive_data(new Uint8Array(failureData));
|
client._sock._websocket._receiveData(new Uint8Array(failureData));
|
||||||
expect(client._fail).to.have.been.calledWith(
|
expect(client._fail).to.have.been.calledWith(
|
||||||
'Security negotiation failed on security result (reason: whoops)');
|
'Security negotiation failed on security result (reason: whoops)');
|
||||||
});
|
});
|
||||||
@ -1413,7 +1413,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
it('should fail on an error code of 1 with a standard message for version < 3.8', function () {
|
it('should fail on an error code of 1 with a standard message for version < 3.8', function () {
|
||||||
sinon.spy(client, '_fail');
|
sinon.spy(client, '_fail');
|
||||||
client._rfbVersion = 3.7;
|
client._rfbVersion = 3.7;
|
||||||
client._sock._websocket._receive_data(new Uint8Array([0, 0, 0, 1]));
|
client._sock._websocket._receiveData(new Uint8Array([0, 0, 0, 1]));
|
||||||
expect(client._fail).to.have.been.calledWith(
|
expect(client._fail).to.have.been.calledWith(
|
||||||
'Security handshake failed');
|
'Security handshake failed');
|
||||||
});
|
});
|
||||||
@ -1421,7 +1421,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
it('should result in securityfailure event when receiving a non zero status', function () {
|
it('should result in securityfailure event when receiving a non zero status', function () {
|
||||||
const spy = sinon.spy();
|
const spy = sinon.spy();
|
||||||
client.addEventListener("securityfailure", spy);
|
client.addEventListener("securityfailure", spy);
|
||||||
client._sock._websocket._receive_data(new Uint8Array([0, 0, 0, 2]));
|
client._sock._websocket._receiveData(new Uint8Array([0, 0, 0, 2]));
|
||||||
expect(spy).to.have.been.calledOnce;
|
expect(spy).to.have.been.calledOnce;
|
||||||
expect(spy.args[0][0].detail.status).to.equal(2);
|
expect(spy.args[0][0].detail.status).to.equal(2);
|
||||||
});
|
});
|
||||||
@ -1432,7 +1432,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
client.addEventListener("securityfailure", spy);
|
client.addEventListener("securityfailure", spy);
|
||||||
const failureData = [0, 0, 0, 1, 0, 0, 0, 12, 115, 117, 99, 104,
|
const failureData = [0, 0, 0, 1, 0, 0, 0, 12, 115, 117, 99, 104,
|
||||||
32, 102, 97, 105, 108, 117, 114, 101];
|
32, 102, 97, 105, 108, 117, 114, 101];
|
||||||
client._sock._websocket._receive_data(new Uint8Array(failureData));
|
client._sock._websocket._receiveData(new Uint8Array(failureData));
|
||||||
expect(spy.args[0][0].detail.status).to.equal(1);
|
expect(spy.args[0][0].detail.status).to.equal(1);
|
||||||
expect(spy.args[0][0].detail.reason).to.equal('such failure');
|
expect(spy.args[0][0].detail.reason).to.equal('such failure');
|
||||||
});
|
});
|
||||||
@ -1442,7 +1442,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
const spy = sinon.spy();
|
const spy = sinon.spy();
|
||||||
client.addEventListener("securityfailure", spy);
|
client.addEventListener("securityfailure", spy);
|
||||||
const failureData = [0, 0, 0, 1, 0, 0, 0, 0];
|
const failureData = [0, 0, 0, 1, 0, 0, 0, 0];
|
||||||
client._sock._websocket._receive_data(new Uint8Array(failureData));
|
client._sock._websocket._receiveData(new Uint8Array(failureData));
|
||||||
expect(spy.args[0][0].detail.status).to.equal(1);
|
expect(spy.args[0][0].detail.status).to.equal(1);
|
||||||
expect('reason' in spy.args[0][0].detail).to.be.false;
|
expect('reason' in spy.args[0][0].detail).to.be.false;
|
||||||
});
|
});
|
||||||
@ -1451,7 +1451,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
client._rfbVersion = 3.6;
|
client._rfbVersion = 3.6;
|
||||||
const spy = sinon.spy();
|
const spy = sinon.spy();
|
||||||
client.addEventListener("securityfailure", spy);
|
client.addEventListener("securityfailure", spy);
|
||||||
client._sock._websocket._receive_data(new Uint8Array([0, 0, 0, 2]));
|
client._sock._websocket._receiveData(new Uint8Array([0, 0, 0, 2]));
|
||||||
expect(spy.args[0][0].detail.status).to.equal(2);
|
expect(spy.args[0][0].detail.status).to.equal(2);
|
||||||
expect('reason' in spy.args[0][0].detail).to.be.false;
|
expect('reason' in spy.args[0][0].detail).to.be.false;
|
||||||
});
|
});
|
||||||
@ -1462,7 +1462,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
const client = makeRFB();
|
const client = makeRFB();
|
||||||
client._rfbConnectionState = 'connecting';
|
client._rfbConnectionState = 'connecting';
|
||||||
client._rfbInitState = 'SecurityResult';
|
client._rfbInitState = 'SecurityResult';
|
||||||
client._sock._websocket._receive_data(new Uint8Array([0, 0, 0, 0]));
|
client._sock._websocket._receiveData(new Uint8Array([0, 0, 0, 0]));
|
||||||
expect(client._rfbInitState).to.equal('ServerInitialisation');
|
expect(client._rfbInitState).to.equal('ServerInitialisation');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1470,7 +1470,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
const client = makeRFB('wss://host:8675', { shared: true });
|
const client = makeRFB('wss://host:8675', { shared: true });
|
||||||
client._rfbConnectionState = 'connecting';
|
client._rfbConnectionState = 'connecting';
|
||||||
client._rfbInitState = 'SecurityResult';
|
client._rfbInitState = 'SecurityResult';
|
||||||
client._sock._websocket._receive_data(new Uint8Array([0, 0, 0, 0]));
|
client._sock._websocket._receiveData(new Uint8Array([0, 0, 0, 0]));
|
||||||
expect(client._sock).to.have.sent(new Uint8Array([1]));
|
expect(client._sock).to.have.sent(new Uint8Array([1]));
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1478,7 +1478,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
const client = makeRFB('wss://host:8675', { shared: false });
|
const client = makeRFB('wss://host:8675', { shared: false });
|
||||||
client._rfbConnectionState = 'connecting';
|
client._rfbConnectionState = 'connecting';
|
||||||
client._rfbInitState = 'SecurityResult';
|
client._rfbInitState = 'SecurityResult';
|
||||||
client._sock._websocket._receive_data(new Uint8Array([0, 0, 0, 0]));
|
client._sock._websocket._receiveData(new Uint8Array([0, 0, 0, 0]));
|
||||||
expect(client._sock).to.have.sent(new Uint8Array([0]));
|
expect(client._sock).to.have.sent(new Uint8Array([0]));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -1517,15 +1517,15 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
push8(data, 0);
|
push8(data, 0);
|
||||||
push8(data, 0);
|
push8(data, 0);
|
||||||
|
|
||||||
client._sock._websocket._receive_data(new Uint8Array(data));
|
client._sock._websocket._receiveData(new Uint8Array(data));
|
||||||
|
|
||||||
const nameData = [];
|
const nameData = [];
|
||||||
let nameLen = [];
|
let nameLen = [];
|
||||||
pushString(nameData, fullOpts.name);
|
pushString(nameData, fullOpts.name);
|
||||||
push32(nameLen, nameData.length);
|
push32(nameLen, nameData.length);
|
||||||
|
|
||||||
client._sock._websocket._receive_data(new Uint8Array(nameLen));
|
client._sock._websocket._receiveData(new Uint8Array(nameLen));
|
||||||
client._sock._websocket._receive_data(new Uint8Array(nameData));
|
client._sock._websocket._receiveData(new Uint8Array(nameData));
|
||||||
}
|
}
|
||||||
|
|
||||||
it('should set the framebuffer width and height', function () {
|
it('should set the framebuffer width and height', function () {
|
||||||
@ -1560,7 +1560,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
for (let i = 0; i < 16 + 32 + 48; i++) {
|
for (let i = 0; i < 16 + 32 + 48; i++) {
|
||||||
tightData.push(i);
|
tightData.push(i);
|
||||||
}
|
}
|
||||||
client._sock._websocket._receive_data(new Uint8Array(tightData));
|
client._sock._websocket._receiveData(new Uint8Array(tightData));
|
||||||
|
|
||||||
expect(client._rfbConnectionState).to.equal('connected');
|
expect(client._rfbConnectionState).to.equal('connected');
|
||||||
});
|
});
|
||||||
@ -1684,7 +1684,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
data = data.concat(rectData[i]);
|
data = data.concat(rectData[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
client._sock._websocket._receive_data(new Uint8Array(data));
|
client._sock._websocket._receiveData(new Uint8Array(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
it('should send an update request if there is sufficient data', function () {
|
it('should send an update request if there is sufficient data', function () {
|
||||||
@ -1692,14 +1692,14 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
RFB.messages.fbUpdateRequest(expectedMsg, true, 0, 0, 640, 20);
|
RFB.messages.fbUpdateRequest(expectedMsg, true, 0, 0, 640, 20);
|
||||||
|
|
||||||
client._framebufferUpdate = () => true;
|
client._framebufferUpdate = () => true;
|
||||||
client._sock._websocket._receive_data(new Uint8Array([0]));
|
client._sock._websocket._receiveData(new Uint8Array([0]));
|
||||||
|
|
||||||
expect(client._sock).to.have.sent(expectedMsg._sQ);
|
expect(client._sock).to.have.sent(expectedMsg._sQ);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not send an update request if we need more data', function () {
|
it('should not send an update request if we need more data', function () {
|
||||||
client._sock._websocket._receive_data(new Uint8Array([0]));
|
client._sock._websocket._receiveData(new Uint8Array([0]));
|
||||||
expect(client._sock._websocket._get_sent_data()).to.have.length(0);
|
expect(client._sock._websocket._getSentData()).to.have.length(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should resume receiving an update if we previously did not have enough data', function () {
|
it('should resume receiving an update if we previously did not have enough data', function () {
|
||||||
@ -1707,21 +1707,21 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
RFB.messages.fbUpdateRequest(expectedMsg, true, 0, 0, 640, 20);
|
RFB.messages.fbUpdateRequest(expectedMsg, true, 0, 0, 640, 20);
|
||||||
|
|
||||||
// just enough to set FBU.rects
|
// just enough to set FBU.rects
|
||||||
client._sock._websocket._receive_data(new Uint8Array([0, 0, 0, 3]));
|
client._sock._websocket._receiveData(new Uint8Array([0, 0, 0, 3]));
|
||||||
expect(client._sock._websocket._get_sent_data()).to.have.length(0);
|
expect(client._sock._websocket._getSentData()).to.have.length(0);
|
||||||
|
|
||||||
client._framebufferUpdate = function () { this._sock.rQskipBytes(1); return true; }; // we magically have enough data
|
client._framebufferUpdate = function () { this._sock.rQskipBytes(1); return true; }; // we magically have enough data
|
||||||
// 247 should *not* be used as the message type here
|
// 247 should *not* be used as the message type here
|
||||||
client._sock._websocket._receive_data(new Uint8Array([247]));
|
client._sock._websocket._receiveData(new Uint8Array([247]));
|
||||||
expect(client._sock).to.have.sent(expectedMsg._sQ);
|
expect(client._sock).to.have.sent(expectedMsg._sQ);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not send a request in continuous updates mode', function () {
|
it('should not send a request in continuous updates mode', function () {
|
||||||
client._enabledContinuousUpdates = true;
|
client._enabledContinuousUpdates = true;
|
||||||
client._framebufferUpdate = () => true;
|
client._framebufferUpdate = () => true;
|
||||||
client._sock._websocket._receive_data(new Uint8Array([0]));
|
client._sock._websocket._receiveData(new Uint8Array([0]));
|
||||||
|
|
||||||
expect(client._sock._websocket._get_sent_data()).to.have.length(0);
|
expect(client._sock._websocket._getSentData()).to.have.length(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fail on an unsupported encoding', function () {
|
it('should fail on an unsupported encoding', function () {
|
||||||
@ -2388,7 +2388,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
it('should set the XVP version and fire the callback with the version on XVP_INIT', function () {
|
it('should set the XVP version and fire the callback with the version on XVP_INIT', function () {
|
||||||
const spy = sinon.spy();
|
const spy = sinon.spy();
|
||||||
client.addEventListener("capabilities", spy);
|
client.addEventListener("capabilities", spy);
|
||||||
client._sock._websocket._receive_data(new Uint8Array([250, 0, 10, 1]));
|
client._sock._websocket._receiveData(new Uint8Array([250, 0, 10, 1]));
|
||||||
expect(client._rfbXvpVer).to.equal(10);
|
expect(client._rfbXvpVer).to.equal(10);
|
||||||
expect(spy).to.have.been.calledOnce;
|
expect(spy).to.have.been.calledOnce;
|
||||||
expect(spy.args[0][0].detail.capabilities.power).to.be.true;
|
expect(spy.args[0][0].detail.capabilities.power).to.be.true;
|
||||||
@ -2397,7 +2397,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
|
|
||||||
it('should fail on unknown XVP message types', function () {
|
it('should fail on unknown XVP message types', function () {
|
||||||
sinon.spy(client, "_fail");
|
sinon.spy(client, "_fail");
|
||||||
client._sock._websocket._receive_data(new Uint8Array([250, 0, 10, 237]));
|
client._sock._websocket._receiveData(new Uint8Array([250, 0, 10, 237]));
|
||||||
expect(client._fail).to.have.been.calledOnce;
|
expect(client._fail).to.have.been.calledOnce;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -2411,7 +2411,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
const spy = sinon.spy();
|
const spy = sinon.spy();
|
||||||
client.addEventListener("clipboard", spy);
|
client.addEventListener("clipboard", spy);
|
||||||
|
|
||||||
client._sock._websocket._receive_data(new Uint8Array(data));
|
client._sock._websocket._receiveData(new Uint8Array(data));
|
||||||
expect(spy).to.have.been.calledOnce;
|
expect(spy).to.have.been.calledOnce;
|
||||||
expect(spy.args[0][0].detail.text).to.equal(expectedStr);
|
expect(spy.args[0][0].detail.text).to.equal(expectedStr);
|
||||||
});
|
});
|
||||||
@ -2437,7 +2437,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
push32(data, toUnsigned32bit(-12));
|
push32(data, toUnsigned32bit(-12));
|
||||||
data = data.concat(flags);
|
data = data.concat(flags);
|
||||||
data = data.concat(fileSizes);
|
data = data.concat(fileSizes);
|
||||||
client._sock._websocket._receive_data(new Uint8Array(data));
|
client._sock._websocket._receiveData(new Uint8Array(data));
|
||||||
|
|
||||||
// Check that we give an response caps when we receive one
|
// Check that we give an response caps when we receive one
|
||||||
expect(RFB.messages.extendedClipboardCaps).to.have.been.calledOnce;
|
expect(RFB.messages.extendedClipboardCaps).to.have.been.calledOnce;
|
||||||
@ -2463,7 +2463,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
push32(data, toUnsigned32bit(-8));
|
push32(data, toUnsigned32bit(-8));
|
||||||
data = data.concat(flags);
|
data = data.concat(flags);
|
||||||
data = data.concat(fileSizes);
|
data = data.concat(fileSizes);
|
||||||
client._sock._websocket._receive_data(new Uint8Array(data));
|
client._sock._websocket._receiveData(new Uint8Array(data));
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Handle Provide', function () {
|
describe('Handle Provide', function () {
|
||||||
@ -2487,7 +2487,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
const spy = sinon.spy();
|
const spy = sinon.spy();
|
||||||
client.addEventListener("clipboard", spy);
|
client.addEventListener("clipboard", spy);
|
||||||
|
|
||||||
client._sock._websocket._receive_data(new Uint8Array(data));
|
client._sock._websocket._receiveData(new Uint8Array(data));
|
||||||
expect(spy).to.have.been.calledOnce;
|
expect(spy).to.have.been.calledOnce;
|
||||||
expect(spy.args[0][0].detail.text).to.equal(expectedData);
|
expect(spy.args[0][0].detail.text).to.equal(expectedData);
|
||||||
client.removeEventListener("clipboard", spy);
|
client.removeEventListener("clipboard", spy);
|
||||||
@ -2514,7 +2514,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
const spy = sinon.spy();
|
const spy = sinon.spy();
|
||||||
client.addEventListener("clipboard", spy);
|
client.addEventListener("clipboard", spy);
|
||||||
|
|
||||||
client._sock._websocket._receive_data(sendData);
|
client._sock._websocket._receiveData(sendData);
|
||||||
expect(spy).to.have.been.calledOnce;
|
expect(spy).to.have.been.calledOnce;
|
||||||
expect(spy.args[0][0].detail.text).to.equal(expectedData);
|
expect(spy.args[0][0].detail.text).to.equal(expectedData);
|
||||||
client.removeEventListener("clipboard", spy);
|
client.removeEventListener("clipboard", spy);
|
||||||
@ -2546,7 +2546,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
const spy = sinon.spy();
|
const spy = sinon.spy();
|
||||||
client.addEventListener("clipboard", spy);
|
client.addEventListener("clipboard", spy);
|
||||||
|
|
||||||
client._sock._websocket._receive_data(sendData);
|
client._sock._websocket._receiveData(sendData);
|
||||||
expect(spy).to.have.been.calledOnce;
|
expect(spy).to.have.been.calledOnce;
|
||||||
expect(spy.args[0][0].detail.text).to.equal(expectedData);
|
expect(spy.args[0][0].detail.text).to.equal(expectedData);
|
||||||
client.removeEventListener("clipboard", spy);
|
client.removeEventListener("clipboard", spy);
|
||||||
@ -2570,7 +2570,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
data = data.concat(flags);
|
data = data.concat(flags);
|
||||||
let expectedData = [0x01];
|
let expectedData = [0x01];
|
||||||
|
|
||||||
client._sock._websocket._receive_data(new Uint8Array(data));
|
client._sock._websocket._receiveData(new Uint8Array(data));
|
||||||
|
|
||||||
expect(RFB.messages.extendedClipboardRequest).to.have.been.calledOnce;
|
expect(RFB.messages.extendedClipboardRequest).to.have.been.calledOnce;
|
||||||
expect(RFB.messages.extendedClipboardRequest).to.have.been.calledWith(client._sock, expectedData);
|
expect(RFB.messages.extendedClipboardRequest).to.have.been.calledWith(client._sock, expectedData);
|
||||||
@ -2593,7 +2593,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
data = data.concat(flags);
|
data = data.concat(flags);
|
||||||
let expectedData = [];
|
let expectedData = [];
|
||||||
|
|
||||||
client._sock._websocket._receive_data(new Uint8Array(data));
|
client._sock._websocket._receiveData(new Uint8Array(data));
|
||||||
|
|
||||||
expect(RFB.messages.extendedClipboardNotify).to.have.been.calledOnce;
|
expect(RFB.messages.extendedClipboardNotify).to.have.been.calledOnce;
|
||||||
expect(RFB.messages.extendedClipboardNotify).to.have.been.calledWith(client._sock, expectedData);
|
expect(RFB.messages.extendedClipboardNotify).to.have.been.calledWith(client._sock, expectedData);
|
||||||
@ -2611,7 +2611,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
client.clipboardPasteFrom("HejHej");
|
client.clipboardPasteFrom("HejHej");
|
||||||
RFB.messages.extendedClipboardNotify.resetHistory();
|
RFB.messages.extendedClipboardNotify.resetHistory();
|
||||||
|
|
||||||
client._sock._websocket._receive_data(new Uint8Array(data));
|
client._sock._websocket._receiveData(new Uint8Array(data));
|
||||||
|
|
||||||
expect(RFB.messages.extendedClipboardNotify).to.have.been.calledOnce;
|
expect(RFB.messages.extendedClipboardNotify).to.have.been.calledOnce;
|
||||||
expect(RFB.messages.extendedClipboardNotify).to.have.been.calledWith(client._sock, expectedData);
|
expect(RFB.messages.extendedClipboardNotify).to.have.been.calledWith(client._sock, expectedData);
|
||||||
@ -2637,7 +2637,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
client.clipboardPasteFrom("HejHej");
|
client.clipboardPasteFrom("HejHej");
|
||||||
expect(RFB.messages.extendedClipboardProvide).to.not.have.been.called;
|
expect(RFB.messages.extendedClipboardProvide).to.not.have.been.called;
|
||||||
|
|
||||||
client._sock._websocket._receive_data(new Uint8Array(data));
|
client._sock._websocket._receiveData(new Uint8Array(data));
|
||||||
|
|
||||||
expect(RFB.messages.extendedClipboardProvide).to.have.been.calledOnce;
|
expect(RFB.messages.extendedClipboardProvide).to.have.been.calledOnce;
|
||||||
expect(RFB.messages.extendedClipboardProvide).to.have.been.calledWith(client._sock, expectedData, ["HejHej"]);
|
expect(RFB.messages.extendedClipboardProvide).to.have.been.calledWith(client._sock, expectedData, ["HejHej"]);
|
||||||
@ -2650,7 +2650,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
it('should fire the bell callback on Bell', function () {
|
it('should fire the bell callback on Bell', function () {
|
||||||
const spy = sinon.spy();
|
const spy = sinon.spy();
|
||||||
client.addEventListener("bell", spy);
|
client.addEventListener("bell", spy);
|
||||||
client._sock._websocket._receive_data(new Uint8Array([2]));
|
client._sock._websocket._receiveData(new Uint8Array([2]));
|
||||||
expect(spy).to.have.been.calledOnce;
|
expect(spy).to.have.been.calledOnce;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -2664,7 +2664,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
RFB.messages.clientFence(expectedMsg, (1<<0) | (1<<1), payload);
|
RFB.messages.clientFence(expectedMsg, (1<<0) | (1<<1), payload);
|
||||||
RFB.messages.clientFence(incomingMsg, 0xffffffff, payload);
|
RFB.messages.clientFence(incomingMsg, 0xffffffff, payload);
|
||||||
|
|
||||||
client._sock._websocket._receive_data(incomingMsg._sQ);
|
client._sock._websocket._receiveData(incomingMsg._sQ);
|
||||||
|
|
||||||
expect(client._sock).to.have.sent(expectedMsg._sQ);
|
expect(client._sock).to.have.sent(expectedMsg._sQ);
|
||||||
|
|
||||||
@ -2674,7 +2674,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
RFB.messages.clientFence(expectedMsg, (1<<0), payload);
|
RFB.messages.clientFence(expectedMsg, (1<<0), payload);
|
||||||
RFB.messages.clientFence(incomingMsg, (1<<0) | (1<<31), payload);
|
RFB.messages.clientFence(incomingMsg, (1<<0) | (1<<31), payload);
|
||||||
|
|
||||||
client._sock._websocket._receive_data(incomingMsg._sQ);
|
client._sock._websocket._receiveData(incomingMsg._sQ);
|
||||||
|
|
||||||
expect(client._sock).to.have.sent(expectedMsg._sQ);
|
expect(client._sock).to.have.sent(expectedMsg._sQ);
|
||||||
});
|
});
|
||||||
@ -2686,7 +2686,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
|
|
||||||
expect(client._enabledContinuousUpdates).to.be.false;
|
expect(client._enabledContinuousUpdates).to.be.false;
|
||||||
|
|
||||||
client._sock._websocket._receive_data(new Uint8Array([150]));
|
client._sock._websocket._receiveData(new Uint8Array([150]));
|
||||||
|
|
||||||
expect(client._enabledContinuousUpdates).to.be.true;
|
expect(client._enabledContinuousUpdates).to.be.true;
|
||||||
expect(client._sock).to.have.sent(expectedMsg._sQ);
|
expect(client._sock).to.have.sent(expectedMsg._sQ);
|
||||||
@ -2696,7 +2696,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
client._enabledContinuousUpdates = true;
|
client._enabledContinuousUpdates = true;
|
||||||
client._supportsContinuousUpdates = true;
|
client._supportsContinuousUpdates = true;
|
||||||
|
|
||||||
client._sock._websocket._receive_data(new Uint8Array([150]));
|
client._sock._websocket._receiveData(new Uint8Array([150]));
|
||||||
|
|
||||||
expect(client._enabledContinuousUpdates).to.be.false;
|
expect(client._enabledContinuousUpdates).to.be.false;
|
||||||
});
|
});
|
||||||
@ -2707,7 +2707,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
|
|
||||||
client._resize(450, 160);
|
client._resize(450, 160);
|
||||||
|
|
||||||
expect(client._sock._websocket._get_sent_data()).to.have.length(0);
|
expect(client._sock._websocket._getSentData()).to.have.length(0);
|
||||||
|
|
||||||
client._enabledContinuousUpdates = true;
|
client._enabledContinuousUpdates = true;
|
||||||
|
|
||||||
@ -2718,7 +2718,7 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
|
|
||||||
it('should fail on an unknown message type', function () {
|
it('should fail on an unknown message type', function () {
|
||||||
sinon.spy(client, "_fail");
|
sinon.spy(client, "_fail");
|
||||||
client._sock._websocket._receive_data(new Uint8Array([87]));
|
client._sock._websocket._receiveData(new Uint8Array([87]));
|
||||||
expect(client._fail).to.have.been.calledOnce;
|
expect(client._fail).to.have.been.calledOnce;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -2892,13 +2892,13 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
// message events
|
// message events
|
||||||
it('should do nothing if we receive an empty message and have nothing in the queue', function () {
|
it('should do nothing if we receive an empty message and have nothing in the queue', function () {
|
||||||
client._normalMsg = sinon.spy();
|
client._normalMsg = sinon.spy();
|
||||||
client._sock._websocket._receive_data(new Uint8Array([]));
|
client._sock._websocket._receiveData(new Uint8Array([]));
|
||||||
expect(client._normalMsg).to.not.have.been.called;
|
expect(client._normalMsg).to.not.have.been.called;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle a message in the connected state as a normal message', function () {
|
it('should handle a message in the connected state as a normal message', function () {
|
||||||
client._normalMsg = sinon.spy();
|
client._normalMsg = sinon.spy();
|
||||||
client._sock._websocket._receive_data(new Uint8Array([1, 2, 3]));
|
client._sock._websocket._receiveData(new Uint8Array([1, 2, 3]));
|
||||||
expect(client._normalMsg).to.have.been.called;
|
expect(client._normalMsg).to.have.been.called;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -2906,14 +2906,14 @@ describe('Remote Frame Buffer Protocol Client', function () {
|
|||||||
client._rfbConnectionState = 'connecting';
|
client._rfbConnectionState = 'connecting';
|
||||||
client._rfbInitState = 'ProtocolVersion';
|
client._rfbInitState = 'ProtocolVersion';
|
||||||
client._initMsg = sinon.spy();
|
client._initMsg = sinon.spy();
|
||||||
client._sock._websocket._receive_data(new Uint8Array([1, 2, 3]));
|
client._sock._websocket._receiveData(new Uint8Array([1, 2, 3]));
|
||||||
expect(client._initMsg).to.have.been.called;
|
expect(client._initMsg).to.have.been.called;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should process all normal messages directly', function () {
|
it('should process all normal messages directly', function () {
|
||||||
const spy = sinon.spy();
|
const spy = sinon.spy();
|
||||||
client.addEventListener("bell", spy);
|
client.addEventListener("bell", spy);
|
||||||
client._sock._websocket._receive_data(new Uint8Array([0x02, 0x02]));
|
client._sock._websocket._receiveData(new Uint8Array([0x02, 0x02]));
|
||||||
expect(spy).to.have.been.calledTwice;
|
expect(spy).to.have.been.calledTwice;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -456,7 +456,7 @@ describe('Websock', function () {
|
|||||||
|
|
||||||
it('should properly pass the encoded data off to the actual WebSocket', function () {
|
it('should properly pass the encoded data off to the actual WebSocket', function () {
|
||||||
sock.send([1, 2, 3]);
|
sock.send([1, 2, 3]);
|
||||||
expect(sock._websocket._get_sent_data()).to.array.equal(new Uint8Array([1, 2, 3]));
|
expect(sock._websocket._getSentData()).to.array.equal(new Uint8Array([1, 2, 3]));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user