fix: restrict sendToFrame to same-process frames by default (#26875)
This commit is contained in:
parent
76f721474e
commit
07a1c2a3e5
12 changed files with 89 additions and 36 deletions
|
@ -3,6 +3,7 @@ import * as path from 'path';
|
|||
import * as cp from 'child_process';
|
||||
import { closeAllWindows } from './window-helpers';
|
||||
import { emittedOnce } from './events-helpers';
|
||||
import { defer } from './spec-helpers';
|
||||
import { ipcMain, BrowserWindow } from 'electron/main';
|
||||
|
||||
describe('ipc main module', () => {
|
||||
|
@ -59,5 +60,30 @@ describe('ipc main module', () => {
|
|||
output = JSON.parse(output);
|
||||
expect(output).to.deep.equal(['error']);
|
||||
});
|
||||
|
||||
it('can be replied to', async () => {
|
||||
ipcMain.on('test-echo', (e, arg) => {
|
||||
e.reply('test-echo', arg);
|
||||
});
|
||||
defer(() => {
|
||||
ipcMain.removeAllListeners('test-echo');
|
||||
});
|
||||
|
||||
const w = new BrowserWindow({
|
||||
show: false,
|
||||
webPreferences: {
|
||||
nodeIntegration: true
|
||||
}
|
||||
});
|
||||
w.loadURL('about:blank');
|
||||
const v = await w.webContents.executeJavaScript(`new Promise((resolve, reject) => {
|
||||
const { ipcRenderer } = require('electron')
|
||||
ipcRenderer.send('test-echo', 'hello')
|
||||
ipcRenderer.on('test-echo', (e, v) => {
|
||||
resolve(v)
|
||||
})
|
||||
})`);
|
||||
expect(v).to.equal('hello');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue