diff --git a/dom/push/PushServiceHttp2.jsm b/dom/push/PushServiceHttp2.jsm index b9303bf4493f..1711723cf4ce 100644 --- a/dom/push/PushServiceHttp2.jsm +++ b/dom/push/PushServiceHttp2.jsm @@ -330,6 +330,7 @@ SubscriptionListener.prototype = { scope: this._subInfo.record.scope, originAttributes: this._subInfo.record.originAttributes, systemRecord: this._subInfo.record.systemRecord, + appServerKey: this._subInfo.record.appServerKey, ctime: Date.now(), }); diff --git a/dom/push/PushServiceWebSocket.jsm b/dom/push/PushServiceWebSocket.jsm index dafd110b9391..38c441ce6a89 100644 --- a/dom/push/PushServiceWebSocket.jsm +++ b/dom/push/PushServiceWebSocket.jsm @@ -906,6 +906,7 @@ this.PushServiceWebSocket = { originAttributes: tmp.record.originAttributes, version: null, systemRecord: tmp.record.systemRecord, + appServerKey: tmp.record.appServerKey, ctime: Date.now(), }); Services.telemetry.getHistogramById("PUSH_API_SUBSCRIBE_WS_TIME").add(Date.now() - tmp.ctime); @@ -1047,6 +1048,13 @@ this.PushServiceWebSocket = { let data = {channelID: this._generateID(), messageType: "register"}; + if (record.appServerKey) { + data.key = ChromeUtils.base64URLEncode(record.appServerKey, { + // The Push server requires padding. + pad: true, + }); + } + return new Promise((resolve, reject) => { this._registerRequests.set(data.channelID, { record: record, diff --git a/dom/push/test/mochitest.ini b/dom/push/test/mochitest.ini index 1ee91ce42b5a..7dc3587361e8 100644 --- a/dom/push/test/mochitest.ini +++ b/dom/push/test/mochitest.ini @@ -12,6 +12,7 @@ support-files = [test_has_permissions.html] [test_permissions.html] [test_register.html] +[test_register_key.html] [test_multiple_register.html] [test_multiple_register_during_service_activation.html] [test_unregister.html] diff --git a/dom/push/test/test_register_key.html b/dom/push/test/test_register_key.html new file mode 100644 index 000000000000..dcfce5b8e309 --- /dev/null +++ b/dom/push/test/test_register_key.html @@ -0,0 +1,206 @@ + + + +
+++ + + +