fix: do not throw on removeListener without listener (#15224)
Co-authored-by: Andrey Lushnikov <aslushnikov@gmail.com>
This commit is contained in:
Родитель
461bd92f12
Коммит
b3c31f5b13
|
@ -119,7 +119,8 @@ export class JoiningEventEmitter implements EventEmitter {
|
|||
}
|
||||
|
||||
private _wrapper(listener: (...args: any[]) => void) {
|
||||
return (listener as any)[wrapperListener];
|
||||
// Fallback to original listener if not wrapped to ensure backwards compatibility Node.js's event emitter
|
||||
return (listener as any)[wrapperListener] ?? listener;
|
||||
}
|
||||
|
||||
private _original(wrapper: Function): Function {
|
||||
|
|
|
@ -128,3 +128,7 @@ it('should handle window', async ({ page, browserName, isElectron }) => {
|
|||
]);
|
||||
expect(error.message).toBe(browserName === 'chromium' ? 'Window' : '[object Window]');
|
||||
});
|
||||
|
||||
it('should remove a listener of a non-existing event handler', async ({ page }) => {
|
||||
page.removeListener('pageerror', () => {});
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче