Bug 1440022: Some infrastructure for testing broadcast_subscribe r?lina draft
authorEthan Glasser-Camp <ethan@betacantrips.com>
Wed, 11 Apr 2018 10:48:01 -0400
changeset 807781 bdead4a90f1052e51263d22eb3a97f4f5b0a399e
parent 807780 b747583ed8c1e45d9227ef677061d9a2a54b2600
child 807782 af3d819aa8266506a421ada96e7f0f287a29bf1d
push id113213
push userbmo:eglassercamp@mozilla.com
push dateFri, 15 Jun 2018 18:42:58 +0000
reviewerslina
bugs1440022
milestone62.0a1
Bug 1440022: Some infrastructure for testing broadcast_subscribe r?lina 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,
@@ -254,16 +255,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);
   },