зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1443115 - Handle FxA pushEndpointExpired flag. r=markh
MozReview-Commit-ID: B0YIrtoSpOI --HG-- extra : rebase_source : 1bf3892286914807157f3ac987f084f159d6639e
This commit is contained in:
Родитель
1a43163be4
Коммит
3a0bca5c18
|
@ -692,8 +692,17 @@ FxAccountsInternal.prototype = {
|
|||
},
|
||||
|
||||
async getDeviceList() {
|
||||
let accountData = await this._getVerifiedAccountOrReject();
|
||||
return this.fxAccountsClient.getDeviceList(accountData.sessionToken);
|
||||
const accountData = await this._getVerifiedAccountOrReject();
|
||||
const devices = await this.fxAccountsClient.getDeviceList(accountData.sessionToken);
|
||||
|
||||
// Check if our push registration is still good.
|
||||
const ourDevice = devices.find(device => device.isCurrentDevice);
|
||||
if (ourDevice.pushEndpointExpired) {
|
||||
await this.fxaPushService.unsubscribe();
|
||||
await this._registerOrUpdateDevice(accountData);
|
||||
}
|
||||
|
||||
return devices;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -131,7 +131,7 @@ add_task(async function test_updateDeviceRegistration_with_new_device() {
|
|||
const credentials = getTestUser("baz");
|
||||
const fxa = new MockFxAccounts({ name: deviceName });
|
||||
await fxa.internal.setSignedInUser(credentials);
|
||||
// Remove the current device registration (setSIgnedInUser does one!).
|
||||
// Remove the current device registration (setSignedInUser does one!).
|
||||
await fxa.updateUserAccountData({uid: credentials.uid, device: null});
|
||||
|
||||
const spy = {
|
||||
|
@ -532,6 +532,40 @@ add_task(async function test_migration_toplevel_deviceId_to_device() {
|
|||
Assert.ok(!data.deviceRegistrationVersion);
|
||||
});
|
||||
|
||||
add_task(async function test_devicelist_pushendpointexpired() {
|
||||
const deviceId = "mydeviceid";
|
||||
const credentials = getTestUser("baz");
|
||||
credentials.verified = true;
|
||||
const fxa = new MockFxAccounts();
|
||||
await fxa.internal.setSignedInUser(credentials);
|
||||
await fxa.updateUserAccountData({uid: credentials.uid, device: {
|
||||
id: deviceId,
|
||||
registrationVersion: 1 // < 42
|
||||
}});
|
||||
|
||||
const spy = {
|
||||
updateDevice: { count: 0, args: [] },
|
||||
getDeviceList: { count: 0, args: [] }
|
||||
};
|
||||
const client = fxa.internal.fxAccountsClient;
|
||||
client.updateDevice = function() {
|
||||
spy.updateDevice.count += 1;
|
||||
spy.updateDevice.args.push(arguments);
|
||||
return Promise.resolve({});
|
||||
};
|
||||
client.getDeviceList = function() {
|
||||
spy.getDeviceList.count += 1;
|
||||
spy.getDeviceList.args.push(arguments);
|
||||
return Promise.resolve([{id: "mydeviceid", name: "foo", type: "desktop",
|
||||
isCurrentDevice: true, pushEndpointExpired: true}]);
|
||||
};
|
||||
|
||||
await fxa.getDeviceList();
|
||||
|
||||
Assert.equal(spy.getDeviceList.count, 1);
|
||||
Assert.equal(spy.updateDevice.count, 1);
|
||||
});
|
||||
|
||||
function expandHex(two_hex) {
|
||||
// Return a 64-character hex string, encoding 32 identical bytes.
|
||||
let eight_hex = two_hex + two_hex + two_hex + two_hex;
|
||||
|
|
Загрузка…
Ссылка в новой задаче