Add support for DesktopName extension

This extension allows session name to be changed during runtime.
This commit is contained in:
Niko Lehto
2019-09-04 14:23:37 +02:00
committed by Lauri Kasanen
parent c16cc6e2b9
commit 8c43287afb
3 changed files with 55 additions and 5 deletions

View File

@@ -41,6 +41,13 @@ function push32(arr, num) {
num & 0xFF);
}
function pushString(arr, string) {
let utf8 = unescape(encodeURIComponent(string));
for (let i = 0; i < utf8.length; i++) {
arr.push(utf8.charCodeAt(i));
}
}
describe('Remote Frame Buffer Protocol Client', function () {
let clock;
let raf;
@@ -2128,6 +2135,21 @@ describe('Remote Frame Buffer Protocol Client', function () {
send_fbu_msg([{ x: 0, y: 0, width: 0, height: 0, encoding: -224}], [[]], client, 100);
expect(client._FBU.rects).to.equal(0);
});
it('should handle the DesktopName pseudo-encoding', function () {
let data = [];
push32(data, 9);
pushString(data, "some name");
const spy = sinon.spy();
client.addEventListener("desktopname", spy);
send_fbu_msg([{ x: 0, y: 0, width: 0, height: 0, encoding: -307 }], [data], client);
expect(client._fb_name).to.equal('some name');
expect(spy).to.have.been.calledOnce;
expect(spy.args[0][0].detail.name).to.equal('some name');
});
});
});