From 74acd17771afdfd3f69d8004d5c5c34deb55a945 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 24 Jan 2020 03:51:41 +0900 Subject: [PATCH] test: make window.history.pushState test more robust (#21875) --- spec-main/chromium-spec.ts | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/spec-main/chromium-spec.ts b/spec-main/chromium-spec.ts index 7c6a115a79b4..d5182cfffc40 100644 --- a/spec-main/chromium-spec.ts +++ b/spec-main/chromium-spec.ts @@ -1089,19 +1089,17 @@ describe('chromium features', () => { describe('window.history', () => { describe('window.history.pushState', () => { - it('should push state after calling history.pushState() from the same url', (done) => { + it('should push state after calling history.pushState() from the same url', async () => { const w = new BrowserWindow({ show: false }) - w.webContents.once('did-finish-load', async () => { - // History should have current page by now. - expect((w.webContents as any).length()).to.equal(1) + await w.loadFile(path.join(fixturesPath, 'pages', 'blank.html')) + // History should have current page by now. + expect((w.webContents as any).length()).to.equal(1) - w.webContents.executeJavaScript('window.history.pushState({}, "")').then(() => { - // Initial page + pushed state - expect((w.webContents as any).length()).to.equal(2) - done() - }) - }) - w.loadURL('about:blank') + const waitCommit = emittedOnce(w.webContents, 'navigation-entry-commited') + w.webContents.executeJavaScript('window.history.pushState({}, "")') + await waitCommit + // Initial page + pushed state. + expect((w.webContents as any).length()).to.equal(2) }) }) })