Bug 1440022: Some infrastructure for testing broadcast_subscribe r?lina
MozReview-Commit-ID: 8Re4EGCSbmi
--- 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);
},