diff --git a/dom/push/PushDB.jsm b/dom/push/PushDB.jsm index f3caa01b6a48..02f623fa7032 100644 --- a/dom/push/PushDB.jsm +++ b/dom/push/PushDB.jsm @@ -376,11 +376,10 @@ this.PushDB.prototype = { * * @param {String} aKeyID The registration ID. * @param {Function} aUpdateFunc A function that receives the existing - * registration record as its argument, and returns a new record. If the - * function returns `null` or `undefined`, the record will not be updated. - * If the record does not exist, the function will not be called. - * @returns {Promise} A promise resolved with either the updated record, or - * `undefined` if the record was not updated. + * registration record as its argument, and returns a new record. + * @returns {Promise} A promise resolved with either the updated record. + * Rejects if the record does not exist, or the function returns an invalid + * record. */ update: function(aKeyID, aUpdateFunc) { return new Promise((resolve, reject) => @@ -393,14 +392,13 @@ this.PushDB.prototype = { let record = aEvent.target.result; if (!record) { - console.error("update: Record does not exist", aKeyID); - return; + throw new Error("Record " + aKeyID + " does not exist"); } let newRecord = aUpdateFunc(this.toPushRecord(record)); if (!this.isValidRecord(newRecord)) { console.error("update: Ignoring invalid update", aKeyID, newRecord); - return; + throw new Error("Invalid update for record " + aKeyID); } function putRecord() { let req = aStore.put(newRecord); diff --git a/dom/push/PushService.jsm b/dom/push/PushService.jsm index 9485dc01f509..80e112f0e66e 100644 --- a/dom/push/PushService.jsm +++ b/dom/push/PushService.jsm @@ -829,9 +829,6 @@ this.PushService = { }); }); }).then(record => { - if (!record) { - throw new Error("Ignoring update for key ID " + keyID); - } gPushNotifier.notifySubscriptionModified(record.scope, record.principal); return record; @@ -880,18 +877,16 @@ this.PushService = { } return record; }).then(record => { - if (record) { - if (record.isExpired()) { - this._recordDidNotNotify(kDROP_NOTIFICATION_REASON_EXPIRED); - // Drop the registration in the background. If the user returns to the - // site, the service worker will be notified on the next `idle-daily` - // event. - this._backgroundUnregister(record, - Ci.nsIPushErrorReporter.UNSUBSCRIBE_QUOTA_EXCEEDED); - } else { - gPushNotifier.notifySubscriptionModified(record.scope, - record.principal); - } + if (record.isExpired()) { + this._recordDidNotNotify(kDROP_NOTIFICATION_REASON_EXPIRED); + // Drop the registration in the background. If the user returns to the + // site, the service worker will be notified on the next `idle-daily` + // event. + this._backgroundUnregister(record, + Ci.nsIPushErrorReporter.UNSUBSCRIBE_QUOTA_EXCEEDED); + } else { + gPushNotifier.notifySubscriptionModified(record.scope, + record.principal); } if (this._updateQuotaTestCallback) { // Callback so that test may be notified when the quota update is complete. diff --git a/dom/push/test/xpcshell/test_registration_success_http2.js b/dom/push/test/xpcshell/test_registration_success_http2.js index 3d985a08407a..010108ca3c4e 100644 --- a/dom/push/test/xpcshell/test_registration_success_http2.js +++ b/dom/push/test/xpcshell/test_registration_success_http2.js @@ -4,15 +4,6 @@ 'use strict'; Cu.import("resource://gre/modules/Services.jsm"); -Cu.import("resource://testing-common/PromiseTestUtils.jsm"); - -/////////////////// -// -// Whitelisting this test. -// As part of bug 1077403, the leaking uncaught rejection should be fixed. -// -// Instances of the rejection "record is undefined" may or may not appear. -PromiseTestUtils.thisTestLeaksUncaughtRejectionsAndShouldBeFixed(); const {PushDB, PushService, PushServiceHttp2} = serviceExports; diff --git a/dom/push/test/xpcshell/test_unregister_success_http2.js b/dom/push/test/xpcshell/test_unregister_success_http2.js index cd0898b528e4..f2eb3533181a 100644 --- a/dom/push/test/xpcshell/test_unregister_success_http2.js +++ b/dom/push/test/xpcshell/test_unregister_success_http2.js @@ -4,15 +4,6 @@ 'use strict'; Cu.import("resource://gre/modules/Services.jsm"); -Cu.import("resource://testing-common/PromiseTestUtils.jsm"); - -/////////////////// -// -// Whitelisting this test. -// As part of bug 1077403, the leaking uncaught rejection should be fixed. -// -// Instances of the rejection "record is undefined" may or may not appear. -PromiseTestUtils.thisTestLeaksUncaughtRejectionsAndShouldBeFixed(); const {PushDB, PushService, PushServiceHttp2} = serviceExports;