feat: make ipc-message and ipc-message-sync events public (#16468)

This commit is contained in:
Milan Burda 2019-01-22 17:47:58 +01:00 committed by Michelle Tilley
parent dbc5f67dca
commit 6cba2c50a2
7 changed files with 82 additions and 26 deletions

View file

@ -995,6 +995,34 @@ describe('webContents module', () => {
})
})
describe('ipc-message event', () => {
it('emits when the renderer process sends an asynchronous message', async () => {
const webContents = remote.getCurrentWebContents()
const promise = emittedOnce(webContents, 'ipc-message')
ipcRenderer.send('message', 'Hello World!')
const [, channel, message] = await promise
expect(channel).to.equal('message')
expect(message).to.equal('Hello World!')
})
})
describe('ipc-message-sync event', () => {
it('emits when the renderer process sends a synchronous message', async () => {
const webContents = remote.getCurrentWebContents()
const promise = emittedOnce(webContents, 'ipc-message-sync')
ipcRenderer.send('handle-next-ipc-message-sync', 'foobar')
const result = ipcRenderer.sendSync('message', 'Hello World!')
const [, channel, message] = await promise
expect(channel).to.equal('message')
expect(message).to.equal('Hello World!')
expect(result).to.equal('foobar')
})
})
describe('referrer', () => {
it('propagates referrer information to new target=_blank windows', (done) => {
const server = http.createServer((req, res) => {