Avoid PhantomJS BroadcastChannel failure user/berick/broadcast-channel-phantom-fix
authorBill Erickson <berickxx@gmail.com>
Thu, 9 Nov 2017 16:39:12 +0000 (11:39 -0500)
committerBill Erickson <berickxx@gmail.com>
Thu, 9 Nov 2017 16:39:13 +0000 (11:39 -0500)
Current version of PhantomJS used for unit tests, etc. does not
recognize the relatively new BroadcastChannel object.  Avoid trying to
create such a channel when the executing code does not recognize it.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/web/js/ui/default/staff/services/auth.js

index 8912c78..ec83005 100644 (file)
@@ -53,7 +53,10 @@ function($q , $timeout , $rootScope , $window , $location , egNet , egHatch) {
         },
 
         // Listen for logout events in other tabs
-        authChannel : new BroadcastChannel('eg.auth')
+        // Current version of phantomjs (unit tests, etc.) does not 
+        // support BroadcastChannel, so just dummy it up.
+        authChannel : (typeof BroadcastChannel == 'undefined') ? 
+            {} : new BroadcastChannel('eg.auth')
     };
 
     /* Returns a promise, which is resolved if valid