LP#1268619: websocket: avoid sharedworker for firefox 29
authorBill Erickson <berick@esilibrary.com>
Sun, 4 May 2014 19:58:17 +0000 (15:58 -0400)
committerGalen Charlton <gmc@esilibrary.com>
Tue, 19 Aug 2014 22:54:47 +0000 (15:54 -0700)
https://bugzilla.mozilla.org/show_bug.cgi?id=504553#c73

Avoid using SharedWorkers when useragent match "Firefox".  FF supports
shared workers, but it does not yet support WebSockets within shared
workers.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>

src/javascript/opensrf.js

index f9b0895..8036c5a 100644 (file)
@@ -257,7 +257,14 @@ OpenSRF.websocketConnected = function() {
 
 OpenSRF.Session.prototype.send_ws = function(osrf_msg) {
 
-    if (typeof SharedWorker == 'function') {
+    if (typeof SharedWorker == 'function' 
+
+        /*
+         * https://bugzilla.mozilla.org/show_bug.cgi?id=504553#c73
+         * Firefox does not yet support WebSockets in worker threads
+         */
+        && !navigator.userAgent.match(/Firefox/)
+    ) {
         // vanilla websockets requested, but this browser supports
         // shared workers, so use those instead.
         return this.send_ws_shared(osrf_msg);
@@ -305,7 +312,6 @@ OpenSRF.Session.setup_shared_ws = function() {
 
     OpenSRF.sharedWSWorker.port.addEventListener('message', function(e) {                          
         var data = e.data;
-        console.debug('sharedWSWorker received message of type: ' + data.action);
 
         if (data.action == 'message') {
             // pass all inbound message up the opensrf stack
@@ -329,7 +335,6 @@ OpenSRF.Session.setup_shared_ws = function() {
 
 
         if (data.action == 'event') {
-            console.debug('event type is ' + data.type);
             if (data.type.match(/onclose|onerror/)) {
                 OpenSRF.sharedWebsocketConnected = false;
                 if (OpenSRF.onWebSocketClosed)