diff --git a/.travis.yml b/.travis.yml index 3b742c308..b0231ee09 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,37 +4,20 @@ node_js: - '4' - '6' - '8' + - node git: depth: 1 notifications: - irc: "irc.freenode.org#socket.io" + irc: irc.freenode.org#socket.io matrix: include: - - node_js: 'node' - env: BROWSER_NAME=chrome BROWSER_VERSION=latest - - node_js: 'node' - env: BROWSER_NAME=safari BROWSER_VERSION=latest - - node_js: 'node' - env: BROWSER_NAME=firefox BROWSER_VERSION=latest - - node_js: 'node' - env: BROWSER_NAME=ie BROWSER_VERSION=8 - - node_js: 'node' - env: BROWSER_NAME=ie BROWSER_VERSION=9 - - node_js: 'node' - env: BROWSER_NAME=ie BROWSER_VERSION=10 - - node_js: 'node' - env: BROWSER_NAME=ie BROWSER_VERSION=11 - - node_js: 'node' - env: BROWSER_NAME=iphone BROWSER_VERSION=8.4 - - node_js: 'node' - env: BROWSER_NAME=iphone BROWSER_VERSION=9.2 - - node_js: 'node' - env: BROWSER_NAME=iphone BROWSER_VERSION=10.0 - - node_js: 'node' - env: BROWSER_NAME=android BROWSER_VERSION=4.4 - - node_js: 'node' - env: BROWSER_NAME=android BROWSER_VERSION=5.1 - - node_js: 'node' - env: BROWSER_NAME=ipad BROWSER_VERSION=9.3 - - node_js: 'node' - env: BROWSER_NAME=ipad BROWSER_VERSION=10.0 + - node_js: node + env: BROWSERS=1 +cache: + directories: + - node_modules +env: + global: + - secure: EeWHa83dNLzbmwn7tai2D7nnqRMhpbZrWh8054je+6M2Iui6heV412ginyx+MfTBkDe9PF9yPhoknpJ1ZiitbFHVhdofzJJErEHWS33gLVXTL2PU1IzAU9h9T/wVSrVsiNfTARW4Bh9JexVl8x8erTzSh/P6fH2KWx4CaPtmYG4= + - secure: 0yzzTFfFW032oyHzLJPkjgtehnJiqbpmI5kPosjC3Nk0AT6wLSdXuo1Cv5mccggPoqtHQ4oo7e4roLgRaZD34ihc2n98oT5LUPoU6ifA2Z+1zmdmFS9oYTvmkMxaxHlyYuWn47INukGLVJkH5mukb4QDji+v2LjbZVGdVHL5iNM= + - secure: l2aD07VwTMZh+8dcE7u7X0lpdYuwl/wk5no1hxaOKvnHiaVSW39kEJFReO0EZXF/ld7teBNwdWVtRK0P28hKjXEr4Z1OjvGyz6WYZ6cSwxAPmDoTaKC4z1NsAlatqjOKyjSqadncYzWwKS+Trxgj8eO1mZt5h+EvgU2gz6l2N+I= diff --git a/gulpfile.js b/gulpfile.js index ca9670783..9bcb626d3 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -38,7 +38,7 @@ const FILES_TO_CLEAN = [ ]; gulp.task('test', ['lint'], function () { - if (process.env.hasOwnProperty('BROWSER_NAME')) { + if (process.env.hasOwnProperty('BROWSERS')) { return testZuul(); } else { return testNode(); @@ -78,18 +78,7 @@ function testNode () { // runs zuul through shell process function testZuul () { const ZUUL_CMD = './node_modules/zuul/bin/zuul'; - const args = [ - '--browser-name', - process.env.BROWSER_NAME, - '--browser-version', - process.env.BROWSER_VERSION - ]; - if (process.env.hasOwnProperty('BROWSER_PLATFORM')) { - args.push('--browser-platform'); - args.push(process.env.BROWSER_PLATFORM); - } - args.push(TEST_FILE); - const zuulChild = child.spawn(ZUUL_CMD, args, { stdio: 'inherit' }); + const zuulChild = child.spawn(ZUUL_CMD, [TEST_FILE], { stdio: 'inherit' }); zuulChild.on('exit', function (code) { cleanFiles(FILES_TO_CLEAN); process.exit(code); diff --git a/lib/transports/polling-xhr.js b/lib/transports/polling-xhr.js index 52048fe65..c6f409200 100755 --- a/lib/transports/polling-xhr.js +++ b/lib/transports/polling-xhr.js @@ -358,11 +358,9 @@ Request.prototype.onLoad = function () { contentType = this.xhr.getResponseHeader('Content-Type'); } catch (e) {} if (contentType === 'application/octet-stream') { - if (this.xhr.responseType === 'arraybuffer') { - data = this.xhr.response || this.xhr.responseText; - } else { - data = String.fromCharCode.apply(null, new Uint8Array(this.xhr.response)); - } + data = this.xhr.response || this.xhr.responseText; + } else if (this.xhr.responseType === 'arraybuffer') { + data = String.fromCharCode.apply(null, new Uint8Array(this.xhr.response)); } else { data = this.xhr.responseText; } diff --git a/package.json b/package.json index ba8a92b8e..4cd44caa1 100644 --- a/package.json +++ b/package.json @@ -58,6 +58,7 @@ "gulp-task-listing": "1.0.1", "istanbul": "^0.4.5", "mocha": "^3.2.0", + "socket.io-browsers": "^1.0.0", "webpack": "1.12.12", "webpack-stream": "^3.2.0", "zuul": "^3.11.1", diff --git a/test/engine.io-client.js b/test/engine.io-client.js index 4e8c2f0e8..a84550685 100644 --- a/test/engine.io-client.js +++ b/test/engine.io-client.js @@ -2,6 +2,8 @@ var expect = require('expect.js'); var eio = require('../'); +var expectedPort = global.location && 'https:' === location.protocol ? '443' : '80'; + describe('engine.io-client', function () { var open; @@ -45,7 +47,7 @@ describe('engine.io-client', function () { it('should properly parse a host without port', function () { var client = eio({ host: 'localhost' }); expect(client.hostname).to.be('localhost'); - expect(client.port).to.be('80'); + expect(client.port).to.be(expectedPort); }); it('should properly parse a host with port', function () { @@ -69,7 +71,7 @@ describe('engine.io-client', function () { it('should properly parse an IPv6 host without port (1/2)', function () { var client = eio({ host: '[::1]' }); expect(client.hostname).to.be('::1'); - expect(client.port).to.be('80'); + expect(client.port).to.be(expectedPort); }); it('should properly parse an IPv6 host without port (2/2)', function () { @@ -87,6 +89,6 @@ describe('engine.io-client', function () { it('should properly parse an IPv6 host without brace', function () { var client = eio({ host: '::1' }); expect(client.hostname).to.be('::1'); - expect(client.port).to.be('80'); + expect(client.port).to.be(expectedPort); }); }); diff --git a/zuul.config.js b/zuul.config.js index d2b94d137..fcb9ac9ad 100644 --- a/zuul.config.js +++ b/zuul.config.js @@ -1,8 +1,22 @@ +'use strict'; + +var browsers = require('socket.io-browsers'); var zuulConfig = module.exports = { ui: 'mocha-bdd', + + // test on localhost by default + local: true, + + concurrency: 2, // ngrok only accepts two tunnels by default + // if browser does not sends output in 120s since last output: + // stop testing, something is wrong + browser_output_timeout: 120 * 1000, + browser_open_timeout: 60 * 4 * 1000, + // we want to be notified something is wrong asap, so no retry + browser_retries: 1, + server: './test/support/server.js', - local: true, // test on localhost by default builder: 'zuul-builder-webpack', webpack: require('./support/webpack.config.js') }; @@ -11,7 +25,9 @@ if (process.env.CI === 'true') { zuulConfig.local = false; zuulConfig.tunnel = { type: 'ngrok', - authtoken: '6Aw8vTgcG5EvXdQywVvbh_3fMxvd4Q7dcL2caAHAFjV', - proto: 'tcp' + bind_tls: true }; } + +var isPullRequest = process.env.TRAVIS_PULL_REQUEST && process.env.TRAVIS_PULL_REQUEST !== 'false'; +zuulConfig.browsers = isPullRequest ? browsers.pullRequest : browsers.all;