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 807837 51d8015ea025b6bea0324b292ce874f931d59d7a
parent 807836 0f54a3e3cdeaa97f9dbd0c5265295377cc7dc5b9
child 807838 90193919ed4f000aab57d84579c60b3886fb9611
child 807844 743a03d50fc300c1afbb335e0ed0c6f99cdb4af6
push id113225
push userbmo:eglassercamp@mozilla.com
push dateFri, 15 Jun 2018 20:41:27 +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);
   },