update spec
This commit is contained in:
parent
dead1ae1ba
commit
eb827eb020
2 changed files with 31 additions and 15 deletions
|
@ -230,21 +230,8 @@ describe('BrowserWindow module', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should not crash when there is a pending navigation entry', function (done) {
|
it('should not crash when there is a pending navigation entry', function (done) {
|
||||||
const source = `
|
ipcRenderer.once('navigated-with-pending-entry', () => done())
|
||||||
<script>
|
ipcRenderer.send('navigate-with-pending-entry', w.id)
|
||||||
setInterval(function () {
|
|
||||||
window.location = 'http://host'
|
|
||||||
}, 1000)
|
|
||||||
</script>
|
|
||||||
`
|
|
||||||
w.webContents.on('did-fail-load', function (event, code, desc, url, isMainFrame) {
|
|
||||||
assert.equal(url, 'http://host/')
|
|
||||||
w.webContents.loadURL('about:blank')
|
|
||||||
})
|
|
||||||
w.webContents.on('did-navigate', function (event, url) {
|
|
||||||
if (url === 'about:blank') done()
|
|
||||||
})
|
|
||||||
w.loadURL(`data:text/html,${source}`)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('POST navigations', function () {
|
describe('POST navigations', function () {
|
||||||
|
|
|
@ -304,6 +304,35 @@ ipcMain.on('handle-unhandled-rejection', (event, message) => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
ipcMain.on('navigate-with-pending-entry', (event, id) => {
|
||||||
|
const w = BrowserWindow.fromId(id)
|
||||||
|
|
||||||
|
const source = `
|
||||||
|
<body>
|
||||||
|
<a href='http://host'>Link</a>
|
||||||
|
</body>
|
||||||
|
<script>
|
||||||
|
setInterval(function () {
|
||||||
|
document.getElementsByTagName('a')[0].click();
|
||||||
|
}, 100)
|
||||||
|
</script>
|
||||||
|
`
|
||||||
|
|
||||||
|
w.webContents.on('did-fail-load', () => {
|
||||||
|
w.loadURL('about:blank')
|
||||||
|
})
|
||||||
|
|
||||||
|
w.webContents.on('did-navigate', (e, url) => {
|
||||||
|
if (url === 'about:blank') {
|
||||||
|
event.sender.send('navigated-with-pending-entry')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
w.webContents.session.clearHostResolverCache(() => {
|
||||||
|
w.loadURL(`data:text/html,${source}`)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
// Suspend listeners until the next event and then restore them
|
// Suspend listeners until the next event and then restore them
|
||||||
const suspendListeners = (emitter, eventName, callback) => {
|
const suspendListeners = (emitter, eventName, callback) => {
|
||||||
const listeners = emitter.listeners(eventName)
|
const listeners = emitter.listeners(eventName)
|
||||||
|
|
Loading…
Reference in a new issue