Change some attributes to arguments
Some attributes are better suited as arguments, primarily because they are associated with a specific method and cannot be changed later.
This commit is contained in:
+2
-2
@@ -77,8 +77,8 @@ export default function RecordingPlayer (frames, encoding, disconnected, notific
|
||||
RecordingPlayer.prototype = {
|
||||
run: function (realtime, trafficManagement) {
|
||||
// initialize a new RFB
|
||||
this._rfb = new RFB({'target': document.getElementById('VNC_canvas'),
|
||||
'view_only': true,
|
||||
this._rfb = new RFB(document.getElementById('VNC_canvas'),
|
||||
{'view_only': true,
|
||||
'onDisconnected': this._handleDisconnect.bind(this),
|
||||
'onNotification': this._notification});
|
||||
this._enablePlaybackMode();
|
||||
|
||||
+11
-11
@@ -40,19 +40,19 @@ describe('Display/Canvas Helper', function () {
|
||||
describe('checking for cursor uri support', function () {
|
||||
it('should disable cursor URIs if there is no support', function () {
|
||||
_forceCursorURIs(false);
|
||||
var display = new Display({ target: document.createElement('canvas'), prefer_js: true, viewport: false });
|
||||
var display = new Display(document.createElement('canvas'), { prefer_js: true, viewport: false });
|
||||
expect(display._cursor_uri).to.be.false;
|
||||
});
|
||||
|
||||
it('should enable cursor URIs if there is support', function () {
|
||||
_forceCursorURIs(true);
|
||||
var display = new Display({ target: document.createElement('canvas'), prefer_js: true, viewport: false });
|
||||
var display = new Display(document.createElement('canvas'), { prefer_js: true, viewport: false });
|
||||
expect(display._cursor_uri).to.be.true;
|
||||
});
|
||||
|
||||
it('respect the cursor_uri option if there is support', function () {
|
||||
_forceCursorURIs(false);
|
||||
var display = new Display({ target: document.createElement('canvas'), prefer_js: true, viewport: false, cursor_uri: false });
|
||||
var display = new Display(document.createElement('canvas'), { prefer_js: true, viewport: false, cursor_uri: false });
|
||||
expect(display._cursor_uri).to.be.false;
|
||||
});
|
||||
});
|
||||
@@ -60,7 +60,7 @@ describe('Display/Canvas Helper', function () {
|
||||
describe('viewport handling', function () {
|
||||
var display;
|
||||
beforeEach(function () {
|
||||
display = new Display({ target: document.createElement('canvas'), prefer_js: false, viewport: true });
|
||||
display = new Display(document.createElement('canvas'), { prefer_js: false, viewport: true });
|
||||
display.resize(5, 5);
|
||||
display.viewportChangeSize(3, 3);
|
||||
display.viewportChangePos(1, 1);
|
||||
@@ -153,7 +153,7 @@ describe('Display/Canvas Helper', function () {
|
||||
describe('resizing', function () {
|
||||
var display;
|
||||
beforeEach(function () {
|
||||
display = new Display({ target: document.createElement('canvas'), prefer_js: false, viewport: false });
|
||||
display = new Display(document.createElement('canvas'), { prefer_js: false, viewport: false });
|
||||
display.resize(4, 4);
|
||||
});
|
||||
|
||||
@@ -214,11 +214,11 @@ describe('Display/Canvas Helper', function () {
|
||||
var canvas;
|
||||
|
||||
beforeEach(function () {
|
||||
display = new Display({ target: document.createElement('canvas'), prefer_js: false, viewport: true });
|
||||
canvas = document.createElement('canvas');
|
||||
display = new Display(canvas, { prefer_js: false, viewport: true });
|
||||
display.resize(4, 4);
|
||||
display.viewportChangeSize(3, 3);
|
||||
display.viewportChangePos(1, 1);
|
||||
canvas = display.get_target();
|
||||
document.body.appendChild(canvas);
|
||||
});
|
||||
|
||||
@@ -254,9 +254,9 @@ describe('Display/Canvas Helper', function () {
|
||||
var canvas;
|
||||
|
||||
beforeEach(function () {
|
||||
display = new Display({ target: document.createElement('canvas'), prefer_js: false, viewport: true });
|
||||
canvas = document.createElement('canvas');
|
||||
display = new Display(canvas, { prefer_js: false, viewport: true });
|
||||
display.resize(4, 3);
|
||||
canvas = display.get_target();
|
||||
document.body.appendChild(canvas);
|
||||
});
|
||||
|
||||
@@ -314,7 +314,7 @@ describe('Display/Canvas Helper', function () {
|
||||
function drawing_tests (pref_js) {
|
||||
var display;
|
||||
beforeEach(function () {
|
||||
display = new Display({ target: document.createElement('canvas'), prefer_js: pref_js });
|
||||
display = new Display(document.createElement('canvas'), { prefer_js: pref_js });
|
||||
display.resize(4, 4);
|
||||
});
|
||||
|
||||
@@ -428,7 +428,7 @@ describe('Display/Canvas Helper', function () {
|
||||
describe('the render queue processor', function () {
|
||||
var display;
|
||||
beforeEach(function () {
|
||||
display = new Display({ target: document.createElement('canvas'), prefer_js: false });
|
||||
display = new Display(document.createElement('canvas'), { prefer_js: false });
|
||||
display.resize(4, 4);
|
||||
sinon.spy(display, '_scan_renderQ');
|
||||
});
|
||||
|
||||
+26
-26
@@ -31,7 +31,7 @@ describe('Key Event Handling', function() {
|
||||
describe('Decode Keyboard Events', function() {
|
||||
it('should decode keydown events', function(done) {
|
||||
if (isIE() || isEdge()) this.skip();
|
||||
var kbd = new Keyboard({
|
||||
var kbd = new Keyboard(document, {
|
||||
onKeyEvent: function(keysym, code, down) {
|
||||
expect(keysym).to.be.equal(0x61);
|
||||
expect(code).to.be.equal('KeyA');
|
||||
@@ -43,7 +43,7 @@ describe('Key Event Handling', function() {
|
||||
it('should decode keyup events', function(done) {
|
||||
if (isIE() || isEdge()) this.skip();
|
||||
var calls = 0;
|
||||
var kbd = new Keyboard({
|
||||
var kbd = new Keyboard(document, {
|
||||
onKeyEvent: function(keysym, code, down) {
|
||||
expect(keysym).to.be.equal(0x61);
|
||||
expect(code).to.be.equal('KeyA');
|
||||
@@ -59,12 +59,12 @@ describe('Key Event Handling', function() {
|
||||
describe('Legacy keypress Events', function() {
|
||||
it('should wait for keypress when needed', function() {
|
||||
var callback = sinon.spy();
|
||||
var kbd = new Keyboard({onKeyEvent: callback});
|
||||
var kbd = new Keyboard(document, {onKeyEvent: callback});
|
||||
kbd._handleKeyDown(keyevent('keydown', {code: 'KeyA', keyCode: 0x41}));
|
||||
expect(callback).to.not.have.been.called;
|
||||
});
|
||||
it('should decode keypress events', function(done) {
|
||||
var kbd = new Keyboard({
|
||||
var kbd = new Keyboard(document, {
|
||||
onKeyEvent: function(keysym, code, down) {
|
||||
expect(keysym).to.be.equal(0x61);
|
||||
expect(code).to.be.equal('KeyA');
|
||||
@@ -76,13 +76,13 @@ describe('Key Event Handling', function() {
|
||||
});
|
||||
it('should ignore keypress with different code', function() {
|
||||
var callback = sinon.spy();
|
||||
var kbd = new Keyboard({onKeyEvent: callback});
|
||||
var kbd = new Keyboard(document, {onKeyEvent: callback});
|
||||
kbd._handleKeyDown(keyevent('keydown', {code: 'KeyA', keyCode: 0x41}));
|
||||
kbd._handleKeyPress(keyevent('keypress', {code: 'KeyB', charCode: 0x61}));
|
||||
expect(callback).to.not.have.been.called;
|
||||
});
|
||||
it('should handle keypress with missing code', function(done) {
|
||||
var kbd = new Keyboard({
|
||||
var kbd = new Keyboard(document, {
|
||||
onKeyEvent: function(keysym, code, down) {
|
||||
expect(keysym).to.be.equal(0x61);
|
||||
expect(code).to.be.equal('KeyA');
|
||||
@@ -93,7 +93,7 @@ describe('Key Event Handling', function() {
|
||||
kbd._handleKeyPress(keyevent('keypress', {charCode: 0x61}));
|
||||
});
|
||||
it('should guess key if no keypress and numeric key', function(done) {
|
||||
var kbd = new Keyboard({
|
||||
var kbd = new Keyboard(document, {
|
||||
onKeyEvent: function(keysym, code, down) {
|
||||
expect(keysym).to.be.equal(0x32);
|
||||
expect(code).to.be.equal('Digit2');
|
||||
@@ -103,7 +103,7 @@ describe('Key Event Handling', function() {
|
||||
kbd._handleKeyDown(keyevent('keydown', {code: 'Digit2', keyCode: 0x32}));
|
||||
});
|
||||
it('should guess key if no keypress and alpha key', function(done) {
|
||||
var kbd = new Keyboard({
|
||||
var kbd = new Keyboard(document, {
|
||||
onKeyEvent: function(keysym, code, down) {
|
||||
expect(keysym).to.be.equal(0x61);
|
||||
expect(code).to.be.equal('KeyA');
|
||||
@@ -113,7 +113,7 @@ describe('Key Event Handling', function() {
|
||||
kbd._handleKeyDown(keyevent('keydown', {code: 'KeyA', keyCode: 0x41, shiftKey: false}));
|
||||
});
|
||||
it('should guess key if no keypress and alpha key (with shift)', function(done) {
|
||||
var kbd = new Keyboard({
|
||||
var kbd = new Keyboard(document, {
|
||||
onKeyEvent: function(keysym, code, down) {
|
||||
expect(keysym).to.be.equal(0x41);
|
||||
expect(code).to.be.equal('KeyA');
|
||||
@@ -123,7 +123,7 @@ describe('Key Event Handling', function() {
|
||||
kbd._handleKeyDown(keyevent('keydown', {code: 'KeyA', keyCode: 0x41, shiftKey: true}));
|
||||
});
|
||||
it('should not guess key if no keypress and unknown key', function(done) {
|
||||
var kbd = new Keyboard({
|
||||
var kbd = new Keyboard(document, {
|
||||
onKeyEvent: function(keysym, code, down) {
|
||||
expect(keysym).to.be.equal(0);
|
||||
expect(code).to.be.equal('KeyA');
|
||||
@@ -139,7 +139,7 @@ describe('Key Event Handling', function() {
|
||||
if (isIE() || isEdge()) this.skip();
|
||||
});
|
||||
it('should suppress anything with a valid key', function() {
|
||||
var kbd = new Keyboard({});
|
||||
var kbd = new Keyboard(document, {});
|
||||
var evt = keyevent('keydown', {code: 'KeyA', key: 'a'});
|
||||
kbd._handleKeyDown(evt);
|
||||
expect(evt.preventDefault).to.have.been.called;
|
||||
@@ -148,13 +148,13 @@ describe('Key Event Handling', function() {
|
||||
expect(evt.preventDefault).to.have.been.called;
|
||||
});
|
||||
it('should not suppress keys without key', function() {
|
||||
var kbd = new Keyboard({});
|
||||
var kbd = new Keyboard(document, {});
|
||||
var evt = keyevent('keydown', {code: 'KeyA', keyCode: 0x41});
|
||||
kbd._handleKeyDown(evt);
|
||||
expect(evt.preventDefault).to.not.have.been.called;
|
||||
});
|
||||
it('should suppress the following keypress event', function() {
|
||||
var kbd = new Keyboard({});
|
||||
var kbd = new Keyboard(document, {});
|
||||
var evt = keyevent('keydown', {code: 'KeyA', keyCode: 0x41});
|
||||
kbd._handleKeyDown(evt);
|
||||
var evt = keyevent('keypress', {code: 'KeyA', charCode: 0x41});
|
||||
@@ -168,7 +168,7 @@ describe('Key Event Handling', function() {
|
||||
it('should fake keyup events for virtual keyboards', function(done) {
|
||||
if (isIE() || isEdge()) this.skip();
|
||||
var count = 0;
|
||||
var kbd = new Keyboard({
|
||||
var kbd = new Keyboard(document, {
|
||||
onKeyEvent: function(keysym, code, down) {
|
||||
switch (count++) {
|
||||
case 0:
|
||||
@@ -215,7 +215,7 @@ describe('Key Event Handling', function() {
|
||||
it('should fake keyup events on iOS', function(done) {
|
||||
if (isIE() || isEdge()) this.skip();
|
||||
var count = 0;
|
||||
var kbd = new Keyboard({
|
||||
var kbd = new Keyboard(document, {
|
||||
onKeyEvent: function(keysym, code, down) {
|
||||
switch (count++) {
|
||||
case 0:
|
||||
@@ -240,7 +240,7 @@ describe('Key Event Handling', function() {
|
||||
if (isIE() || isEdge()) this.skip();
|
||||
});
|
||||
it('should send release using the same keysym as the press', function(done) {
|
||||
var kbd = new Keyboard({
|
||||
var kbd = new Keyboard(document, {
|
||||
onKeyEvent: function(keysym, code, down) {
|
||||
expect(keysym).to.be.equal(0x61);
|
||||
expect(code).to.be.equal('KeyA');
|
||||
@@ -253,7 +253,7 @@ describe('Key Event Handling', function() {
|
||||
});
|
||||
it('should send the same keysym for multiple presses', function() {
|
||||
var count = 0;
|
||||
var kbd = new Keyboard({
|
||||
var kbd = new Keyboard(document, {
|
||||
onKeyEvent: function(keysym, code, down) {
|
||||
expect(keysym).to.be.equal(0x61);
|
||||
expect(code).to.be.equal('KeyA');
|
||||
@@ -266,14 +266,14 @@ describe('Key Event Handling', function() {
|
||||
});
|
||||
it('should do nothing on keyup events if no keys are down', function() {
|
||||
var callback = sinon.spy();
|
||||
var kbd = new Keyboard({onKeyEvent: callback});
|
||||
var kbd = new Keyboard(document, {onKeyEvent: callback});
|
||||
kbd._handleKeyUp(keyevent('keyup', {code: 'KeyA', key: 'a'}));
|
||||
expect(callback).to.not.have.been.called;
|
||||
});
|
||||
|
||||
describe('Legacy Events', function() {
|
||||
it('should track keys using keyCode if no code', function(done) {
|
||||
var kbd = new Keyboard({
|
||||
var kbd = new Keyboard(document, {
|
||||
onKeyEvent: function(keysym, code, down) {
|
||||
expect(keysym).to.be.equal(0x61);
|
||||
expect(code).to.be.equal('Platform65');
|
||||
@@ -293,7 +293,7 @@ describe('Key Event Handling', function() {
|
||||
kbd._handleKeyDown(keyevent('keydown', {keyCode: 229, key: 'a'}));
|
||||
});
|
||||
it('should track keys using keyIdentifier if no code', function(done) {
|
||||
var kbd = new Keyboard({
|
||||
var kbd = new Keyboard(document, {
|
||||
onKeyEvent: function(keysym, code, down) {
|
||||
expect(keysym).to.be.equal(0x61);
|
||||
expect(code).to.be.equal('Platform65');
|
||||
@@ -335,7 +335,7 @@ describe('Key Event Handling', function() {
|
||||
|
||||
it('should change Alt to AltGraph', function() {
|
||||
var count = 0;
|
||||
var kbd = new Keyboard({
|
||||
var kbd = new Keyboard(document, {
|
||||
onKeyEvent: function(keysym, code, down) {
|
||||
switch (count++) {
|
||||
case 0:
|
||||
@@ -353,7 +353,7 @@ describe('Key Event Handling', function() {
|
||||
expect(count).to.be.equal(2);
|
||||
});
|
||||
it('should change left Super to Alt', function(done) {
|
||||
var kbd = new Keyboard({
|
||||
var kbd = new Keyboard(document, {
|
||||
onKeyEvent: function(keysym, code, down) {
|
||||
expect(keysym).to.be.equal(0xFFE9);
|
||||
expect(code).to.be.equal('MetaLeft');
|
||||
@@ -362,7 +362,7 @@ describe('Key Event Handling', function() {
|
||||
kbd._handleKeyDown(keyevent('keydown', {code: 'MetaLeft', key: 'Meta', location: 1}));
|
||||
});
|
||||
it('should change right Super to left Super', function(done) {
|
||||
var kbd = new Keyboard({
|
||||
var kbd = new Keyboard(document, {
|
||||
onKeyEvent: function(keysym, code, down) {
|
||||
expect(keysym).to.be.equal(0xFFEB);
|
||||
expect(code).to.be.equal('MetaRight');
|
||||
@@ -400,7 +400,7 @@ describe('Key Event Handling', function() {
|
||||
|
||||
it('should generate fake undo/redo events on press when AltGraph is down', function() {
|
||||
var times_called = 0;
|
||||
var kbd = new Keyboard({
|
||||
var kbd = new Keyboard(document, {
|
||||
onKeyEvent: function(keysym, code, down) {
|
||||
switch(times_called++) {
|
||||
case 0:
|
||||
@@ -449,7 +449,7 @@ describe('Key Event Handling', function() {
|
||||
});
|
||||
it('should no do anything on key release', function() {
|
||||
var times_called = 0;
|
||||
var kbd = new Keyboard({
|
||||
var kbd = new Keyboard(document, {
|
||||
onKeyEvent: function(keysym, code, down) {
|
||||
switch(times_called++) {
|
||||
case 7:
|
||||
@@ -469,7 +469,7 @@ describe('Key Event Handling', function() {
|
||||
});
|
||||
it('should not consider a char modifier to be down on the modifier key itself', function() {
|
||||
var times_called = 0;
|
||||
var kbd = new Keyboard({
|
||||
var kbd = new Keyboard(document, {
|
||||
onKeyEvent: function(keysym, code, down) {
|
||||
switch(times_called++) {
|
||||
case 0:
|
||||
|
||||
+20
-28
@@ -33,47 +33,44 @@ describe('Mouse Event Handling', function() {
|
||||
|
||||
describe('Decode Mouse Events', function() {
|
||||
it('should decode mousedown events', function(done) {
|
||||
var mouse = new Mouse({
|
||||
var mouse = new Mouse(target, {
|
||||
onMouseButton: function(x, y, down, bmask) {
|
||||
expect(bmask).to.be.equal(0x01);
|
||||
expect(down).to.be.equal(1);
|
||||
done();
|
||||
},
|
||||
target: target
|
||||
}
|
||||
});
|
||||
mouse._handleMouseDown(mouseevent('mousedown', { button: '0x01' }));
|
||||
});
|
||||
it('should decode mouseup events', function(done) {
|
||||
var calls = 0;
|
||||
var mouse = new Mouse({
|
||||
var mouse = new Mouse(target, {
|
||||
onMouseButton: function(x, y, down, bmask) {
|
||||
expect(bmask).to.be.equal(0x01);
|
||||
if (calls++ === 1) {
|
||||
expect(down).to.not.be.equal(1);
|
||||
done();
|
||||
}
|
||||
},
|
||||
target: target
|
||||
}
|
||||
});
|
||||
mouse._handleMouseDown(mouseevent('mousedown', { button: '0x01' }));
|
||||
mouse._handleMouseUp(mouseevent('mouseup', { button: '0x01' }));
|
||||
});
|
||||
it('should decode mousemove events', function(done) {
|
||||
var mouse = new Mouse({
|
||||
var mouse = new Mouse(target, {
|
||||
onMouseMove: function(x, y) {
|
||||
// Note that target relative coordinates are sent
|
||||
expect(x).to.be.equal(40);
|
||||
expect(y).to.be.equal(10);
|
||||
done();
|
||||
},
|
||||
target: target
|
||||
}
|
||||
});
|
||||
mouse._handleMouseMove(mouseevent('mousemove',
|
||||
{ clientX: 50, clientY: 20 }));
|
||||
});
|
||||
it('should decode mousewheel events', function(done) {
|
||||
var calls = 0;
|
||||
var mouse = new Mouse({
|
||||
var mouse = new Mouse(target, {
|
||||
onMouseButton: function(x, y, down, bmask) {
|
||||
calls++;
|
||||
expect(bmask).to.be.equal(1<<6);
|
||||
@@ -83,8 +80,7 @@ describe('Mouse Event Handling', function() {
|
||||
expect(down).to.not.be.equal(1);
|
||||
done();
|
||||
}
|
||||
},
|
||||
target: target
|
||||
}
|
||||
});
|
||||
mouse._handleMouseWheel(mouseevent('mousewheel',
|
||||
{ deltaX: 50, deltaY: 0,
|
||||
@@ -99,7 +95,7 @@ describe('Mouse Event Handling', function() {
|
||||
|
||||
it('should use same pos for 2nd tap if close enough', function(done) {
|
||||
var calls = 0;
|
||||
var mouse = new Mouse({
|
||||
var mouse = new Mouse(target, {
|
||||
onMouseButton: function(x, y, down, bmask) {
|
||||
calls++;
|
||||
if (calls === 1) {
|
||||
@@ -112,8 +108,7 @@ describe('Mouse Event Handling', function() {
|
||||
expect(y).to.be.equal(36);
|
||||
done();
|
||||
}
|
||||
},
|
||||
target: target
|
||||
}
|
||||
});
|
||||
// touch events are sent in an array of events
|
||||
// with one item for each touch point
|
||||
@@ -132,7 +127,7 @@ describe('Mouse Event Handling', function() {
|
||||
|
||||
it('should not modify 2nd tap pos if far apart', function(done) {
|
||||
var calls = 0;
|
||||
var mouse = new Mouse({
|
||||
var mouse = new Mouse(target, {
|
||||
onMouseButton: function(x, y, down, bmask) {
|
||||
calls++;
|
||||
if (calls === 1) {
|
||||
@@ -145,8 +140,7 @@ describe('Mouse Event Handling', function() {
|
||||
expect(y).to.not.be.equal(36);
|
||||
done();
|
||||
}
|
||||
},
|
||||
target: target
|
||||
}
|
||||
});
|
||||
mouse._handleMouseDown(touchevent(
|
||||
'touchstart', { touches: [{ clientX: 78, clientY: 46 }]}));
|
||||
@@ -163,7 +157,7 @@ describe('Mouse Event Handling', function() {
|
||||
|
||||
it('should not modify 2nd tap pos if not soon enough', function(done) {
|
||||
var calls = 0;
|
||||
var mouse = new Mouse({
|
||||
var mouse = new Mouse(target, {
|
||||
onMouseButton: function(x, y, down, bmask) {
|
||||
calls++;
|
||||
if (calls === 1) {
|
||||
@@ -176,8 +170,7 @@ describe('Mouse Event Handling', function() {
|
||||
expect(y).to.not.be.equal(36);
|
||||
done();
|
||||
}
|
||||
},
|
||||
target: target
|
||||
}
|
||||
});
|
||||
mouse._handleMouseDown(touchevent(
|
||||
'touchstart', { touches: [{ clientX: 78, clientY: 46 }]}));
|
||||
@@ -194,7 +187,7 @@ describe('Mouse Event Handling', function() {
|
||||
|
||||
it('should not modify 2nd tap pos if not touch', function(done) {
|
||||
var calls = 0;
|
||||
var mouse = new Mouse({
|
||||
var mouse = new Mouse(target, {
|
||||
onMouseButton: function(x, y, down, bmask) {
|
||||
calls++;
|
||||
if (calls === 1) {
|
||||
@@ -207,8 +200,7 @@ describe('Mouse Event Handling', function() {
|
||||
expect(y).to.not.be.equal(36);
|
||||
done();
|
||||
}
|
||||
},
|
||||
target: target
|
||||
}
|
||||
});
|
||||
mouse._handleMouseDown(mouseevent(
|
||||
'mousedown', { button: '0x01', clientX: 78, clientY: 46 }));
|
||||
@@ -232,7 +224,7 @@ describe('Mouse Event Handling', function() {
|
||||
|
||||
it('should accumulate wheel events if small enough', function () {
|
||||
var callback = sinon.spy();
|
||||
var mouse = new Mouse({ onMouseButton: callback, target: target });
|
||||
var mouse = new Mouse(target, { onMouseButton: callback });
|
||||
|
||||
mouse._handleMouseWheel(mouseevent(
|
||||
'mousewheel', { clientX: 18, clientY: 40,
|
||||
@@ -265,7 +257,7 @@ describe('Mouse Event Handling', function() {
|
||||
|
||||
it('should not accumulate large wheel events', function () {
|
||||
var callback = sinon.spy();
|
||||
var mouse = new Mouse({ onMouseButton: callback, target: target });
|
||||
var mouse = new Mouse(target, { onMouseButton: callback });
|
||||
|
||||
mouse._handleMouseWheel(mouseevent(
|
||||
'mousewheel', { clientX: 18, clientY: 40,
|
||||
@@ -284,7 +276,7 @@ describe('Mouse Event Handling', function() {
|
||||
|
||||
it('should send even small wheel events after a timeout', function () {
|
||||
var callback = sinon.spy();
|
||||
var mouse = new Mouse({ onMouseButton: callback, target: target });
|
||||
var mouse = new Mouse(target, { onMouseButton: callback });
|
||||
|
||||
mouse._handleMouseWheel(mouseevent(
|
||||
'mousewheel', { clientX: 18, clientY: 40,
|
||||
@@ -296,7 +288,7 @@ describe('Mouse Event Handling', function() {
|
||||
|
||||
it('should account for non-zero deltaMode', function () {
|
||||
var callback = sinon.spy();
|
||||
var mouse = new Mouse({ onMouseButton: callback, target: target });
|
||||
var mouse = new Mouse(target, { onMouseButton: callback });
|
||||
|
||||
mouse._handleMouseWheel(mouseevent(
|
||||
'mousewheel', { clientX: 18, clientY: 40,
|
||||
|
||||
+34
-33
@@ -10,12 +10,8 @@ import FakeWebSocket from './fake.websocket.js';
|
||||
import sinon from '../vendor/sinon.js';
|
||||
|
||||
function make_rfb (extra_opts) {
|
||||
if (!extra_opts) {
|
||||
extra_opts = {};
|
||||
}
|
||||
|
||||
extra_opts.target = extra_opts.target || document.createElement('canvas');
|
||||
return new RFB(extra_opts);
|
||||
extra_opts = extra_opts || {};
|
||||
return new RFB(document.createElement('canvas'), extra_opts);
|
||||
}
|
||||
|
||||
var push8 = function (arr, num) {
|
||||
@@ -581,15 +577,6 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
||||
client._sock._websocket._open();
|
||||
});
|
||||
|
||||
it('should interpret version 000.000 as a repeater', function () {
|
||||
client._repeaterID = '12345';
|
||||
send_ver('000.000', client);
|
||||
expect(client._rfb_version).to.equal(0);
|
||||
|
||||
var sent_data = client._sock._websocket._get_sent_data();
|
||||
expect(new Uint8Array(sent_data.buffer, 0, 9)).to.array.equal(new Uint8Array([73, 68, 58, 49, 50, 51, 52, 53, 0]));
|
||||
});
|
||||
|
||||
it('should interpret version 003.003 as version 3.3', function () {
|
||||
send_ver('003.003', client);
|
||||
expect(client._rfb_version).to.equal(3.3);
|
||||
@@ -637,19 +624,6 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('should handle two step repeater negotiation', function () {
|
||||
client._repeaterID = '12345';
|
||||
|
||||
send_ver('000.000', client);
|
||||
expect(client._rfb_version).to.equal(0);
|
||||
var sent_data = client._sock._websocket._get_sent_data();
|
||||
expect(new Uint8Array(sent_data.buffer, 0, 9)).to.array.equal(new Uint8Array([73, 68, 58, 49, 50, 51, 52, 53, 0]));
|
||||
expect(sent_data).to.have.length(250);
|
||||
|
||||
send_ver('003.008', client);
|
||||
expect(client._rfb_version).to.equal(3.8);
|
||||
});
|
||||
|
||||
it('should send back the interpreted version', function () {
|
||||
send_ver('004.000', client);
|
||||
|
||||
@@ -666,6 +640,29 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
||||
send_ver('003.008', client);
|
||||
expect(client._rfb_init_state).to.equal('Security');
|
||||
});
|
||||
|
||||
describe('Repeater', function () {
|
||||
it('should interpret version 000.000 as a repeater', function () {
|
||||
client = make_rfb();
|
||||
client.connect('wss://host:8675', { repeaterID: "12345" });
|
||||
client._sock._websocket._open();
|
||||
send_ver('000.000', client);
|
||||
expect(client._rfb_version).to.equal(0);
|
||||
|
||||
var sent_data = client._sock._websocket._get_sent_data();
|
||||
expect(new Uint8Array(sent_data.buffer, 0, 9)).to.array.equal(new Uint8Array([73, 68, 58, 49, 50, 51, 52, 53, 0]));
|
||||
expect(sent_data).to.have.length(250);
|
||||
});
|
||||
|
||||
it('should handle two step repeater negotiation', function () {
|
||||
client = make_rfb();
|
||||
client.connect('wss://host:8675', { repeaterID: "12345" });
|
||||
client._sock._websocket._open();
|
||||
send_ver('000.000', client);
|
||||
send_ver('003.008', client);
|
||||
expect(client._rfb_version).to.equal(3.8);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Security', function () {
|
||||
@@ -1016,24 +1013,28 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
||||
|
||||
beforeEach(function () {
|
||||
client = make_rfb();
|
||||
client.connect('wss://host:8675');
|
||||
client._sock._websocket._open();
|
||||
client._rfb_init_state = 'SecurityResult';
|
||||
});
|
||||
|
||||
it('should transition to the ServerInitialisation state', function () {
|
||||
client.connect('wss://host:8675');
|
||||
client._sock._websocket._open();
|
||||
client._rfb_init_state = 'SecurityResult';
|
||||
client._sock._websocket._receive_data(new Uint8Array([0, 0, 0, 0]));
|
||||
expect(client._rfb_init_state).to.equal('ServerInitialisation');
|
||||
});
|
||||
|
||||
it('should send 1 if we are in shared mode', function () {
|
||||
client.set_shared(true);
|
||||
client.connect('wss://host:8675', { shared: true });
|
||||
client._sock._websocket._open();
|
||||
client._rfb_init_state = 'SecurityResult';
|
||||
client._sock._websocket._receive_data(new Uint8Array([0, 0, 0, 0]));
|
||||
expect(client._sock).to.have.sent(new Uint8Array([1]));
|
||||
});
|
||||
|
||||
it('should send 0 if we are not in shared mode', function () {
|
||||
client.set_shared(false);
|
||||
client.connect('wss://host:8675', { shared: false });
|
||||
client._sock._websocket._open();
|
||||
client._rfb_init_state = 'SecurityResult';
|
||||
client._sock._websocket._receive_data(new Uint8Array([0, 0, 0, 0]));
|
||||
expect(client._sock).to.have.sent(new Uint8Array([0]));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user