[Pkg-javascript-commits] [sockjs-client] 50/350: Fix browserify issues. Move tests to js.

tonnerre at ancient-solutions.com tonnerre at ancient-solutions.com
Fri Aug 5 01:03:40 UTC 2016


This is an automated email from the git hooks/post-receive script.

tonnerre-guest pushed a commit to branch upstream
in repository sockjs-client.

commit 2a62e8b3ab1a286d726002fb09413d70756faf46
Author: Bryce Kahle <bkahle at gmail.com>
Date:   Mon May 26 18:39:52 2014 -0400

    Fix browserify issues. Move tests to js.
---
 .gitignore                          |   2 +
 .travis.yml                         |   2 +-
 .zuul.yml                           |   3 +-
 Makefile                            |  58 +-----
 VERSION-GEN                         |  17 --
 bin/render.coffee                   | 125 -------------
 gulpfile.js                         |  46 ++++-
 lib/eventemitter.js                 |   2 +-
 lib/info-receiver-iframe.js         |   2 +-
 lib/info-receiver.js                |   5 +-
 lib/sockjs.js                       |  18 +-
 lib/trans-eventsource.js            |   4 +-
 lib/trans-iframe-htmlfile.js        |   4 +-
 lib/trans-iframe-xhr-polling.js     |   4 +-
 lib/trans-iframe.js                 |   5 +-
 lib/trans-jsonp-polling.js          |   1 +
 lib/utils.js                        |   2 +-
 lib/xhr-polling.js                  |   5 +-
 lib/xhr-streaming.js                |   4 +-
 package.json                        |  15 +-
 tests/html/src/domtests.coffee      | 134 --------------
 tests/html/src/endtoendtests.coffee | 136 --------------
 tests/html/src/protocols.coffee     |  12 --
 tests/html/src/tests.coffee         | 350 ------------------------------------
 tests/html/src/unittests.coffee     | 295 ------------------------------
 tests/server.js                     |  13 +-
 tests/sockjs_app.js                 |   3 +-
 tests/sockjs_server.js              |   5 +-
 version                             |   1 -
 29 files changed, 95 insertions(+), 1178 deletions(-)

diff --git a/.gitignore b/.gitignore
index 00ae4e5..1ead977 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,9 @@
 .pidfile.pid
 node_modules
+npm-debug.log
 sockjs.js
 sockjs.min.js
 tests/html/lib/*.js
 .testling_env.sh
 testling.js
+build/
diff --git a/.travis.yml b/.travis.yml
index c8fbb19..0907c7f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,7 +2,7 @@ language: node_js
 node_js:
   - '0.10'
 before_script:
-  - "make build_tests"
+  - "gulp test"
 env:
   global:
   - secure: L36j3mbU1U2FiOhxYZrTZ7apVnb56gE+QFixsYyDpCRBrVW0q8WR9LTMJx+aPNdlzhRS5FT4gfInujPTnZeb+EvqEoYwtT+CeNG15XtGkfJDkfBFjBa4IZpJAjIwJB+0kKkZr9R7lQEEgy7H9FvLHY2N2WgdzuG8WZwiVRnkwVw=
diff --git a/.zuul.yml b/.zuul.yml
index 4614764..dea9388 100644
--- a/.zuul.yml
+++ b/.zuul.yml
@@ -1,10 +1,9 @@
 ui: qunit
 scripts:
-  - "http://cdnjs.cloudflare.com/ajax/libs/jquery/1.7.1/jquery.min.js"
+  - "static/jquery.min.js"
   - "config.js"
   - "domain.js"
   - "lib/sockjs.js"
-  - "lib/tests.js"
 server: ./tests/sockjs_server.js
 browsers:
   - name: chrome
diff --git a/Makefile b/Makefile
index a21be22..b88e22d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,62 +1,6 @@
 .PHONY: all build tests test serve clean
 
-COFFEE:=./node_modules/.bin/coffee
-
-all: sockjs.js
-
-build: sockjs.js sockjs.min.js
-
-sockjs.js: lib/*js version
-	@$(COFFEE) -v > /dev/null
-	$(COFFEE) bin/render.coffee --set-version "$(VER)" lib/all.js > $@
-
-sockjs.min.js: lib/*js version
-	@$(COFFEE) -v > /dev/null
-	$(COFFEE) bin/render.coffee --set-version "$(VER)" --minify lib/all.js > $@
-
-sockjs.pretty.js: lib/*js version
-	@$(COFFEE) -v > /dev/null
-	$(COFFEE) bin/render.coffee --set-version "$(VER)" --minify --pretty lib/all.js > $@
-
-tests/html/lib/sockjs.js: sockjs.js
-	mkdir -p tests/html/lib
-	cp $< $@
-
-tests/html/lib/%.js: tests/html/src/%.coffee
-	@$(COFFEE) -v > /dev/null
-	mkdir -p tests/html/lib
-	$(COFFEE) -o tests/html/lib/ -c --bare $<
-
-build_tests: tests/html/lib/sockjs.js tests/html/lib/tests.js \
-		tests/html/lib/unittests.js tests/html/lib/domtests.js \
-		tests/html/lib/endtoendtests.js tests/html/lib/protocols.js
-
-test: tests
-tests: build_tests
-	node tests/server.js
-
-
-serve:
-	@if [ -e .pidfile.pid ]; then			\
-		kill `cat .pidfile.pid`;		\
-		rm .pidfile.pid;			\
-	fi
-
-	@while [ 1 ]; do					\
-		make build_tests;				\
-		echo " [*] Running http server";		\
-		make test &					\
-		SRVPID=$$!;					\
-		echo $$SRVPID > .pidfile.pid;			\
-		echo " [*] Server pid: $$SRVPID";		\
-		inotifywait -r -q -e modify . ../sockjs-node;	\
-		kill `cat .pidfile.pid`;			\
-		rm -f .pidfile.pid;				\
-		sleep 0.1;					\
-	done
-
-clean:
-	rm -f sockjs*.js tests/html/lib/*.js
+test: node tests/server.js
 
 # To release:
 #   0) 'make prepare-release'
diff --git a/VERSION-GEN b/VERSION-GEN
deleted file mode 100755
index 1653203..0000000
--- a/VERSION-GEN
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/sh
-
-LF='
-'
-
-VN=$(git describe --match "v[0-9]*" --abbrev=4 HEAD 2>/dev/null)
-case "$VN" in
-    *$LF*) (exit 1) ;;
-v[0-9]*)
-        git update-index -q --refresh
-        test -z "$(git diff-index --name-only HEAD --)" ||
-        VN="$VN-dirty" ;;
-esac
-VN=$(echo "$VN" | sed -e 's/-/./g');
-VN=$(expr "$VN" : v*'\(.*\)')
-
-echo "$VN"
diff --git a/bin/render.coffee b/bin/render.coffee
deleted file mode 100644
index a686493..0000000
--- a/bin/render.coffee
+++ /dev/null
@@ -1,125 +0,0 @@
-#!/usr/bin/env coffee
-#
-# ***** BEGIN LICENSE BLOCK *****
-# Copyright (c) 2011-2012 VMware, Inc.
-#
-# For the license see COPYING.
-# ***** END LICENSE BLOCK *****
-
-
-fs = require('fs')
-uglify = require('uglify-js')
-optimist = require('optimist')
-
-array_flatten = (arr, acc) ->
-    if typeof acc is 'undefined'
-        acc = []
-    if typeof arr is 'string'
-        acc.push(arr)
-        return acc
-
-    if arr.constructor isnt Array
-        throw "Value is not an Array nor a String!"
-
-    for v in arr
-        if typeof v is 'string'
-            acc.push(v)
-        else if v.constructor is Array
-            array_flatten(v, acc)
-        else
-            throw "Value is not an Array nor a String!"
-    return acc
-
-stringify_unicode = (str) ->
-    str = str.replace /[\u0100-\uffff]/g, (ch) ->
-            return "\\u" + ('0000' + ch.charCodeAt(0).toString(16)).substr(-4)
-    str = str.replace /[\x00-\x08\x0b-\x1f\x7f-\xff]/g, (ch) ->
-            return "\\x" + ('00' + ch.charCodeAt(0).toString(16)).substr(-2)
-    return str
-
-
-minify = (data, minify_options)->
-    ast = uglify.parser.parse(data)
-    ast = uglify.uglify.ast_mangle(ast, minify_options)
-    ast = uglify.uglify.ast_squeeze(ast)
-    uglify.uglify.gen_code(ast, minify_options)
-
-render = (filename, depth, options) ->
-    tags =
-        include: (args) ->
-            if (args.length > 1 and args[1].indexOf('c') isnt -1 and
-                     options.minify is false)
-                options.comment = true
-            render(args[0], depth + '    ', options)
-        version: ->
-            options.version
-        include_and_minify: (args) ->
-            if (args.length > 1 and args[1].indexOf('c') isnt -1 and
-                     options.minify is false)
-                options.comment = true
-            d = render(args[0], depth + '    ', options)
-            if options.minify
-                return minify(array_flatten(d).join(''), options)
-            return d
-
-    console.warn(depth + " [.] Rendering", filename)
-
-    # no trailing whitespace
-    data = fs.readFileSync(filename, encoding='utf8').replace(/\s+$/, '')
-
-    content = []
-    if options.comment
-        content.push('\n// ' + depth + '[*] Including ' + filename + '\n')
-
-    elements = data.split(/<!--\s*([^>]+)\s*-->/g)
-    for i in [0...elements.length]
-        e = elements[i];
-        if i % 2 is 0
-            content.push(e)
-        else
-            p = e.split(' ')
-            content.push( tags[p[0]](p.slice(1)) )
-
-    if options.comment
-        content.push('\n// ' + depth + '[*] End of ' + filename + '\n')
-    return content
-
-
-main = ->
-    argv = optimist.options({
-        'c': {
-            alias: 'comment',
-            default: false,
-            describe: 'Add comments',
-        },
-        'm': {
-            alias: 'minify',
-            default: true,
-            describe: 'Minify javascript',
-        },
-        'p': {
-            alias: 'pretty',
-            default: true,
-            describe: 'Prettify javascript',
-        },
-        's': {
-            alias: 'set-version',
-            default: 'unknown',
-            describe: 'Set the value of version tag',
-        }})
-        .boolean('c')
-        .boolean('m')
-        .boolean('p')
-        .string('s')
-        .argv
-    options = {comment: argv.comment, minify: argv.minify, pretty: argv.pretty, toplevel: true, version: (argv.s || "unknown")}
-    filenames = argv._
-
-    content = for filename in filenames
-        render(filename, '', options)
-    content.push('\n')
-    process.stdout.write(
-        stringify_unicode(array_flatten(content).join('')),
-        'utf8')
-
-main()
diff --git a/gulpfile.js b/gulpfile.js
index e855df1..5746ed4 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -2,19 +2,49 @@
 
 var gulp = require('gulp')
   , browserify = require('browserify')
+  , exorcist = require('exorcist')
+  , mold = require('mold-source-map')
   , source = require('vinyl-source-stream')
-  , pkg = require('./package.json')
+  , path = require('path')
+  , jsRoot = path.join(__dirname, 'lib')
   ;
 
+function debugBuild() {
+  return browserify('./lib/sockjs.js')
+    .bundle({
+      standalone: 'SockJS'
+    , debug: true
+    })
+    .pipe(mold.transformSourcesRelativeTo(jsRoot))
+    .pipe(exorcist(path.join(__dirname, 'build/sockjs.js.map')))
+    .pipe(source('sockjs.js'))
+    .pipe(gulp.dest('./build/'))
+    ;
+}
+
 gulp.task('default', function() {
 
 });
 
-gulp.task('browserify', function() {
-    return browserify('./lib/sockjs.js')
-        .bundle({
-            standalone: 'SockJS'
-        })
-        .pipe(source('sockjs.js'))
-        .pipe(gulp.dest('./build/'));
+gulp.task('test', function() {
+  return debugBuild()
+    .pipe(gulp.dest('./tests/html/lib/'))
+    ;
+});
+
+gulp.task('browserify', debugBuild);
+
+gulp.task('browserify:min', function () {
+  return browserify('./lib/sockjs.js')
+    .plugin('minifyify', {
+      map: 'sockjs.min.js.map'
+    , compressPath: jsRoot
+    , output: './build/sockjs.min.js.map'
+    })
+    .bundle({
+      standalone: 'SockJS'
+    })
+    .pipe(source('sockjs.min.js'))
+    .pipe(gulp.dest('./build/'))
+    ;
 });
\ No newline at end of file
diff --git a/lib/eventemitter.js b/lib/eventemitter.js
index ad43524..3b0cb9b 100644
--- a/lib/eventemitter.js
+++ b/lib/eventemitter.js
@@ -8,7 +8,7 @@
  */
 
 var utils = require('./utils');
-var JSON3 = require('json3').noConflict();
+var JSON3 = require('json3');
 
 var EventEmitter = function(events) {
     var that = this;
diff --git a/lib/info-receiver-iframe.js b/lib/info-receiver-iframe.js
index 13d4873..ad32ffd 100644
--- a/lib/info-receiver-iframe.js
+++ b/lib/info-receiver-iframe.js
@@ -10,7 +10,7 @@
 var utils = require('./utils');
 var EventEmitter = require('./eventemitter');
 var IframeTransport = require('./trans-iframe');
-var JSON3 = require('json3').noConflict();
+var JSON3 = require('json3');
 
 function InfoReceiverIframe(base_url) {
     var that = this;
diff --git a/lib/info-receiver.js b/lib/info-receiver.js
index b900c9b..787abea 100644
--- a/lib/info-receiver.js
+++ b/lib/info-receiver.js
@@ -10,7 +10,8 @@
 var utils = require('./utils');
 var EventEmitter = require('./eventemitter');
 var FacadeJS = require('./facade');
-var JSON3 = require('json3').noConflict();
+var JSON3 = require('json3');
+var XHRLocalObject = require('./xhr-local');
 
 function InfoReceiver(base_url, AjaxObject) {
     var that = this;
@@ -54,7 +55,7 @@ InfoReceiver.prototype.doXhr = function(base_url, AjaxObject) {
 module.exports = InfoReceiver;
 
 var WInfoReceiverIframe = FacadeJS['w-iframe-info-receiver'] = function(ri, _trans_url, base_url) {
-    var ir = new InfoReceiver(base_url, utils.XHRLocalObject);
+    var ir = new InfoReceiver(base_url, XHRLocalObject);
     ir.onfinish = function(info, rtt) {
         ri._didMessage('m'+JSON3.stringify([info, rtt]));
         ri._didClose();
diff --git a/lib/sockjs.js b/lib/sockjs.js
index bd14725..4386fdf 100644
--- a/lib/sockjs.js
+++ b/lib/sockjs.js
@@ -14,7 +14,10 @@ var InfoReceiver = require('./info-receiver');
 var InfoReceiverIframe = require('./info-receiver-iframe');
 var InfoReceiverFake = require('./info-receiver-fake');
 var FacadeJS = require('./facade');
-var JSON3 = require('json3').noConflict();
+var JSON3 = require('json3');
+var IframeTransport = require('./trans-iframe');
+var XHRLocalObject = require('./xhr-local');
+var XDRObject = require('./xdr');
 
 function SockJS(url, dep_protocols_whitelist, options) {
     if (!(this instanceof SockJS)) {
@@ -74,7 +77,7 @@ function SockJS(url, dep_protocols_whitelist, options) {
 // Inheritance
 SockJS.prototype = new REventTarget();
 
-SockJS.version = "<!-- version -->";
+SockJS.version = '1.0.0-alpha1';
 
 SockJS.prototype.CONNECTING = SockJS.CONNECTING = 0;
 SockJS.prototype.OPEN = SockJS.OPEN = 1;
@@ -198,7 +201,7 @@ SockJS.prototype._try_next_protocol = function(close_event) {
             // I can't understand how it is possible to run
             // this timer, when the state is CLOSED, but
             // apparently in IE everythin is possible.
-            that._didClose(2007, "Transport timeouted");
+            that._didClose(2007, "Transport timed out");
         }
     }
 
@@ -302,6 +305,7 @@ SockJS.bootstrap_iframe = function() {
             var protocol = p[1];
             var trans_url = p[2];
             var base_url = p[3];
+            // change this to semver logic
             if (version !== SockJS.version) {
                 utils.log("Incompatibile SockJS! Main site uses:" +
                           " \"" + version + "\", the iframe:" +
@@ -355,20 +359,22 @@ SockJS['xhr-streaming'] = require('./xhr-streaming');
 
 module.exports = SockJS;
 
+SockJS.getUtils = function () { return utils; };
+
 function createInfoReceiver(base_url) {
     if (utils.isSameOriginUrl(base_url)) {
         // If, for some reason, we have SockJS locally - there's no
         // need to start up the complex machinery. Just use ajax.
-        return new InfoReceiver(base_url, utils.XHRLocalObject);
+        return new InfoReceiver(base_url, XHRLocalObject);
     }
     switch (utils.isXHRCorsCapable()) {
     case 1:
         // XHRLocalObject -> no_credentials=true
-        return new InfoReceiver(base_url, utils.XHRLocalObject);
+        return new InfoReceiver(base_url, XHRLocalObject);
     case 2:
         // IE 8/9 if the request target uses the same scheme
         if (utils.isSameOriginScheme(base_url)) {
-            return new InfoReceiver(base_url, utils.XDRObject);
+            return new InfoReceiver(base_url, XDRObject);
         }
         break;
     case 3:
diff --git a/lib/trans-eventsource.js b/lib/trans-eventsource.js
index bb71161..56faebb 100644
--- a/lib/trans-eventsource.js
+++ b/lib/trans-eventsource.js
@@ -3,11 +3,11 @@
 var AjaxBasedTransport = require('./ajax-based');
 var EventSourceReceiver = require('./trans-receiver-eventsource');
 var FacadeJS = require('./facade');
-var utils = require('./utils');
+var XHRLocalObject = require('./xhr-local');
 
 // w-iframe-eventsource
 var EventSourceTransport = FacadeJS['w-iframe-eventsource'] = function EventSourceTransport(ri, trans_url) {
-    this.run(ri, trans_url, '/eventsource', EventSourceReceiver, utils.XHRLocalObject);
+    this.run(ri, trans_url, '/eventsource', EventSourceReceiver, XHRLocalObject);
 };
 EventSourceTransport.prototype = new AjaxBasedTransport();
 
diff --git a/lib/trans-iframe-htmlfile.js b/lib/trans-iframe-htmlfile.js
index 25de7af..7356a70 100644
--- a/lib/trans-iframe-htmlfile.js
+++ b/lib/trans-iframe-htmlfile.js
@@ -13,10 +13,10 @@
 // production it should be only run in IE.
 
 var IframeTransport = require('./trans-iframe');
-var utils = require('./utils');
 var AjaxBasedTransport = require('./ajax-based');
 var HtmlfileReceiver = require('./trans-receiver-htmlfile');
 var FacadeJS = require('./facade');
+var XHRLocalObject = require('./xhr-local');
 
 function HtmlFileIframeTransport() {
     var that = this;
@@ -39,6 +39,6 @@ module.exports = HtmlFileIframeTransport;
 
 // w-iframe-htmlfile
 var HtmlFileTransport = FacadeJS['w-iframe-htmlfile'] = function(ri, trans_url) {
-    this.run(ri, trans_url, '/htmlfile', HtmlfileReceiver, utils.XHRLocalObject);
+    this.run(ri, trans_url, '/htmlfile', HtmlfileReceiver, XHRLocalObject);
 };
 HtmlFileTransport.prototype = new AjaxBasedTransport();
diff --git a/lib/trans-iframe-xhr-polling.js b/lib/trans-iframe-xhr-polling.js
index 969832a..a63d36e 100644
--- a/lib/trans-iframe-xhr-polling.js
+++ b/lib/trans-iframe-xhr-polling.js
@@ -8,10 +8,10 @@
  */
 
 var IframeTransport = require('./trans-iframe');
-var utils = require('./utils');
 var AjaxBasedTransport = require('./ajax-based');
 var XhrReceiver = require('./trans-receiver-xhr');
 var FacadeJS = require('./facade');
+var XHRLocalObject = require('./xhr-local');
 
 function XhrPollingIframeTransport() {
     var that = this;
@@ -32,7 +32,7 @@ module.exports = XhrPollingIframeTransport;
 
 // w-iframe-xhr-polling
 var XhrPollingITransport = FacadeJS['w-iframe-xhr-polling'] = function(ri, trans_url) {
-    this.run(ri, trans_url, '/xhr', XhrReceiver, utils.XHRLocalObject);
+    this.run(ri, trans_url, '/xhr', XhrReceiver, XHRLocalObject);
 };
 
 XhrPollingITransport.prototype = new AjaxBasedTransport();
diff --git a/lib/trans-iframe.js b/lib/trans-iframe.js
index 8063994..1cce2fa 100644
--- a/lib/trans-iframe.js
+++ b/lib/trans-iframe.js
@@ -15,7 +15,7 @@
 //    http://msdn.microsoft.com/en-us/library/cc197015(v=VS.85).aspx
 //    http://stevesouders.com/misc/test-postmessage.php
 
-var JSON3 = require('json3').noConflict();
+var JSON3 = require('json3');
 var utils = require('./utils');
 
 function IframeTransport() {}
@@ -64,11 +64,12 @@ IframeTransport.prototype.onmessage = function(e) {
     var type = e.data.slice(8, 9);
     var data = e.data.slice(9);
 
-    if (window_id !== that.window_id) return;
+    if (window_id !== that.window_id) return console.log('Mismatched window id');
 
     switch(type) {
     case 's':
         that.iframeObj.loaded();
+        // window global dependency
         that.postMessage('s', JSON3.stringify([window.SockJS.version, that.protocol, that.trans_url, that.base_url]));
         break;
     case 't':
diff --git a/lib/trans-jsonp-polling.js b/lib/trans-jsonp-polling.js
index 4dfb425..62efa6b 100644
--- a/lib/trans-jsonp-polling.js
+++ b/lib/trans-jsonp-polling.js
@@ -66,6 +66,7 @@ JsonPTransport.prototype.doCleanup = function() {
     that.send_destructor();
 };
 
+module.exports = JsonPTransport;
 
 // Abstract away code that handles global namespace pollution.
 var jsonPReceiverWrapper = function(url, constructReceiver, user_callback) {
diff --git a/lib/utils.js b/lib/utils.js
index 3c233f5..90dc4a1 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -7,7 +7,7 @@
  * ***** END LICENSE BLOCK *****
  */
 
-var JSON3 = require('json3').noConflict();
+var JSON3 = require('json3');
 var utils = {};
 
 // This string has length 32, a power of 2, so the modulus doesn't introduce a
diff --git a/lib/xhr-polling.js b/lib/xhr-polling.js
index b57ac07..d9b4d92 100644
--- a/lib/xhr-polling.js
+++ b/lib/xhr-polling.js
@@ -10,11 +10,10 @@
 var AjaxBasedTransport = require('./ajax-based');
 var XhrStreamingTransport = require('./xhr-streaming');
 var XhrReceiver = require('./trans-receiver-xhr');
-var utils = require('./utils');
-
+var XHRCorsObject = require('./xhr-cors');
 
 function XhrPollingTransport(ri, trans_url) {
-    this.run(ri, trans_url, '/xhr', XhrReceiver, utils.XHRCorsObject);
+    this.run(ri, trans_url, '/xhr', XhrReceiver, XHRCorsObject);
 }
 
 XhrPollingTransport.prototype = new AjaxBasedTransport();
diff --git a/lib/xhr-streaming.js b/lib/xhr-streaming.js
index 0a98429..4513761 100644
--- a/lib/xhr-streaming.js
+++ b/lib/xhr-streaming.js
@@ -9,10 +9,10 @@
 
 var AjaxBasedTransport = require('./ajax-based');
 var XhrReceiver = require('./trans-receiver-xhr');
-var utils = require('./utils');
+var XHRCorsObject = require('./xhr-cors');
 
 function XhrStreamingTransport(ri, trans_url) {
-    this.run(ri, trans_url, '/xhr_streaming', XhrReceiver, utils.XHRCorsObject);
+    this.run(ri, trans_url, '/xhr_streaming', XhrReceiver, XHRCorsObject);
 }
 
 XhrStreamingTransport.prototype = new AjaxBasedTransport();
diff --git a/package.json b/package.json
index 883565e..e1d6985 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
 {
   "name": "sockjs-client",
   "description": "SockJS-client is a browser JavaScript library that provides a WebSocket-like object. SockJS gives you a coherent, cross-browser, Javascript API which creates a low latency, full duplex, cross-domain communication channel between the browser and the web server.",
-  "version": "0.3.4",
+  "version": "1.0.0-alpha1",
   "author": "Marek Majkowski",
   "bugs": {
     "url": "https://github.com/sockjs/sockjs-client/issues"
@@ -17,13 +17,14 @@
   },
   "devDependencies": {
     "browserify": "^4.1.5",
-    "coffee-script": "1.2.x",
+    "exorcist": "^0.1.6",
     "gulp": "^3.6.2",
+    "gulp-util": "^2.2.14",
+    "minifyify": "^3.0.6",
     "mocha": "^1.18.2",
+    "mold-source-map": "^0.3.0",
     "node-static": "0.5.9",
-    "optimist": "0.3.5",
     "sockjs": "^0.3.8",
-    "uglify-js": "1.2.5",
     "vinyl-source-stream": "^0.1.1",
     "zuul": "^1.6.4"
   },
@@ -39,7 +40,7 @@
     "url": "https://github.com/sockjs/sockjs-client.git"
   },
   "scripts": {
-    "test": "./node_modules/zuul/bin/zuul -- tests/html/lib/unittests.js tests/html/lib/domtests.js tests/html/lib/endtoendtests.js tests/html/lib/protocols.js",
-    "test_local": "./node_modules/zuul/bin/zuul --local 9090 --ui qunit -- tests/html/lib/unittests.js tests/html/lib/domtests.js tests/html/lib/endtoendtests.js tests/html/lib/protocols.js"
+    "test": "./node_modules/zuul/bin/zuul -- tests/html/lib/unittests.js tests/html/lib/domtests.js tests/html/lib/endtoendtests.js tests/html/lib/tests.js",
+    "test_local": "./node_modules/zuul/bin/zuul --local 9090 --ui qunit -- tests/html/lib/unittests.js tests/html/lib/domtests.js tests/html/lib/endtoendtests.js tests/html/lib/tests.js"
   }
-}
\ No newline at end of file
+}
diff --git a/tests/html/src/domtests.coffee b/tests/html/src/domtests.coffee
deleted file mode 100644
index d5ed0e7..0000000
--- a/tests/html/src/domtests.coffee
+++ /dev/null
@@ -1,134 +0,0 @@
-QUnit.module('Dom')
-
-u = SockJS.getUtils()
-
-onunload_test_factory = (code) ->
-    return ->
-        expect(3)
-        hook = newIframe()
-        hook.open = ->
-            ok(true, 'open hook called by an iframe')
-            hook.callback(code)
-        hook.load = ->
-            ok(true, 'onload hook called by an iframe')
-            f = -> hook.iobj.cleanup()
-            setTimeout(f, 1)
-        hook.unload = ->
-            ok(true, 'onunload hook called by an iframe')
-            hook.del()
-            start()
-
-if navigator.userAgent.indexOf('Konqueror') isnt -1 or navigator.userAgent.indexOf('Opera') isnt -1
-    test "onunload [unsupported by client]", ->
-        ok(true)
-else
-    asyncTest('onunload', onunload_test_factory("""
-                    var u = SockJS.getUtils();
-                    u.attachEvent('load', function(){
-                        hook.load();
-                    });
-                    var w = 0;
-                    var run = function(){
-                        if(w === 0) {
-                            w = 1;
-                            hook.unload();
-                        }
-                    };
-                    u.attachEvent('beforeunload', run);
-                    u.attachEvent('unload', run);
-                """))
-
-if not SockJS.getIframeTransport().enabled()
-    test "onmessage [unsupported by client]", ->
-        ok(true)
-else
-    asyncTest 'onmessage', ->
-        expect(3)
-        hook = newIframe()
-        hook.open = ->
-            ok(true, 'open hook called by an iframe')
-            hook.callback("""
-                    var u = SockJS.getUtils();
-                    u.attachMessage(function(e) {
-                        var b = e.data;
-                        parent.postMessage(window_id + ' ' + 'e', '*');
-                    });
-                    parent.postMessage(window_id + ' ' + 's', '*');
-                """)
-        u.attachMessage (e) ->
-            [window_id, data] = e.data.split(' ')
-            if window_id is hook.id
-                switch data
-                    when 's'
-                        hook.iobj.loaded()
-                        ok(true, 'start frame send')
-                        origin = u.getOrigin(u.amendUrl('/'))
-                        hook.iobj.post(hook.id + ' ' + 's' , origin)
-                    when 'e'
-                        ok(true, 'done hook called by an iframe')
-                        hook.iobj.cleanup()
-                        hook.del()
-                        start()
-
-
-ajax_simple_factory = (name) ->
-    asyncTest name + ' simple', ->
-        expect(2)
-        x = new u[name]('GET', '/simple.txt', null)
-        x.onfinish = (status, text) ->
-            equal(text.length, 2051)
-            equal(text.slice(-2), 'b\n')
-            start()
-
-ajax_streaming_factory = (name) ->
-    asyncTest name + ' streaming', ->
-        expect(4)
-        x = new u[name]('GET', '/streaming.txt', null)
-        x.onchunk = (status, text) ->
-            equal(status, 200)
-            ok(text.length <= 2049, 'Most likely you\'re behind a transparent Proxy that can\'t do streaming. QUnit tests won\'t work properly. Sorry!')
-            delete x.onchunk
-        x.onfinish = (status, text) ->
-            equal(status, 200)
-            equal(text.slice(-4), 'a\nb\n')
-            start()
-
-
-test_wrong_url = (name, url, statuses) ->
-    if window.console and console.log
-        console.log(' [*] Connecting to wrong url ' + url)
-    expect(2)
-    x = new u[name]('GET', url, null)
-    x.onchunk = ->
-        ok(false, "chunk shall not be received")
-    x.onfinish = (status, text) ->
-        ok(u.arrIndexOf(statuses, status) isnt -1)
-        equal(text, '')
-        start()
-
-ajax_wrong_port_factory = (name) ->
-    for port in [25, 8999, 65300]
-        asyncTest name + ' wrong port ' + port, ->
-            test_wrong_url(name, 'http://localhost:'+port+'/wrong_url_indeed.txt', [0])
-
-
-ajax_simple_factory('XHRLocalObject')
-if window.XDomainRequest
-    ajax_simple_factory('XDRObject')
-
-if not window.ActiveXObject
-    # Ajax streaming is not working in ie.
-    ajax_streaming_factory('XHRLocalObject')
-if window.XDomainRequest
-    ajax_streaming_factory('XDRObject')
-
-ajax_wrong_port_factory('XHRLocalObject')
-if window.XDomainRequest
-    ajax_wrong_port_factory('XDRObject')
-
-asyncTest 'XHRLocalObject wrong url', ->
-    # Opera responds with 0, all other browsers with 404
-    test_wrong_url('XHRLocalObject', '/wrong_url_indeed.txt', [0, 404])
-if window.XDomainRequest
-    asyncTest 'XDRObject wrong url', ->
-        test_wrong_url('XDRObject', '/wrong_url_indeed.txt', [0])
diff --git a/tests/html/src/endtoendtests.coffee b/tests/html/src/endtoendtests.coffee
deleted file mode 100644
index 1a8d7db..0000000
--- a/tests/html/src/endtoendtests.coffee
+++ /dev/null
@@ -1,136 +0,0 @@
-u = SockJS.getUtils()
-
-QUnit.module('End to End')
-
-factory_body_check = (protocol) ->
-    if not SockJS[protocol] or not SockJS[protocol].enabled(client_opts.sockjs_opts)
-        n = " " + protocol + " [unsupported by client]"
-        test n, ->
-            u.log('Unsupported protocol (by client): "' + protocol + '"')
-    else
-        asyncTest protocol, ->
-            expect(5)
-            url = client_opts.url + '/echo'
-
-            code = """
-            hook.test_body(!!document.body, typeof document.body);
-
-            var sock = new SockJS('""" + url + """', null,
-                                  {protocols_whitelist:['""" + protocol + """']});
-            sock.onopen = function() {
-                var m = hook.onopen();
-                sock.send(m);
-            };
-            sock.onmessage = function(e) {
-                hook.onmessage(e.data);
-                sock.close();
-            };
-            """
-            hook = newIframe('sockjs-in-head.html')
-            hook.open = ->
-                hook.iobj.loaded()
-                ok(true, 'open')
-                hook.callback(code)
-            hook.test_body = (is_body, type) ->
-                equal(is_body, false, 'body not yet loaded ' + type)
-            hook.onopen = ->
-                ok(true, 'onopen')
-                return 'a'
-            hook.onmessage = (m) ->
-                equal(m, 'a')
-                ok(true, 'onmessage')
-                hook.iobj.cleanup()
-                hook.del()
-                start()
-
-# QUnit.module('sockjs in head')
-# body_protocols = ['iframe-eventsource',
-#             'iframe-htmlfile',
-#             'iframe-xhr-polling',
-#             'jsonp-polling']
-# for protocol in body_protocols
-#     factory_body_check(protocol)
-
-
-QUnit.module('connection errors')
-asyncTest "invalid url 404", ->
-    expect(4)
-    r = newSockJS('/invalid_url', 'jsonp-polling')
-    ok(r)
-    r.onopen = (e) ->
-        ok(false)
-    r.onmessage = (e) ->
-        ok(false)
-    r.onclose = (e) ->
-        if u.isXHRCorsCapable() < 4
-            equal(e.code, 1002)
-            equal(e.reason, 'Can\'t connect to server')
-        else
-            # IE 7 doesn't look at /info, unfortunately
-            equal(e.code, 2000)
-            equal(e.reason, 'All transports failed')
-        equal(e.wasClean, false)
-        start()
-
-asyncTest "invalid url port", ->
-    expect(4)
-    dl = document.location
-    r = newSockJS(dl.protocol + '//' + dl.hostname + ':1079', 'jsonp-polling')
-    ok(r)
-    r.onopen = (e) ->
-        ok(false)
-    r.onclose = (e) ->
-        if u.isXHRCorsCapable() < 4
-            equal(e.code, 1002)
-            equal(e.reason, 'Can\'t connect to server')
-        else
-            # IE 7 doesn't look at /info, unfortunately
-            equal(e.code, 2000)
-            equal(e.reason, 'All transports failed')
-        equal(e.wasClean, false)
-        start()
-
-asyncTest "disabled websocket test", ->
-        expect(3)
-        r = newSockJS('/disabled_websocket_echo', 'websocket')
-        r.onopen = (e) ->
-            ok(false)
-        r.onmessage = (e) ->
-            ok(false)
-        r.onclose = (e) ->
-            equal(e.code, 2000)
-            equal(e.reason, "All transports failed")
-            equal(e.wasClean, false)
-            start()
-
-asyncTest "close on close", ->
-    expect(4)
-    r = newSockJS('/close', 'jsonp-polling')
-    r.onopen = (e) ->
-        ok(true)
-    r.onmessage = (e) ->
-        ok(false)
-    r.onclose = (e) ->
-        equal(e.code, 3000)
-        equal(e.reason, "Go away!")
-        equal(e.wasClean, true)
-        r.onclose = ->
-            ok(false)
-        r.close()
-
-        u.delay 10, ->
-            start()
-
-# Test for #61
-asyncTest "EventEmitter exception handling", ->
-    expect(1)
-    r = newSockJS('/echo', 'xhr-streaming')
-    prev_onerror = window.onerror
-    window.onerror = (e) ->
-        ok(/onopen error/.test(''+e))
-        window.onerror = prev_onerror
-        r.close()
-    r.onopen = (e) ->
-        throw "onopen error"
-    r.onclose = ->
-        start()
diff --git a/tests/html/src/protocols.coffee b/tests/html/src/protocols.coffee
deleted file mode 100644
index 8a72866..0000000
--- a/tests/html/src/protocols.coffee
+++ /dev/null
@@ -1,12 +0,0 @@
-protocols = ['websocket',
-        'xdr-streaming',
-        'xhr-streaming',
-        'iframe-eventsource',
-        'iframe-htmlfile',
-        'xdr-polling',
-        'xhr-polling',
-        'iframe-xhr-polling',
-        'jsonp-polling']
-
-for protocol in protocols
-    test_protocol_messages(protocol)
\ No newline at end of file
diff --git a/tests/html/src/tests.coffee b/tests/html/src/tests.coffee
deleted file mode 100755
index 78bbff5..0000000
--- a/tests/html/src/tests.coffee
+++ /dev/null
@@ -1,350 +0,0 @@
-u = SockJS.getUtils()
-
-newIframe = (path = '/iframe.html') ->
-    # Requires to put:
-    #     document.domain = document.domain
-    # in HEAD, for IE7
-    hook = u.createHook()
-    err = ->
-        u.log('iframe error. bad.')
-    hook.iobj = u.createIframe(path + '?a=' + Math.random() + '#' + hook.id, err)
-    return hook
-
-newSockJS = (path, protocol) ->
-    url = if /^http/.test(path) then path else client_opts.url + path
-    options = jQuery.extend({}, client_opts.sockjs_opts)
-    if protocol
-        options.protocols_whitelist = [protocol]
-    return new SockJS(url, null, options)
-
-echo_factory_factory = (protocol, messages) ->
-    return ->
-        expect(2 + messages.length)
-        a = messages.slice(0)
-        r = newSockJS('/echo', protocol)
-        r.onopen = (e) ->
-            #u.log('onopen ' + e)
-            ok(true)
-            r.send(a[0])
-        r.onmessage = (e) ->
-            #u.log('onmessage ' + e);
-            x = ''+a[0]
-            if e.data != x
-                for i in [0...e.data.length]
-                    if e.data.charCodeAt(i) != x.charCodeAt(i)
-                        xx1 = ('0000' + x.charCodeAt(i).toString(16)).slice(-4)
-                        xx2 = ('0000' + e.data.charCodeAt(i).toString(16)).slice(-4)
-                        u.log('source: \\u' + xx1 + ' differs from: \\u' + xx2)
-                        break
-            equal(e.data, '' + a[0])
-            a.shift()
-            if typeof a[0] is 'undefined'
-                r.close()
-            else
-                r.send(a[0])
-        r.onclose = (e) ->
-            if a.length
-                ok(false, "Transport closed prematurely. " + e)
-            else
-                ok(true)
-            start()
-
-factor_echo_basic = (protocol) ->
-    messages = [ 'data' ]
-    return echo_factory_factory(protocol, messages)
-
-factor_echo_rich = (protocol) ->
-    messages = [ [1,2,3,'data'], null, false, "data", 1, 12.0, {a:1, b:2} ]
-    return echo_factory_factory(protocol, messages)
-
-factor_echo_from_child = (protocol) ->
-  return ->
-    timeout = undefined
-    hookReady = false
-    sockJSReady = false
-    expect 4
-    hook = newIframe("sockjs-in-parent.html")
-    r = newSockJS("/echo", protocol)
-    code = "hook.r.send('a'); hook.onsend();"
-    hook.open = ->
-      hook.iobj.loaded()
-      ok true, "iframe open"
-      hookReady = true
-      hook.r = r
-      sockJSReady and hook.callback(code)
-
-    r.onopen = (e) ->
-      hook.iobj.loaded()
-      ok true, "sockjs open"
-      sockJSReady = true
-      hookReady and hook.callback(code)
-
-    r.onmessage = (e) ->
-      clearTimeout timeout
-      equal e.data, "a"
-      ok true, "onmessage"
-      hook.iobj.cleanup()
-      hook.del()
-      r.close()
-
-    hook.onsend = (e) ->
-      timeout = setTimeout(->
-        ok false
-        r.close()
-        return
-      , 300)
-      return
-
-    r.onclose = ->
-      start()
-
-factor_echo_unicode = (protocol) ->
-    messages = [
-        "Τη γλώσσα μου έδωσαν ελληνική το σπίτι φτωχικό στις αμμουδιές του ",
-        "ღმერთსი შემვედრე, ნუთუ კვლა დამხსნას სოფლისა შრომასა, ცეცხლს, წყალს",
-        "⠊⠀⠉⠁⠝⠀⠑⠁⠞⠀⠛⠇⠁⠎⠎⠀⠁⠝⠙⠀⠊⠞⠀⠙⠕⠑⠎⠝⠞⠀⠓⠥⠗⠞⠀⠍⠑",
-        "Би шил идэй чадна, надад хортой биш",
-        "을",
-        "나는 유리를 먹을 수 있어요. 그래도 아프지 않아요",
-        "ฉันกินกระจกได้ แต่มันไม่ทำให้ฉันเจ็บฉันกินกระจกได้ แต่มันไม่ทำให้ฉันเจ็บ",
-        "Ég get etið gler án þess að meiða mig.",
-        "Mogę jeść szkło, i mi nie szkodzi.",
-        "\ufffd\u10102\u2f877",
-        """Начало музыкальной карьеры
-Бритни пела в церковном хоре местной баптистской церкви. В возрасте 8-ми лет Спирс прошла аудирование для участия в шоу «Новый Клуб Микки-Мауса» на канале «Дисней». И хотя продюсеры решили, что Спирс слишком молода для участия в шоу, они представили её агенту в Нью-Йорке. Следующие 3 года Бритни училась в актёрской школе Professional Performing Arts School в Нью-Йорке и участвовала в нескольких постановках, в том числе «Ruthless!» 1991 года. В 1992 году Спирс участвовала в конкурсе Star  [...]
-В 1993 году Спирс вернулась на канал «Дисней» и в течение 2-х лет участвовала в шоу «Новый Клуб Микки-Мауса». Другие будущие знаменитости, начинавшие с этого шоу — Кристина Агилера, участники 'N Sync Джастин Тимберлейк и Джейси Шазе, звезда сериала «Счастье» Кери Расселл и актёр фильма «Дневник памяти» Райан Гослинг.
-В 1994 году шоу закрыли, Бритни вернулась домой в Луизиану, где поступила в среднюю школу. Некоторое время она пела в девичьей группе Innosense, но вскоре, решив начать сольную карьеру, записала демодиск, который попал в руки продюсерам из Jive Records, и те заключили с ней контракт.
-Далее последовал тур по стране, выступления в супермаркетах и работа на разогреве у групп 'N Sync и Backstreet Boys.
-[править]1999—2000: Ранний коммерческий успех
-В октябре 1998 года вышел дебютный сингл Бритни Спирс «…Baby One More Time» . Песня имела огромный успех, в первые же недели возглавила международные чарты, мировые продажи сингла составили 9 миллионов копий, что сделало диск дважды платиновым. Альбом с одноимённым названием вышел в январе 1999 года. Альбом стартовал на первом месте рейтинга Billboard 200, пятьдесят одну неделю продержался в верхней десятке и шестьдесят недель в двадцати лучших. Альбом стал 15-кратным платиновым и на сег [...]
-В 1999 году Бритни снялась для апрельского номера журнала Rolling Stone. Откровенные фотографии спровоцировали слухи о том, что 17-летняя звезда сделала операцию по увеличению груди, что сама Спирс отрицала. Успех альбома и противоречивый образ Спирс, созданный массмедиа, сделали её главной звездой 1999 года.
-Вслед за успешным дебютом последовал второй альбом певицы «Oops!... I Did It Again», также стартовавший на 1-м месте в США. Продажи за первую неделю составили 1 319 193 копии, что являлось абсолютным рекордом, который затем побил американский рэпер Эминем. Летом 2000 года Спирс отправилась в свой первый мировой тур, «Oops!… I Did It Again World Tour». В 2000 году Спирс получила две награды Billboards Music Awards и была номинирована на «Грэмми» в двух категориях — «Лучший поп-альбом» и « [...]
-[править]2001—2003: Вершина карьеры
-
-
-Исполняя «Me Against the Music»
-Успех Спирс сделал её заметной фигурой и в музыкальной индустрии, и в поп-культуре. В начале 2001 года она привлекла внимание «Пепси», эта компания предложила ей многомиллионный контракт, включавший телевизионную рекламу и участие в промо-акциях.
-В ноябре 2001 года вышел третий альбом Спирс — Britney. Альбом дебютировал на первом месте в США с продажами в 745 744 пластинок за первую неделю, что сделало Бритни первой в истории исполнительницей, чьи первые три альбома стартовали на вершине рейтинга. Сразу же после выхода альбома Спирс отправилась в тур Dream Within a Dream Tour, по окончании которого объявила, что хочет взять 6-месячный перерыв в карьере.
-В этом же году Спирс рассталась с солистом 'N Sync Джастином Тимберлейком, с которым встречалась 4 года.
-Бритни вернулась на сцену в августе 2003 года.
-В ноябре 2003 года вышел четвёртый студийный альбом Спирс In The Zone. Бритни участвовала в написании восьми из тринадцати композиций, а также выступила в качестве продюсера альбома. In The Zone дебютировал на первом месте в США, что сделало Бритни первой в истории исполнительницей, чьи первые четыре альбома стартовали на вершине рейтинга. Самый успешный сингл с альбома — Toxic — принёс Бритни первую для неё награду Грэмми в категории «Лучшая танцевальная композиция».
-[править]2007—2008: Возвращение к музыке
-В начале 2007 года после двухлетнего перерыва Спирс приступила к записи нового сольного альбома, продюсерами которого выступили Nate «Danja» Hills, Шон Гарретт и Джонатан Ротэм.
-В мае 2007 года Спирс в составе коллектива «The M and M’s» дала 6 концертов в рамках тура «House of Blues» в Лос-Анджелесе, Сан-Диего, Анахайме, Лас-Вегасе, Орландо и Майами. Каждый концерт длился около 15 минут и включал 5 старых хитов певицы.[4]
-30 августа 2007 года на волнах нью-йоркской радиостанции Z100 состоялась премьера песни «Gimme More», первого сингла с нового альбома Спирс.[5] Сингл вышел на iTunes 24 сентября и на CD 29 октября 2007.
-9 сентября 2007 года Спирс исполнила «Gimme More» на церемонии вручения наград MTV Video Music Awards. Выступление оказалось неудачным; Спирс выглядела непрофессионально — не всегда попадала в фонограмму и в танце отставала от группы хореографической поддержки.[6]
-Несмотря на это, в начале октября 2007 года сингл «Gimme More» достиг 3-го места в чарте Billboard Hot 100, став таким образом одним из самых успешных синглов Спирс.[7]""",
-    ]
-    return echo_factory_factory(protocol, messages)
-
-factor_echo_special_chars = (protocol) ->
-    messages = [
-        " ",
-        "\u0000",
-        "\xff",
-        "\xff\x00",
-        "\x00\xff",
-        " \r ",
-        " \n ",
-        " \r\n ",
-        "\r\n",
-        "",
-        "message\t",
-        "\tmessage",
-        "message ",
-        " message",
-        "message\r",
-        "\rmessage",
-        "message\n",
-        "\nmessage",
-        "message\xff",
-        "\xffmessage",
-        "A",
-        "b",
-        "c",
-        "d",
-        "e",
-        "\ufffd",
-        "\ufffd\u0000",
-        "message\ufffd",
-        "\ufffdmessage",
-    ]
-    return echo_factory_factory(protocol, messages)
-
-
-factor_echo_large_message = (protocol) ->
-    # Should be larger than 128k - the limit for a single request in
-    # some streaming transports.
-    messages = [
-        Array(Math.pow(2,1)).join('x'),
-        Array(Math.pow(2,2)).join('x'),
-        Array(Math.pow(2,4)).join('x'),
-        Array(Math.pow(2,8)).join('x'),
-        Array(Math.pow(2,13)).join('x'),
-        Array(Math.pow(2,13)).join('x'),
-    ]
-    return echo_factory_factory(protocol, messages)
-
-
-batch_factory_factory = (protocol, messages) ->
-    return ->
-        expect(3 + messages.length)
-        r = newSockJS('/echo', protocol)
-        ok(r)
-        counter = 0
-        r.onopen = (e) ->
-            ok(true)
-            for msg in messages
-                r.send(msg)
-        r.onmessage = (e) ->
-            equal(e.data, messages[counter])
-            counter += 1
-            if counter is messages.length
-                r.close()
-        r.onclose = (e) ->
-            if counter isnt messages.length
-                ok(false, "Transport closed prematurely. " + e)
-            else
-                ok(true)
-            start()
-
-factor_batch_large = (protocol) ->
-    messages = [
-        Array(Math.pow(2,1)).join('x'),
-        Array(Math.pow(2,2)).join('x'),
-        Array(Math.pow(2,4)).join('x'),
-        Array(Math.pow(2,8)).join('x'),
-        Array(Math.pow(2,13)).join('x'),
-        Array(Math.pow(2,13)).join('x'),
-    ]
-    return batch_factory_factory(protocol, messages)
-
-
-batch_factory_factory_amp = (protocol, messages) ->
-    return ->
-        expect(3 + messages.length)
-        r = newSockJS('/amplify', protocol)
-        ok(r)
-        counter = 0
-        r.onopen = (e) ->
-            ok(true)
-            for msg in messages
-                r.send(''+msg)
-        r.onmessage = (e) ->
-            equal(e.data.length, Math.pow(2, messages[counter]), e.data)
-            counter += 1
-            if counter is messages.length
-                r.close()
-        r.onclose = (e) ->
-            if counter isnt messages.length
-                ok(false, "Transport closed prematurely. " + e)
-            else
-                ok(true)
-            start()
-
-factor_batch_large_amp = (protocol) ->
-    messages = [
-        1,
-        2,
-        4,
-        8,
-        13,
-        15,
-        15,
-    ]
-    return batch_factory_factory_amp(protocol, messages)
-
-
-
-escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u2000-\u20ff\ufeff\ufff0-\uffff\x00-\x1f\ufffe\uffff\u0300-\u0333\u033d-\u0346\u034a-\u034c\u0350-\u0352\u0357-\u0358\u035c-\u0362\u0374\u037e\u0387\u0591-\u05af\u05c4\u0610-\u0617\u0653-\u0654\u0657-\u065b\u065d-\u065e\u06df-\u06e2\u06eb-\u06ec\u0730\u0732-\u0733\u0735-\u0736\u073a\u073d\u073f-\u0741\u0743\u0745\u0747\u07eb-\u07f1\u0951\u0958-\u095f\u09dc-\u09dd\u09df\u0a33\u0a36\u0a59-\u0a5b\u0a5e\u0b5c-\u0b5d\u0 [...]
-
-generate_killer_string = (escapable) ->
-    s = []
-    c = for i in [0..65535]
-            String.fromCharCode(i)
-    escapable.lastIndex = 0;
-    c.join('').replace escapable,  (a) ->
-            s.push(a)
-            return ''
-    return s.join('')
-
-factor_echo_utf_encoding_simple = (protocol) ->
-    message = for i in [0..256]
-                  String.fromCharCode(i)
-    return echo_factory_factory(protocol, [message.join('')])
-
-factor_echo_utf_encoding = (protocol) ->
-        message = generate_killer_string(escapable)
-        return echo_factory_factory(protocol, [message])
-
-
-
-factor_user_close = (protocol) ->
-    return ->
-        expect(5)
-        r = newSockJS('/echo', protocol)
-        ok(r)
-        counter = 0
-        r.onopen = (e) ->
-            counter += 1
-            ok(counter is 1)
-            r.close(3000, "User message")
-            ok(counter is 1)
-        r.onmessage = () ->
-            ok(false)
-            counter += 1
-        r.onclose = (e) ->
-            counter += 1
-            u.log('user_close ' + e.code + ' ' + e.reason)
-            equal(e.wasClean, true)
-            ok(counter is 2)
-            start()
-
-factor_server_close = (protocol) ->
-    return ->
-        expect(5)
-        r = newSockJS('/close', protocol)
-        ok(r)
-        r.onopen = (e) ->
-            ok(true)
-        r.onmessage = (e) ->
-            ok(false)
-        r.onclose = (e) ->
-            equal(e.code, 3000)
-            equal(e.reason, "Go away!")
-            equal(e.wasClean, true)
-            start()
-
-# IE doesn't do array.indexOf...
-arrIndexOf = (arr, obj) ->
-     for i in [0...arr.length]
-         if arr[i] is obj
-            return i
-     return -1
-
-test_protocol_messages = (protocol) ->
-    QUnit.module(protocol)
-    if not SockJS[protocol] or not SockJS[protocol].enabled()
-        test "[unsupported by client]", ->
-                ok(true, 'Unsupported protocol (by client): "' + protocol + '"')
-    else if client_opts.disabled_transports and
-          arrIndexOf(client_opts.disabled_transports, protocol) isnt -1
-        test "[disabled by config]", ->
-                ok(true, 'Disabled by config: "' + protocol + '"')
-    else
-        asyncTest("echo1", factor_echo_basic(protocol))
-        asyncTest("echo2", factor_echo_rich(protocol))
-        asyncTest("echo from child", factor_echo_from_child(protocol))
-        asyncTest("unicode", factor_echo_unicode(protocol))
-        asyncTest("utf encoding 0x00-0xFF",
-            factor_echo_utf_encoding_simple(protocol))
-        asyncTest("utf encoding killer message",
-            factor_echo_utf_encoding(protocol))
-        asyncTest("special_chars", factor_echo_special_chars(protocol))
-        asyncTest("large message (ping-pong)",
-            factor_echo_large_message(protocol))
-        asyncTest("large message (batch)", factor_batch_large(protocol))
-        asyncTest("large download", factor_batch_large_amp(protocol))
-
-        asyncTest("user close", factor_user_close(protocol))
-        asyncTest("server close", factor_server_close(protocol))
diff --git a/tests/html/src/unittests.coffee b/tests/html/src/unittests.coffee
deleted file mode 100644
index b5e2d86..0000000
--- a/tests/html/src/unittests.coffee
+++ /dev/null
@@ -1,295 +0,0 @@
-QUnit.module('Utils')
-
-u = SockJS.getUtils()
-
-test 'random_string', ->
-    notEqual(u.random_string(8), u.random_string(8))
-    for i in [1,2,3,128]
-        equal(u.random_string(i).length, i)
-
-test 'random_number_string', ->
-    for i in [0..10]
-        equal(u.random_number_string(10).length, 1)
-        equal(u.random_number_string(100).length, 2)
-        equal(u.random_number_string(1000).length, 3)
-        equal(u.random_number_string(10000).length, 4)
-        equal(u.random_number_string(100000).length, 5)
-
-test 'getOrigin', ->
-    equal(u.getOrigin('http://a.b/'), 'http://a.b')
-    equal(u.getOrigin('http://a.b/c'), 'http://a.b')
-    equal(u.getOrigin('http://a.b:123/c'), 'http://a.b:123')
-
-test 'isSameOriginUrl', ->
-    ok(u.isSameOriginUrl('http://localhost', 'http://localhost/'))
-    ok(u.isSameOriginUrl('http://localhost', 'http://localhost/abc'))
-    ok(u.isSameOriginUrl('http://localhost/', 'http://localhost'))
-    ok(u.isSameOriginUrl('http://localhost', 'http://localhost'))
-    ok(u.isSameOriginUrl('http://localhost', 'http://localhost:8080') is false)
-    ok(u.isSameOriginUrl('http://localhost:8080', 'http://localhost') is false)
-    ok(u.isSameOriginUrl('http://localhost:8080', 'http://localhost:8080/'))
-    ok(u.isSameOriginUrl('http://127.0.0.1:80/', 'http://127.0.0.1:80/a'))
-    ok(u.isSameOriginUrl('http://127.0.0.1:80', 'http://127.0.0.1:80/a'))
-    ok(u.isSameOriginUrl('http://localhost', 'http://localhost:80') is false)
-    ok(u.isSameOriginUrl('http://127.0.0.1/', 'http://127.0.0.1:80/a') is false)
-    ok(u.isSameOriginUrl('http://127.0.0.1:9', 'http://127.0.0.1:9999') is false)
-    ok(u.isSameOriginUrl('http://127.0.0.1:99', 'http://127.0.0.1:9999') is false)
-    ok(u.isSameOriginUrl('http://127.0.0.1:999', 'http://127.0.0.1:9999') is false)
-    ok(u.isSameOriginUrl('http://127.0.0.1:9999', 'http://127.0.0.1:9999'))
-    ok(u.isSameOriginUrl('http://127.0.0.1:99999', 'http://127.0.0.1:9999') is false)
-
-test "getParentDomain", ->
-    domains =
-        'localhost': 'localhost'
-        '127.0.0.1': '127.0.0.1'
-        'a.b.c.d':   'b.c.d'
-        'a.b.c.d.e': 'b.c.d.e'
-        '[::1]':     '[::1]'
-        'a.org':     'org'
-        'a2.a3.org': 'a3.org'
-
-    for k of domains
-        equal(u.getParentDomain(k), domains[k])
-
-test 'objectExtend', ->
-    deepEqual(u.objectExtend({}, {}), {})
-    a = {a:1};
-    equal(u.objectExtend(a, {}), a)
-    equal(u.objectExtend(a, {b:1}), a)
-    a = {a:1}; b = {b:2}
-    deepEqual(u.objectExtend(a, b), {a:1, b:2})
-    deepEqual(a, {a:1, b:2})
-    deepEqual(b, {b:2})
-
-test 'bind', ->
-    o = {}
-    fun = ->
-        return this
-    deepEqual(fun(), window)
-    bound_fun = u.bind(fun, o)
-    deepEqual(bound_fun(), o)
-
-test 'amendUrl', ->
-    dl = document.location
-
-    equal(u.amendUrl('//blah:1/abc'), dl.protocol + '//blah:1/abc')
-    equal(u.amendUrl('/abc'), dl.protocol + '//' + dl.host + '/abc')
-    equal(u.amendUrl('/'), dl.protocol + '//' + dl.host)
-    equal(u.amendUrl('http://a:1/abc'), 'http://a:1/abc')
-    equal(u.amendUrl('http://a:1/abc/'), 'http://a:1/abc')
-    equal(u.amendUrl('http://a:1/abc//'), 'http://a:1/abc')
-    t = -> u.amendUrl('')
-    raises(t, 'Wrong url')
-    t = -> u.amendUrl(false)
-    raises(t, 'Wrong url')
-    t = -> u.amendUrl('http://abc?a=a')
-    raises(t, 'Only basic urls are supported')
-    t = -> u.amendUrl('http://abc#a')
-    raises(t, 'Only basic urls are supported')
-
-    # For some browsers http://localhost:80/ is not in the same origin
-    # as http://localhost/. Remove explicit port number in such cases. See #74
-    equal(u.amendUrl('http://a:80/abc'), 'http://a/abc')
-    equal(u.amendUrl('https://a:443/abc'), 'https://a/abc')
-    equal(u.amendUrl('https://a:80/abc'), 'https://a:80/abc')
-    equal(u.amendUrl('http://a:443/abc'), 'http://a:443/abc')
-
-test 'arrIndexOf', ->
-    a = [1,2,3,4,5]
-    equal(u.arrIndexOf(a, 1), 0)
-    equal(u.arrIndexOf(a, 5), 4)
-    equal(u.arrIndexOf(a, null), -1)
-    equal(u.arrIndexOf(a, 6), -1)
-
-test 'arrSkip', ->
-    a = [1,2,3,4,5]
-    deepEqual(u.arrSkip(a, 1), [2,3,4,5])
-    deepEqual(u.arrSkip(a, 2), [1,3,4,5])
-    deepEqual(u.arrSkip(a, 11), [1,2,3,4,5])
-    deepEqual(u.arrSkip(a, 'a'), [1,2,3,4,5])
-    deepEqual(u.arrSkip(a, '1'), [1,2,3,4,5])
-
-test 'quote', ->
-    equal(u.quote(''), '""')
-    equal(u.quote('a'), '"a"')
-    ok(u.arrIndexOf(['"\\t"', '"\\u0009"'], u.quote('\t')) isnt -1)
-    ok(u.arrIndexOf(['"\\n"', '"\\u000a"'], u.quote('\n')) isnt -1)
-    equal(u.quote('\x00\udfff\ufffe\uffff'), '"\\u0000\\udfff\\ufffe\\uffff"')
-    # Unicode surrogates, formally incorrect unicode datapoints:
-    equal(u.quote('\ud85c\udff7\ud800\ud8ff'), '"\\ud85c\\udff7\\ud800\\ud8ff"')
-    equal(u.quote('\u2000\u2001\u0300\u0301'), '"\\u2000\\u2001\\u0300\\u0301"')
-
-    # And a sanity check.
-    c = for i in [0..65535]
-            String.fromCharCode(i)
-    all_chars = c.join('')
-    ok(JSON.parse(u.quote(all_chars)) is all_chars, "Quote/unquote all 64K chars.")
-
-test 'detectProtocols', ->
-    chrome_probed = {
-        'websocket': true
-        'xdr-streaming': false
-        'xhr-streaming': true
-        'iframe-eventsource': true
-        'iframe-htmlfile': true
-        'xdr-polling': false
-        'xhr-polling': true
-        'iframe-xhr-polling': true
-        'jsonp-polling': true
-    }
-    # Chrome
-    deepEqual(u.detectProtocols(chrome_probed, null, {}),
-            ['websocket', 'xhr-streaming', 'xhr-polling'])
-    deepEqual(u.detectProtocols(chrome_probed, null, {websocket:false}),
-            ['xhr-streaming', 'xhr-polling'])
-    # Opera
-    opera_probed = {
-        'websocket': false
-        'xdr-streaming': false
-        'xhr-streaming': false
-        'iframe-eventsource': true
-        'iframe-htmlfile': true
-        'xdr-polling': false
-        'xhr-polling': false
-        'iframe-xhr-polling': true
-        'jsonp-polling': true
-    }
-    deepEqual(u.detectProtocols(opera_probed, null, {}),
-            ['iframe-eventsource', 'iframe-xhr-polling'])
-    # IE 6, IE 7
-    ie6_probed = {
-        'websocket': false
-        'xdr-streaming': false
-        'xhr-streaming': false
-        'iframe-eventsource': false
-        'iframe-htmlfile': false
-        'xdr-polling': false
-        'xhr-polling': false
-        'iframe-xhr-polling': false
-        'jsonp-polling': true
-    }
-    deepEqual(u.detectProtocols(ie6_probed, null, {}),
-            ['jsonp-polling'])
-    # IE 8, IE 9
-    ie8_probed = {
-        'websocket': false
-        'xdr-streaming': true
-        'xhr-streaming': false
-        'iframe-eventsource': false
-        'iframe-htmlfile': true
-        'xdr-polling': true
-        'xhr-polling': false
-        'iframe-xhr-polling': true
-        'jsonp-polling': true
-    }
-    deepEqual(u.detectProtocols(ie8_probed, null, {}),
-            ['xdr-streaming', 'xdr-polling'])
-    deepEqual(u.detectProtocols(ie8_probed, null, {cookie_needed:true}),
-            ['iframe-htmlfile', 'iframe-xhr-polling'])
-    # IE 10
-    ie10_probed = {
-        'websocket': true
-        'xdr-streaming': true
-        'xhr-streaming': true
-        'iframe-eventsource': false
-        'iframe-htmlfile': true
-        'xdr-polling': true
-        'xhr-polling': true
-        'iframe-xhr-polling': true
-        'jsonp-polling': true
-    }
-    deepEqual(u.detectProtocols(ie10_probed, null, {}),
-            ['websocket', 'xhr-streaming', 'xhr-polling'])
-    deepEqual(u.detectProtocols(ie10_probed, null, {cookie_needed:true}),
-            ['websocket', 'xhr-streaming', 'xhr-polling'])
-
-    # Check if protocols are picked up correctly when served from file://
-    deepEqual(u.detectProtocols(chrome_probed, null, {null_origin:true}),
-            ['websocket', 'iframe-eventsource', 'iframe-xhr-polling'])
-    deepEqual(u.detectProtocols(chrome_probed, null,
-                                {websocket:false, null_origin:true}),
-            ['iframe-eventsource', 'iframe-xhr-polling'])
-
-    deepEqual(u.detectProtocols(opera_probed, null, {null_origin:true}),
-            ['iframe-eventsource', 'iframe-xhr-polling'])
-
-    deepEqual(u.detectProtocols(ie6_probed, null, {null_origin:true}),
-            ['jsonp-polling'])
-    deepEqual(u.detectProtocols(ie8_probed, null, {null_origin:true}),
-            ['iframe-htmlfile', 'iframe-xhr-polling'])
-    deepEqual(u.detectProtocols(ie10_probed, null, {null_origin:true}),
-            ['websocket', 'iframe-htmlfile', 'iframe-xhr-polling'])
-
-test "EventEmitter", ->
-    expect(7)
-    r = new SockJS('//1.2.3.4/wrongurl', null,
-                   {protocols_whitelist: []})
-    r.addEventListener 'message', -> ok(true)
-    r.onmessage = -> ok(false)
-    bluff = -> ok(false)
-    r.addEventListener 'message', bluff
-    r.removeEventListener 'message', bluff
-    r.addEventListener 'message', bluff
-    r.addEventListener 'message', -> ok(true)
-    r.onmessage = -> ok(true)
-    r.removeEventListener 'message', bluff
-    r.dispatchEvent({type:'message'})
-
-    # Per DOM Level 3, addEventListener and removeEventListener does not effect
-    # a pending dispatchEvent. This is consistent with IE and older Opera, but
-    # not other browsers (which implement the DOM Level 2 behavior). IE's is
-    # simpler, so we mimic it as this is not an important edge case.
-    #
-    # See https://github.com/sockjs/sockjs-client/pull/127
-    handler0 = -> log.push(0)
-    handler1 = ->
-        log.push(1)
-        r.removeEventListener 'test', handler0
-        r.removeEventListener 'test', handler2
-        r.addEventListener 'test', handler3
-        r.addEventListener 'test', handler4
-    handler2 = -> log.push(2)
-    handler3 = ->
-        log.push(3)
-        r.removeEventListener 'test', handler1
-        r.removeEventListener 'test', handler3
-        r.removeEventListener 'test', handler4
-    handler4 = -> log.push(4)
-    r.addEventListener 'test', handler0
-    r.addEventListener 'test', handler1
-    r.addEventListener 'test', handler2
-
-    # Should run the registered listeners when first calling.
-    log = []
-    r.dispatchEvent({type:'test'})
-    deepEqual(log, [0, 1, 2])
-
-    # Should run the new listeners and not crash even though we remove the last
-    # one mid-dispatch.
-    log = []
-    r.dispatchEvent({type:'test'})
-    deepEqual(log, [1, 3, 4])
-
-    # All event listeners gone. Should run none.
-    log = []
-    r.dispatchEvent({type:'test'})
-    deepEqual(log, [])
-
-    # Adding the same eventlistener should be indempotent (sockjs-client #4).
-    single = -> ok(true)
-    r.addEventListener 'close', single
-    r.addEventListener 'close', single
-    r.dispatchEvent({type:'close'}) # 1 callback run
-    r.removeEventListener 'close', single
-    r.dispatchEvent({type:'close'}) # 0 runs
-    r.close()
-
-
-test "NoConstructor", ->
-    expect(2)
-    r = new SockJS('//1.2.3.4/blah', null, {protocols_whitelist: []})
-    ok(r instanceof SockJS)
-    r.close()
-    r = SockJS('//1.2.3.4/blah', null, {protocols_whitelist: []})
-    ok(r instanceof SockJS)
-    r.close()
diff --git a/tests/server.js b/tests/server.js
index f860a8d..920af81 100644
--- a/tests/server.js
+++ b/tests/server.js
@@ -1,10 +1,11 @@
+'use strict';
+
 var http = require('http');
 var node_static = require('node-static');
 
 var config = require('./config').config;
 
-var static_directory = new node_static.Server(__dirname + '/html');
-
+var static_directory = new node_static.Server(__dirname + '/html', { cache: 0 });
 
 var server = http.createServer();
 server.addListener('request', function(req, res) {
@@ -16,18 +17,18 @@ server.addListener('request', function(req, res) {
         }, 500);
     } else if ( /\/streaming.txt/.test(req.url) ) {
         res.setHeader('content-type', 'text/plain');
-        res.setHeader('Access-Control-Allow-Origin', '*')
+        res.setHeader('Access-Control-Allow-Origin', '*');
 
         res.writeHead(200);
-        res.write(Array(2049).join('a') + '\n');
+        res.write(new Array(2049).join('a') + '\n');
         setTimeout(function() {
             res.end('b\n');
         }, 250);
     } else if ( /\/simple.txt/.test(req.url) ) {
         res.setHeader('content-type', 'text/plain');
-        res.setHeader('Access-Control-Allow-Origin', '*')
+        res.setHeader('Access-Control-Allow-Origin', '*');
         res.writeHead(200);
-        res.end(Array(2049).join('a') + '\nb\n');
+        res.end(new Array(2049).join('a') + '\nb\n');
     } else if (req.url === '/config.js') {
         res.setHeader('content-type', 'application/javascript');
         res.writeHead(200);
diff --git a/tests/sockjs_app.js b/tests/sockjs_app.js
index 5a876bc..c4af0eb 100644
--- a/tests/sockjs_app.js
+++ b/tests/sockjs_app.js
@@ -1,3 +1,4 @@
+'use strict';
 var sockjs = require('sockjs');
 
 exports.install = function(opts, server) {
@@ -67,7 +68,7 @@ exports.install = function(opts, server) {
       var n = Math.floor(Number(m));
       n = (n > 0 && n < 19) ? n : 1;
       console.log('    [ ] amp message: 2^' + n);
-      conn.write(Array(Math.pow(2, n)+1).join('x'));
+      conn.write(new Array(Math.pow(2, n)+1).join('x'));
     });
   });
 
diff --git a/tests/sockjs_server.js b/tests/sockjs_server.js
index 4a5a757..25ac69c 100644
--- a/tests/sockjs_server.js
+++ b/tests/sockjs_server.js
@@ -1,3 +1,4 @@
+'use strict';
 var http = require('http');
 var node_static = require('node-static');
 var sockjs_app = require('./sockjs_app');
@@ -29,7 +30,7 @@ server.addListener('request', function(req, res) {
     res.setHeader('Access-Control-Allow-Origin', '*');
 
     res.writeHead(200);
-    res.write(Array(2049).join('a') + '\n');
+    res.write(new Array(2049).join('a') + '\n');
     setTimeout(function() {
         res.end('b\n');
     }, 250);
@@ -37,7 +38,7 @@ server.addListener('request', function(req, res) {
     res.setHeader('content-type', 'text/plain');
     res.setHeader('Access-Control-Allow-Origin', '*');
     res.writeHead(200);
-    res.end(Array(2049).join('a') + '\nb\n');
+    res.end(new Array(2049).join('a') + '\nb\n');
   } else if (req.url === '/config.js') {
     res.setHeader('content-type', 'application/javascript');
     res.writeHead(200);
diff --git a/version b/version
deleted file mode 100644
index 42045ac..0000000
--- a/version
+++ /dev/null
@@ -1 +0,0 @@
-0.3.4

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/sockjs-client.git



More information about the Pkg-javascript-commits mailing list