fix: [webview] fix missing properties on events when contextIsolation: true (#26289)
This commit is contained in:
parent
c856b5fa53
commit
34156c424c
5 changed files with 51 additions and 24 deletions
|
@ -1,4 +1,4 @@
|
|||
import { webFrame, IpcMessageEvent } from 'electron';
|
||||
import { webFrame } from 'electron';
|
||||
import { ipcRendererInternal } from '@electron/internal/renderer/ipc-renderer-internal';
|
||||
import * as ipcRendererUtils from '@electron/internal/renderer/ipc-renderer-internal-utils';
|
||||
import { webViewEvents } from '@electron/internal/common/web-view-events';
|
||||
|
@ -17,15 +17,15 @@ const dispatchEvent = function (
|
|||
dispatchEvent(webView, DEPRECATED_EVENTS[eventName], eventKey, ...args);
|
||||
}
|
||||
|
||||
const domEvent = new Event(eventName) as ElectronInternal.WebViewEvent;
|
||||
const props: Record<string, any> = {};
|
||||
webViewEvents[eventKey].forEach((prop, index) => {
|
||||
(domEvent as any)[prop] = args[index];
|
||||
props[prop] = args[index];
|
||||
});
|
||||
|
||||
webView.dispatchEvent(domEvent);
|
||||
webView.dispatchEvent(eventName, props);
|
||||
|
||||
if (eventName === 'load-commit') {
|
||||
webView.onLoadCommit(domEvent);
|
||||
webView.onLoadCommit(props);
|
||||
} else if (eventName === 'focus-change') {
|
||||
webView.onFocusChange();
|
||||
}
|
||||
|
@ -35,8 +35,7 @@ export function registerEvents (webView: WebViewImpl, viewInstanceId: number) {
|
|||
ipcRendererInternal.on(`${IPC_MESSAGES.GUEST_VIEW_INTERNAL_DESTROY_GUEST}-${viewInstanceId}`, function () {
|
||||
webView.guestInstanceId = undefined;
|
||||
webView.reset();
|
||||
const domEvent = new Event('destroyed');
|
||||
webView.dispatchEvent(domEvent);
|
||||
webView.dispatchEvent('destroyed');
|
||||
});
|
||||
|
||||
ipcRendererInternal.on(`${IPC_MESSAGES.GUEST_VIEW_INTERNAL_DISPATCH_EVENT}-${viewInstanceId}`, function (event, eventName, ...args) {
|
||||
|
@ -44,11 +43,7 @@ export function registerEvents (webView: WebViewImpl, viewInstanceId: number) {
|
|||
});
|
||||
|
||||
ipcRendererInternal.on(`${IPC_MESSAGES.GUEST_VIEW_INTERNAL_IPC_MESSAGE}-${viewInstanceId}`, function (event, channel, ...args) {
|
||||
const domEvent = new Event('ipc-message') as IpcMessageEvent;
|
||||
domEvent.channel = channel;
|
||||
domEvent.args = args;
|
||||
|
||||
webView.dispatchEvent(domEvent);
|
||||
webView.dispatchEvent('ipc-message', { channel, args });
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue