Handle unknown errors in addonManager.install() (#8653)
This commit is contained in:
Родитель
f70863c821
Коммит
14a911fb2c
|
@ -130,7 +130,8 @@ export function install(
|
||||||
installObj.addEventListener('onInstallEnded', () => resolve());
|
installObj.addEventListener('onInstallEnded', () => resolve());
|
||||||
installObj.addEventListener('onInstallFailed', () => reject());
|
installObj.addEventListener('onInstallFailed', () => reject());
|
||||||
log.info('Events to handle the installation initialized.');
|
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 () => {
|
it('passes the installObj, the event and the id to the callback', async () => {
|
||||||
const fakeEvent = { type: 'fakeEvent' };
|
const fakeEvent = { type: 'fakeEvent' };
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче