fix(context): fire close event for persistent contexts (#2891)
This commit is contained in:
parent
8fe29feb21
commit
e90ba26250
|
|
@ -92,6 +92,8 @@ export abstract class BrowserBase extends EventEmitter implements Browser {
|
|||
_didClose() {
|
||||
for (const context of this.contexts())
|
||||
(context as BrowserContextBase)._browserClosed();
|
||||
if (this._defaultContext)
|
||||
this._defaultContext._browserClosed();
|
||||
this.emit(Events.Browser.Disconnected);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -367,4 +367,11 @@ describe('launchPersistentContext()', function() {
|
|||
expect(error).toBe(e);
|
||||
await removeUserDataDir(userDataDir);
|
||||
});
|
||||
it('should fire close event for a persistent context', async(state) => {
|
||||
const {context} = await launch(state);
|
||||
let closed = false;
|
||||
context.on('close', () => closed = true);
|
||||
await close(state);
|
||||
expect(closed).toBe(true);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue