mirror of
https://github.com/socketio/socket.io.git
synced 2026-04-30 03:00:39 -04:00
Possibility to disable JSONP. Emitting an error if JSONP is the only available transport.
This commit is contained in:
@@ -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();
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user