Bug 1440022: Some infrastructure for testing broadcast_subscribe r?kitcambridge draft
authorEthan Glasser-Camp <ethan@betacantrips.com>
Wed, 11 Apr 2018 10:48:01 -0400
changeset 792609 e7fa0278fed9faecb4247c6ab2ab0915651fa877
parent 792608 3b64471ab9e1403fbc1855c4e0ecf5bea6201736
child 792610 6595ce0d34197c1bc74ab10fb63a9ae3b6803030
child 792611 7c7ae83601344b12cba61239587474660113e639
push id109162
push userbmo:eglassercamp@mozilla.com
push dateTue, 08 May 2018 18:35:34 +0000
reviewerskitcambridge
bugs1440022
milestone61.0a1
Bug 1440022: Some infrastructure for testing broadcast_subscribe r?kitcambridge MozReview-Commit-ID: 8Re4EGCSbmi
dom/push/test/xpcshell/head.js
--- a/dom/push/test/xpcshell/head.js
+++ b/dom/push/test/xpcshell/head.js
@@ -182,16 +182,17 @@ function compareAscending(a, b) {
  */
 function MockWebSocket(originalURI, handlers = {}) {
   this._originalURI = originalURI;
   this._onHello = handlers.onHello;
   this._onRegister = handlers.onRegister;
   this._onUnregister = handlers.onUnregister;
   this._onACK = handlers.onACK;
   this._onPing = handlers.onPing;
+  this._onBroadcastSubscribe = handlers.onBroadcastSubscribe;
 }
 
 MockWebSocket.prototype = {
   _originalURI: null,
   _onHello: null,
   _onRegister: null,
   _onUnregister: null,
   _onACK: null,
@@ -257,16 +258,23 @@ MockWebSocket.prototype = {
       if (typeof this._onPing == 'function') {
         this._onPing(request);
       } else {
         // Echo ping packets.
         this.serverSendMsg('{}');
       }
       break;
 
+    case 'broadcast_subscribe':
+      if (typeof this._onBroadcastSubscribe != 'function') {
+        throw new Error('Unexpected broadcast_subscribe');
+      }
+      this._onBroadcastSubscribe(request);
+      break;
+
     default:
       throw new Error('Unexpected message: ' + messageType);
     }
   },
 
   sendMsg(msg) {
     this._handleMessage(msg);
   },