feat: add webFrameMain.send() / webFrameMain.postMessage() (#26807)
This commit is contained in:
parent
28b6579538
commit
2be3d03630
14 changed files with 340 additions and 209 deletions
|
@ -2,7 +2,7 @@ import { expect } from 'chai';
|
|||
import * as http from 'http';
|
||||
import * as path from 'path';
|
||||
import * as url from 'url';
|
||||
import { BrowserWindow, WebFrameMain, webFrameMain } from 'electron/main';
|
||||
import { BrowserWindow, WebFrameMain, webFrameMain, ipcMain } from 'electron/main';
|
||||
import { closeAllWindows } from './window-helpers';
|
||||
import { emittedOnce, emittedNTimes } from './events-helpers';
|
||||
import { AddressInfo } from 'net';
|
||||
|
@ -173,6 +173,24 @@ describe('webFrameMain module', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('WebFrame.send', () => {
|
||||
it('works', async () => {
|
||||
const w = new BrowserWindow({
|
||||
show: false,
|
||||
webPreferences: {
|
||||
preload: path.join(subframesPath, 'preload.js'),
|
||||
nodeIntegrationInSubFrames: true
|
||||
}
|
||||
});
|
||||
await w.loadURL('about:blank');
|
||||
const webFrame = w.webContents.mainFrame;
|
||||
const pongPromise = emittedOnce(ipcMain, 'preload-pong');
|
||||
webFrame.send('preload-ping');
|
||||
const [, routingId] = await pongPromise;
|
||||
expect(routingId).to.equal(webFrame.routingId);
|
||||
});
|
||||
});
|
||||
|
||||
describe('disposed WebFrames', () => {
|
||||
let w: BrowserWindow;
|
||||
let webFrame: WebFrameMain;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue