[Pkg-javascript-commits] [sockjs-client] 166/434: Fix #14. Renamed `status` property to `code` 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 2296591767a1ed8fc71aa269dd8f201061cccd19
Author: Marek Majkowski <majek04 at gmail.com>
Date:   Wed Oct 12 13:56:50 2011 +0100

    Fix #14. Renamed `status` property to `code` on CloseEvent.
---
 lib/sockjs.js               | 14 +++++++-------
 lib/trans-iframe-within.js  |  4 ++--
 lib/utils.js                |  8 ++++----
 tests/html/src/tests.coffee | 12 ++++++------
 4 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/lib/sockjs.js b/lib/sockjs.js
index 8e1a292..11ea16b 100644
--- a/lib/sockjs.js
+++ b/lib/sockjs.js
@@ -63,7 +63,7 @@ SockJS.prototype._dispatchMessage = function(data) {
 };
 
 
-SockJS.prototype._didClose = function(status, reason) {
+SockJS.prototype._didClose = function(code, reason) {
     var that = this;
     if (that.readyState !== SockJS.CONNECTING &&
         that.readyState !== SockJS.OPEN &&
@@ -76,9 +76,9 @@ SockJS.prototype._didClose = function(status, reason) {
         clearTimeout(that._transport_tref);
         that._transport_tref = null;
     }
-    var close_event = new SimpleEvent("close", {status: status, reason: reason});
+    var close_event = new SimpleEvent("close", {code: code, reason: reason});
 
-    if (!utils.userSetStatus(status) && that.readyState === SockJS.CONNECTING) {
+    if (!utils.userSetCode(code) && that.readyState === SockJS.CONNECTING) {
         if (that._try_next_protocol(close_event)) {
             that._transport_tref = setTimeout(
                 function() {
@@ -92,7 +92,7 @@ SockJS.prototype._didClose = function(status, reason) {
                 }, 5001);
             return;
         }
-        close_event = new SimpleEvent("close", {status: 2000,
+        close_event = new SimpleEvent("close", {code: 2000,
                                                 reason: "All transports failed",
                                                 last_event: close_event});
     }
@@ -171,16 +171,16 @@ SockJS.prototype._try_next_protocol = function(close_event) {
     }
 };
 
-SockJS.prototype.close = function(status, reason) {
+SockJS.prototype.close = function(code, reason) {
     var that = this;
-    if (status && !utils.userSetStatus(status))
+    if (code && !utils.userSetCode(code))
         throw new Error("INVALID_ACCESS_ERR");
     if(that.readyState !== SockJS.CONNECTING &&
        that.readyState !== SockJS.OPEN) {
         return false;
     }
     that.readyState = SockJS.CLOSING;
-    that._didClose(status || 1000, reason || "Normal closure");
+    that._didClose(code || 1000, reason || "Normal closure");
     return true;
 };
 
diff --git a/lib/trans-iframe-within.js b/lib/trans-iframe-within.js
index 630257a..203eb9f 100644
--- a/lib/trans-iframe-within.js
+++ b/lib/trans-iframe-within.js
@@ -9,8 +9,8 @@ var postMessage = function (type, data) {
 };
 
 var FacadeJS = function() {};
-FacadeJS.prototype._didClose = function (status, reason) {
-    postMessage('t', utils.closeFrame(status, reason));
+FacadeJS.prototype._didClose = function (code, reason) {
+    postMessage('t', utils.closeFrame(code, reason));
 };
 FacadeJS.prototype._didMessage = function (frame) {
     postMessage('t', frame);
diff --git a/lib/utils.js b/lib/utils.js
index 41dee37..0e44a62 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -295,12 +295,12 @@ utils.createHtmlfile = function (iframe_url, error_callback) {
     };
 };
 
-utils.closeFrame = function (status, reason) {
-    return 'c'+JSON.stringify([status, reason]);
+utils.closeFrame = function (code, reason) {
+    return 'c'+JSON.stringify([code, reason]);
 };
 
-utils.userSetStatus = function (status) {
-    return status === 1000 || (status >= 3000 && status <= 4999);
+utils.userSetCode = function (code) {
+    return code === 1000 || (code >= 3000 && code <= 4999);
 };
 
 utils.log = function() {
diff --git a/tests/html/src/tests.coffee b/tests/html/src/tests.coffee
index 5e1ded0..46a4402 100644
--- a/tests/html/src/tests.coffee
+++ b/tests/html/src/tests.coffee
@@ -217,7 +217,7 @@ factor_user_close = (protocol) ->
             counter += 1
         r.onclose = (e) ->
             counter += 1
-            log('user_close ' + e.status + ' ' + e.reason)
+            log('user_close ' + e.code + ' ' + e.reason)
             ok(counter is 2)
             start()
 
@@ -231,7 +231,7 @@ factor_server_close = (protocol) ->
         r.onmessage = (e) ->
             fail(true)
         r.onclose = (e) ->
-            equals(e.status, 3000)
+            equals(e.code, 3000)
             equals(e.reason, "Go away!")
             start()
 
@@ -247,7 +247,7 @@ test_invalid_url_404 = (protocol) ->
             fail(true)
         r.onclose = (e) ->
             log('404', e)
-            equals(e.status, 2000)
+            equals(e.code, 2000)
             start()
 
 test_invalid_url_500 = (protocol) ->
@@ -259,7 +259,7 @@ test_invalid_url_500 = (protocol) ->
             fail(true)
         r.onclose = (e) ->
             log('500', e)
-            equals(e.status, 2000)
+            equals(e.code, 2000)
             start()
 
 test_invalid_url_port = (protocol) ->
@@ -272,7 +272,7 @@ test_invalid_url_port = (protocol) ->
             fail(true)
         r.onclose = (e) ->
             log('port', e)
-            equals(e.status, 2000)
+            equals(e.code, 2000)
             start()
 
 
@@ -424,7 +424,7 @@ asyncTest "disabled websocket test", ->
         r.onmessage = (e) ->
             fail(true)
         r.onclose = (e) ->
-            equals(e.status, 2000)
+            equals(e.code, 2000)
             equals(e.reason, "All transports failed")
             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