From 9fdef970f3785e958090f8edf4ad37ece4459343 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Sun, 4 May 2014 15:58:17 -0400 Subject: [PATCH] LP#1268619: websocket: avoid sharedworker for firefox 29 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 Signed-off-by: Galen Charlton --- src/javascript/opensrf.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/javascript/opensrf.js b/src/javascript/opensrf.js index f9b0895..8036c5a 100644 --- a/src/javascript/opensrf.js +++ b/src/javascript/opensrf.js @@ -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) -- 2.11.0