[Pkg-javascript-commits] [sockjs-client] 246/434: #28 Don't start a websocket connection if we're after beforeunload

Tonnerre Lombard tonnerre-guest at moszumanska.debian.org
Wed Jan 8 00:47:17 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 fcef6bc2f2eef2926cdca5073bd34b1cae28ac1a
Author: Marek Majkowski <majek04 at gmail.com>
Date:   Thu Dec 1 17:40:21 2011 +0000

    #28 Don't start a websocket connection if we're after beforeunload
---
 lib/trans-websocket.js | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lib/trans-websocket.js b/lib/trans-websocket.js
index 813b724..a6ef09e 100644
--- a/lib/trans-websocket.js
+++ b/lib/trans-websocket.js
@@ -9,6 +9,16 @@ var WebSocketTransport = SockJS.websocket = function(ri, trans_url) {
     that.ri = ri;
     that.url = url;
     var Constructor = window.WebSocket || window.MozWebSocket;
+
+    if(_document_guard.state >= DocumentGuard.beforeunload) {
+        // Firefox has an interesting bug. If a websocket connection
+        // is created after onbeforeunload, it stays alive even when
+        // user navigates away from the page. In such situation let's
+        // lie - let's not open the ws connection at all. See:
+        // https://github.com/sockjs/sockjs-client/issues/28
+        return;
+    }
+
     that.ws = new Constructor(that.url);
     that.ws.onmessage = function(e) {
         that.ri._didMessage(e.data);

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