Possibility to disable JSONP. Emitting an error if JSONP is the only available transport.

This commit is contained in:
Tony Kovanen
2014-06-23 01:31:17 +03:00
parent c090f20211
commit 269bdfff23
3 changed files with 44 additions and 2 deletions

View File

@@ -1,6 +1,12 @@
var expect = require('expect.js');
var eio = require('../');
var wsSupport = require('has-cors');
var uagent = navigator.userAgent;
var isOldSimulator = ~uagent.indexOf('iPhone OS 4') || ~uagent.indexOf('iPhone OS 5');
var isIE11 = !!navigator.userAgent.match(/Trident.*rv[ :]*11\./); // ws doesn't work at all in sauce labs
var isAndroid = navigator.userAgent.match(/Android/i);
describe('connection', function() {
this.timeout(20000);
@@ -55,7 +61,7 @@ describe('connection', function() {
}, 1200);
});
});
// no `Worker` on old IE
if (global.Worker) {
it('should work in a worker', function(done){
@@ -66,4 +72,23 @@ describe('connection', function() {
};
});
}
it('should not connect at all when JSONP forced and disabled', function(done) {
var socket = eio.Socket({ transports: ['polling'], forceJSONP: true, noJSONP: true });
socket.on('error', function(msg) {
expect(msg).to.be('No transports available');
done();
});
});
if (wsSupport && !isOldSimulator && !isAndroid && !isIE11) {
it('should connect with ws when JSONP forced and disabled', function(done) {
var socket = eio.Socket({ transports: ['polling', 'websocket'], forceJSONP: true, noJSONP: true });
socket.on('open', function() {
expect(socket.transport.name).to.be('websocket');
done();
});
});
}
});