refactor: replace webFrame.routingId with sync IPC (#47941)

* refactor: replace webFrame.routingId with sync IPC

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

* fix: GetConstructor missing isolate

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

* fix: missing isolate

Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Samuel Maddock <smaddock@slack-corp.com>
This commit is contained in:
trop[bot] 2025-08-08 10:55:05 +02:00 committed by GitHub
commit 74ad696f98
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 88 additions and 42 deletions

View file

@ -3,6 +3,7 @@ import * as ipcMainUtils from '@electron/internal/browser/ipc-main-internal-util
import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages';
import { clipboard } from 'electron/common';
import { webFrameMain } from 'electron/main';
import * as fs from 'fs';
import * as path from 'path';
@ -109,3 +110,17 @@ ipcMainInternal.on(IPC_MESSAGES.BROWSER_PRELOAD_ERROR, function (event, preloadP
if (event.type !== 'frame') return;
event.sender?.emit('preload-error', event, preloadPath, error);
});
ipcMainUtils.handleSync(IPC_MESSAGES.BROWSER_GET_FRAME_ROUTING_ID_SYNC, function (event, frameToken: string) {
if (event.type !== 'frame') return;
const senderFrame = event.senderFrame;
if (!senderFrame || senderFrame.isDestroyed()) return;
return webFrameMain.fromFrameToken(senderFrame.processId, frameToken)?.routingId;
});
ipcMainUtils.handleSync(IPC_MESSAGES.BROWSER_GET_FRAME_TOKEN_SYNC, function (event, routingId: number) {
if (event.type !== 'frame') return;
const senderFrame = event.senderFrame;
if (!senderFrame || senderFrame.isDestroyed()) return;
return webFrameMain.fromId(senderFrame.processId, routingId)?.frameToken;
});