Bug 1943111 - Fix pref observer to use the branched name r=asuth
Differential Revision: https://phabricator.services.mozilla.com/D235199
This commit is contained in:
@@ -142,7 +142,7 @@ export var PushServiceWebSocket = {
|
||||
},
|
||||
|
||||
observe(aSubject, aTopic, aData) {
|
||||
if (aTopic == "nsPref:changed" && aData == "dom.push.userAgentID") {
|
||||
if (aTopic == "nsPref:changed" && aData == "userAgentID") {
|
||||
this._onUAIDChanged();
|
||||
} else if (aTopic == "timer-callback") {
|
||||
this._onTimerFired(aSubject);
|
||||
|
||||
@@ -2,3 +2,7 @@
|
||||
[Fire pushsubscriptionchange event when permission is revoked]
|
||||
expected:
|
||||
if os == "android": FAIL
|
||||
|
||||
[Fire pushsubscriptionchange event when UAID changes]
|
||||
expected:
|
||||
if os == "android": FAIL
|
||||
|
||||
@@ -33,3 +33,25 @@ promise_test(async (t) => {
|
||||
assert_equals(pushSubscriptionChangeEvent.data.constructor, "PushSubscriptionChangeEvent");
|
||||
assert_object_equals(pushSubscriptionChangeEvent.data.oldSubscription, subscription.toJSON());
|
||||
}, "Fire pushsubscriptionchange event when permission is revoked");
|
||||
|
||||
promise_test(async (t) => {
|
||||
const promise = new Promise(r => {
|
||||
navigator.serviceWorker.addEventListener("message", r, { once: true })
|
||||
});
|
||||
|
||||
const subscription = await registration.pushManager.subscribe();
|
||||
t.add_cleanup(() => subscription.unsubscribe());
|
||||
|
||||
await SpecialPowers.spawnChrome([], async () => {
|
||||
// Bug 1210943: UAID changes should drop existing push subscriptions
|
||||
const uaid = await Services.prefs.getStringPref("dom.push.userAgentID");
|
||||
await Services.prefs.setStringPref("dom.push.userAgentID", uaid + "0");
|
||||
})
|
||||
|
||||
const pushSubscriptionChangeEvent = await promise;
|
||||
|
||||
assert_equals(pushSubscriptionChangeEvent.data.type, "pushsubscriptionchange");
|
||||
assert_equals(pushSubscriptionChangeEvent.data.constructor, "PushSubscriptionChangeEvent");
|
||||
assert_object_equals(pushSubscriptionChangeEvent.data.oldSubscription, subscription.toJSON());
|
||||
assert_equals(pushSubscriptionChangeEvent.data.newSubscription, undefined);
|
||||
}, "Fire pushsubscriptionchange event when UAID changes");
|
||||
|
||||
Reference in New Issue
Block a user