Throw an error when users attempt to remove all listeners from the IPC modules

This commit is contained in:
Samuel Attard 2016-11-22 18:30:58 +11:00
parent 71f94c7a3a
commit db729b5b52
No known key found for this signature in database
GPG key ID: 273DC1869D8F13EF
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)
}
}