From 33b0a3512ecedf33a27ef53965530d569b6ba810 Mon Sep 17 00:00:00 2001 From: clavin Date: Thu, 25 Dec 2025 01:15:19 -0700 Subject: [PATCH] feat: `WebContents` extends `EventEmitter` --- lib/browser/api/web-contents.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/browser/api/web-contents.ts b/lib/browser/api/web-contents.ts index dde4432a6d..f2807e7562 100644 --- a/lib/browser/api/web-contents.ts +++ b/lib/browser/api/web-contents.ts @@ -8,6 +8,7 @@ import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages'; import { app, session, webFrameMain, dialog } from 'electron/main'; import type { BrowserWindowConstructorOptions, MessageBoxOptions, NavigationEntry } from 'electron/main'; +import { EventEmitter } from 'events'; import * as path from 'path'; import * as url from 'url'; @@ -118,6 +119,8 @@ const binding = process._linkedBinding('electron_browser_web_contents'); const printing = process._linkedBinding('electron_browser_printing'); const { WebContents } = binding as { WebContents: { prototype: Electron.WebContents } }; +Object.setPrototypeOf(WebContents.prototype, EventEmitter.prototype); + WebContents.prototype.postMessage = function (...args) { return this.mainFrame.postMessage(...args); };