[Pkg-javascript-commits] [sockjs-client] 168/434: #14 support `wasClean` property on CloseEvent

Tonnerre Lombard tonnerre-guest at moszumanska.debian.org
Wed Jan 8 00:47:11 UTC 2014


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

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

commit a22c5781576ee7a2a5af945a960718ddf8fdd52d
Author: Marek Majkowski <majek04 at gmail.com>
Date:   Wed Oct 12 14:25:56 2011 +0100

    #14 support `wasClean` property on CloseEvent
---
 lib/sockjs.js               |  5 ++++-
 tests/html/src/tests.coffee | 18 ++++++++++++------
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/lib/sockjs.js b/lib/sockjs.js
index 11ea16b..33eb67c 100644
--- a/lib/sockjs.js
+++ b/lib/sockjs.js
@@ -76,7 +76,9 @@ SockJS.prototype._didClose = function(code, reason) {
         clearTimeout(that._transport_tref);
         that._transport_tref = null;
     }
-    var close_event = new SimpleEvent("close", {code: code, reason: reason});
+    var close_event = new SimpleEvent("close", {code: code,
+                                                reason: reason,
+                                                wasClean: utils.userSetCode(code)});
 
     if (!utils.userSetCode(code) && that.readyState === SockJS.CONNECTING) {
         if (that._try_next_protocol(close_event)) {
@@ -94,6 +96,7 @@ SockJS.prototype._didClose = function(code, reason) {
         }
         close_event = new SimpleEvent("close", {code: 2000,
                                                 reason: "All transports failed",
+                                                wasClean: false,
                                                 last_event: close_event});
     }
     that.readyState = SockJS.CLOSED;
diff --git a/tests/html/src/tests.coffee b/tests/html/src/tests.coffee
index 46a4402..e0ebdee 100644
--- a/tests/html/src/tests.coffee
+++ b/tests/html/src/tests.coffee
@@ -203,7 +203,7 @@ factor_batch_large_amp = (protocol) ->
 
 factor_user_close = (protocol) ->
     return ->
-        expect(4)
+        expect(5)
         r = newSockJS('/echo', protocol)
         ok(r)
         counter = 0
@@ -218,12 +218,13 @@ factor_user_close = (protocol) ->
         r.onclose = (e) ->
             counter += 1
             log('user_close ' + e.code + ' ' + e.reason)
+            equals(e.wasClean, true)
             ok(counter is 2)
             start()
 
 factor_server_close = (protocol) ->
     return ->
-        expect(4)
+        expect(5)
         r = newSockJS('/close', protocol)
         ok(r)
         r.onopen = (e) ->
@@ -233,11 +234,12 @@ factor_server_close = (protocol) ->
         r.onclose = (e) ->
             equals(e.code, 3000)
             equals(e.reason, "Go away!")
+            equals(e.wasClean, true)
             start()
 
 test_invalid_url_404 = (protocol) ->
     return ->
-        expect(2)
+        expect(3)
         r = newSockJS('/invalid_url', protocol)
         ok(r)
         counter =
@@ -248,11 +250,12 @@ test_invalid_url_404 = (protocol) ->
         r.onclose = (e) ->
             log('404', e)
             equals(e.code, 2000)
+            equals(e.wasClean, false)
             start()
 
 test_invalid_url_500 = (protocol) ->
     return ->
-        expect(2)
+        expect(3)
         r = newSockJS('/500_error', protocol)
         ok(r)
         r.onopen = (e) ->
@@ -260,11 +263,12 @@ test_invalid_url_500 = (protocol) ->
         r.onclose = (e) ->
             log('500', e)
             equals(e.code, 2000)
+            equals(e.wasClean, false)
             start()
 
 test_invalid_url_port = (protocol) ->
     return ->
-        expect(2)
+        expect(3)
         dl = document.location
         r = newSockJS(dl.protocol + '//' + dl.hostname + ':1079', protocol)
         ok(r)
@@ -273,6 +277,7 @@ test_invalid_url_port = (protocol) ->
         r.onclose = (e) ->
             log('port', e)
             equals(e.code, 2000)
+            equals(e.wasClean, false)
             start()
 
 
@@ -417,7 +422,7 @@ asyncTest "chunking test, invalid url port", ->
             start()
 
 asyncTest "disabled websocket test", ->
-        expect(2)
+        expect(3)
         r = newSockJS('/disabled_websocket_echo', 'websocket')
         r.onopen = (e) ->
             fail(true)
@@ -426,6 +431,7 @@ asyncTest "disabled websocket test", ->
         r.onclose = (e) ->
             equals(e.code, 2000)
             equals(e.reason, "All transports failed")
+            equals(e.wasClean, false)
             start()
 
 

-- 
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