Merge pull request #8049 from electron/prevent-remove-all-ipc

Throw an error when users attempt to remove all listeners from the IPC modules
This commit is contained in:
Cheng Zhao 2016-11-27 14:29:49 +08:00 committed by GitHub
commit bbaab755e3
2 changed files with 16 additions and 0 deletions

View file

@ -29,4 +29,12 @@ module.exports = function (ipcRenderer, binding) {
ipcRenderer.send('ELECTRON_BROWSER_SEND_TO', true, webContentsId, channel, ...args)
}
const removeAllListeners = ipcRenderer.removeAllListeners
ipcRenderer.removeAllListeners = function (...args) {
if (args.length === 0) {
throw new Error('Removing all listeners from ipcRenderer will make Electron internals stop working. Please specify a event name')
}
removeAllListeners.apply(this, args)
}
}