From eb827eb020fea24a5deec8b5f2ffe1cbdc81aa14 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Wed, 1 Mar 2017 00:21:37 +0530 Subject: [PATCH] update spec --- spec/api-browser-window-spec.js | 17 ++--------------- spec/static/main.js | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/spec/api-browser-window-spec.js b/spec/api-browser-window-spec.js index 9631de810c3..c9fe34aef8f 100644 --- a/spec/api-browser-window-spec.js +++ b/spec/api-browser-window-spec.js @@ -230,21 +230,8 @@ describe('BrowserWindow module', function () { }) it('should not crash when there is a pending navigation entry', function (done) { - const source = ` - - ` - 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}`) + ipcRenderer.once('navigated-with-pending-entry', () => done()) + ipcRenderer.send('navigate-with-pending-entry', w.id) }) describe('POST navigations', function () { diff --git a/spec/static/main.js b/spec/static/main.js index c36e86aeaec..1e81ddc8cfa 100644 --- a/spec/static/main.js +++ b/spec/static/main.js @@ -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 = ` + + Link + + + ` + + 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 const suspendListeners = (emitter, eventName, callback) => { const listeners = emitter.listeners(eventName)