зеркало из https://github.com/electron/electron.git
Add spec for render-view-deleted issue
This commit is contained in:
Родитель
ec43dd067c
Коммит
c1a02d6556
|
@ -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'))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -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>
|
Загрузка…
Ссылка в новой задаче