Handle unknown errors in addonManager.install() (#8653)

This commit is contained in:
William Durand 2019-09-24 15:22:06 +02:00 коммит произвёл GitHub
Родитель f70863c821
Коммит 14a911fb2c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 21 добавлений и 1 удалений

Просмотреть файл

@ -130,7 +130,8 @@ export function install(
installObj.addEventListener('onInstallEnded', () => resolve());
installObj.addEventListener('onInstallFailed', () => reject());
log.info('Events to handle the installation initialized.');
installObj.install();
// See: https://github.com/mozilla/addons-frontend/issues/8633
installObj.install().catch(reject);
});
});
}

Просмотреть файл

@ -197,6 +197,25 @@ describe(__filename, () => {
);
});
it('rejects if the install returns an error', () => {
const error = new Error('oops');
fakeInstallObj.install = sinon.spy(() => {
return Promise.reject(error);
});
return (
addonManager
.install(fakeInstallUrl, fakeCallback, {
_mozAddonManager: fakeMozAddonManager,
src: 'home',
})
// The second argument is the reject function.
.then(unexpectedSuccess, () => {
sinon.assert.calledOnce(fakeInstallObj.install);
})
);
});
it('passes the installObj, the event and the id to the callback', async () => {
const fakeEvent = { type: 'fakeEvent' };