feat(extensions): expose ExtensionRegistryObserver events in Session (#25385)
* feat(extensions): expose ExtensionRegistryObserver events in Session Extensions can be loaded and unloaded for various reasons. In some cases this can occur by no means of the Electron programmer, such as in the case of chrome.runtime.reload(). In order to be able to manage state about extensions outside of Electron's APIs, events reloaded to loading and unloaded are needed. * docs(extensions): elaborate on extension-loaded/unloaded details * fix: remove scoped extension registry observer * docs: update extension-unloaded
This commit is contained in:
parent
881ac995da
commit
9d0d9a1664
4 changed files with 92 additions and 0 deletions
|
@ -123,6 +123,23 @@ describe('chrome extensions', () => {
|
|||
}
|
||||
});
|
||||
|
||||
it('emits extension lifecycle events', async () => {
|
||||
const customSession = session.fromPartition(`persist:${require('uuid').v4()}`);
|
||||
|
||||
const loadedPromise = emittedOnce(customSession, 'extension-loaded');
|
||||
const extension = await customSession.loadExtension(path.join(fixtures, 'extensions', 'red-bg'));
|
||||
const [, loadedExtension] = await loadedPromise;
|
||||
const [, readyExtension] = await emittedOnce(customSession, 'extension-ready');
|
||||
|
||||
expect(loadedExtension.id).to.equal(extension.id);
|
||||
expect(readyExtension.id).to.equal(extension.id);
|
||||
|
||||
const unloadedPromise = emittedOnce(customSession, 'extension-unloaded');
|
||||
await customSession.removeExtension(extension.id);
|
||||
const [, unloadedExtension] = await unloadedPromise;
|
||||
expect(unloadedExtension.id).to.equal(extension.id);
|
||||
});
|
||||
|
||||
it('lists loaded extensions in getAllExtensions', async () => {
|
||||
const customSession = session.fromPartition(`persist:${require('uuid').v4()}`);
|
||||
const e = await customSession.loadExtension(path.join(fixtures, 'extensions', 'red-bg'));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue