Auto-install extensions unit tests

This is a squashed version of PR #9581

Auto-install extensions unit tests, bug fixes, code cleanup

This adds unit tests for auto-installing extensions
* refactored code to facilitate testing
* added jsdoc annotations
* minor code cleanup
* fixes #9576

cc @dangoor 

There's no need there. In the case here, it can reject for reasons other than an actual error (the extension is already installed, for example). In ExtensionManagerDialog, I think the promise is only rejected for actual errors.