Fix tests after changing auth negotiation

PhantomJS has a very basic implementation of Uint8Array, so we
need to help it out a bit.
This commit is contained in:
Pierre Ossman
2017-02-13 15:00:32 +01:00
parent 95533c579e
commit 0ee5ca6ebe
2 changed files with 26 additions and 7 deletions

View File

@@ -795,15 +795,26 @@
var types = this._sock.rQshiftBytes(num_types);
Util.Debug("Server security types: " + types);
// Polyfill since IE and PhantomJS doesn't have
// TypedArray.includes()
function includes(item, array) {
for (var i = 0; i < array.length; i++) {
if (array[i] === item) {
return true;
}
}
return false;
}
// Look for each auth in preferred order
this._rfb_auth_scheme = 0;
if (types.indexOf(1) !== -1) {
if (includes(1, types)) {
this._rfb_auth_scheme = 1; // None
} else if (types.indexOf(22) !== -1) {
} else if (includes(22, types)) {
this._rfb_auth_scheme = 22; // XVP
} else if (types.indexOf(16) !== -1) {
} else if (includes(16, types)) {
this._rfb_auth_scheme = 16; // Tight
} else if (types.indexOf(2) !== -1) {
} else if (includes(2, types)) {
this._rfb_auth_scheme = 2; // VNC Auth
} else {
return this._fail("Unsupported server",