mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 10:44:56 +00:00
Backed out changeset 0943ef016d1c (bug 1277026
)
MozReview-Commit-ID: HlPMAtJZ2Pp
This commit is contained in:
parent
e74c05284e
commit
7cd6c3a3bf
@ -115,46 +115,37 @@ FxAccountsPushService.prototype = {
|
|||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
observe(subject, topic, data) {
|
observe(subject, topic, data) {
|
||||||
this.log.trace(`observed topic=${topic}, data=${data}, subject=${subject}`);
|
this.log.trace(`observed topic=${topic}, data=${data}, subject=${subject}`);
|
||||||
switch (topic) {
|
switch (topic) {
|
||||||
case this.pushService.pushTopic:
|
case this.pushService.pushTopic:
|
||||||
if (data === FXA_PUSH_SCOPE_ACCOUNT_UPDATE) {
|
if (data === FXA_PUSH_SCOPE_ACCOUNT_UPDATE) {
|
||||||
let message = subject.QueryInterface(Ci.nsIPushMessage);
|
this._onPushMessage();
|
||||||
this._onPushMessage(message);
|
}
|
||||||
}
|
break;
|
||||||
break;
|
case this.pushService.subscriptionChangeTopic:
|
||||||
case this.pushService.subscriptionChangeTopic:
|
if (data === FXA_PUSH_SCOPE_ACCOUNT_UPDATE) {
|
||||||
if (data === FXA_PUSH_SCOPE_ACCOUNT_UPDATE) {
|
this._onPushSubscriptionChange();
|
||||||
this._onPushSubscriptionChange();
|
}
|
||||||
}
|
break;
|
||||||
break;
|
case ONLOGOUT_NOTIFICATION:
|
||||||
case ONLOGOUT_NOTIFICATION:
|
// user signed out, we need to stop polling the Push Server
|
||||||
// user signed out, we need to stop polling the Push Server
|
this.unsubscribe().catch(err => {
|
||||||
this.unsubscribe().catch(err => {
|
this.log.error("Error during unsubscribe", err);
|
||||||
this.log.error("Error during unsubscribe", err);
|
});
|
||||||
});
|
break;
|
||||||
break;
|
default:
|
||||||
default:
|
break;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Fired when the Push server sends a notification.
|
* Fired when the Push server sends a notification.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_onPushMessage(message) {
|
_onPushMessage() {
|
||||||
this.log.trace("FxAccountsPushService _onPushMessage");
|
this.log.trace("FxAccountsPushService _onPushMessage");
|
||||||
if (!message.data) {
|
// Use this signal to check the verification state of the account right away
|
||||||
// Use the empty signal to check the verification state of the account right away
|
this.fxAccounts.checkVerificationStatus();
|
||||||
this.fxAccounts.checkVerificationStatus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let payload = message.data.json();
|
|
||||||
switch (payload.command) {
|
|
||||||
default:
|
|
||||||
this.log.warn("FxA Push command unrecognized: " + payload.command);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Fired when the Push server drops a subscription, or the subscription identifier changes.
|
* Fired when the Push server drops a subscription, or the subscription identifier changes.
|
||||||
|
@ -49,7 +49,7 @@ let mockLog = {
|
|||||||
|
|
||||||
add_task(function* initialize() {
|
add_task(function* initialize() {
|
||||||
let pushService = new FxAccountsPushService();
|
let pushService = new FxAccountsPushService();
|
||||||
equal(pushService.initialize(), false);
|
do_check_eq(pushService.initialize(), false);
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(function* registerPushEndpointSuccess() {
|
add_task(function* registerPushEndpointSuccess() {
|
||||||
@ -59,7 +59,7 @@ add_task(function* registerPushEndpointSuccess() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let subscription = yield pushService.registerPushEndpoint();
|
let subscription = yield pushService.registerPushEndpoint();
|
||||||
equal(subscription.endpoint, MOCK_ENDPOINT);
|
do_check_eq(subscription.endpoint, MOCK_ENDPOINT);
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(function* registerPushEndpointFailure() {
|
add_task(function* registerPushEndpointFailure() {
|
||||||
@ -75,7 +75,7 @@ add_task(function* registerPushEndpointFailure() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let subscription = yield pushService.registerPushEndpoint();
|
let subscription = yield pushService.registerPushEndpoint();
|
||||||
equal(subscription, null);
|
do_check_eq(subscription, null);
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(function* unsubscribeSuccess() {
|
add_task(function* unsubscribeSuccess() {
|
||||||
@ -85,7 +85,7 @@ add_task(function* unsubscribeSuccess() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let result = yield pushService.unsubscribe();
|
let result = yield pushService.unsubscribe();
|
||||||
equal(result, true);
|
do_check_eq(result, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(function* unsubscribeFailure() {
|
add_task(function* unsubscribeFailure() {
|
||||||
@ -101,7 +101,7 @@ add_task(function* unsubscribeFailure() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let result = yield pushService.unsubscribe();
|
let result = yield pushService.unsubscribe();
|
||||||
equal(result, null);
|
do_check_eq(result, null);
|
||||||
});
|
});
|
||||||
|
|
||||||
add_test(function observeLogout() {
|
add_test(function observeLogout() {
|
||||||
@ -122,15 +122,10 @@ add_test(function observeLogout() {
|
|||||||
pushService.observe(null, ONLOGOUT_NOTIFICATION);
|
pushService.observe(null, ONLOGOUT_NOTIFICATION);
|
||||||
});
|
});
|
||||||
|
|
||||||
add_test(function observePushTopicVerify() {
|
add_test(function observePushTopic() {
|
||||||
let emptyMsg = {
|
|
||||||
QueryInterface: function() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
let customAccounts = Object.assign(mockFxAccounts, {
|
let customAccounts = Object.assign(mockFxAccounts, {
|
||||||
checkVerificationStatus: function () {
|
checkVerificationStatus: function () {
|
||||||
// checking verification status on push messages without data
|
// checking verification status on push messages
|
||||||
run_next_test();
|
run_next_test();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -140,7 +135,7 @@ add_test(function observePushTopicVerify() {
|
|||||||
fxAccounts: customAccounts,
|
fxAccounts: customAccounts,
|
||||||
});
|
});
|
||||||
|
|
||||||
pushService.observe(emptyMsg, mockPushService.pushTopic, FXA_PUSH_SCOPE_ACCOUNT_UPDATE);
|
pushService.observe(null, mockPushService.pushTopic, FXA_PUSH_SCOPE_ACCOUNT_UPDATE);
|
||||||
});
|
});
|
||||||
|
|
||||||
add_test(function observeSubscriptionChangeTopic() {
|
add_test(function observeSubscriptionChangeTopic() {
|
||||||
@ -158,3 +153,8 @@ add_test(function observeSubscriptionChangeTopic() {
|
|||||||
|
|
||||||
pushService.observe(null, mockPushService.subscriptionChangeTopic, FXA_PUSH_SCOPE_ACCOUNT_UPDATE);
|
pushService.observe(null, mockPushService.subscriptionChangeTopic, FXA_PUSH_SCOPE_ACCOUNT_UPDATE);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
function run_test() {
|
||||||
|
run_next_test();
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user