Add spec for render-view-deleted issue

This commit is contained in:
Kevin Sawicki 2016-11-30 17:29:50 -08:00
parent ec43dd067c
commit c1a02d6556
2 changed files with 47 additions and 0 deletions

View file

@ -517,4 +517,19 @@ describe('ipc module', function () {
ipcRenderer.removeAllListeners('test-event')
assert.equal(ipcRenderer.listenerCount('test-event'), 0)
})
describe('remote objects registry', function () {
it('does not dereference until the render view is deleted (regression)', function (done) {
w = new BrowserWindow({
show: true
})
ipcMain.once('error-message', (event, message) => {
assert(message.startsWith('Cannot call function \'getURL\' on missing remote object'), message)
done()
})
w.loadURL('file://' + path.join(fixtures, 'api', 'render-view-deleted.html'))
})
})
})

View file

@ -0,0 +1,32 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script>
const {ipcRenderer, remote} = require('electron')
const contents = remote.getCurrentWebContents()
// This should not trigger a dereference and a remote getURL call should not fail
contents.emit('render-view-deleted', {}, 'not-a-process-id')
try {
contents.getURL()
} catch (error) {
ipcRenderer.send('error-message', 'Unexpected error on getURL call')
}
// This should trigger a dereference and a remote getURL call should fail
contents.emit('render-view-deleted', {}, contents.getProcessId())
try {
contents.getURL()
ipcRenderer.send('error-message', 'No error thrown')
} catch (error) {
ipcRenderer.send('error-message', error.message)
}
</script>
</head>
<body>
</body>
</html>