diff --git a/lib/browser/api/navigation-controller.js b/lib/browser/api/navigation-controller.js index 0bccf0c6dcc5..7eb21ddb3ea9 100644 --- a/lib/browser/api/navigation-controller.js +++ b/lib/browser/api/navigation-controller.js @@ -27,7 +27,6 @@ var NavigationController = (function () { this.history.push(this.webContents._getURL()) } this.webContents.on('navigation-entry-commited', (event, url, inPage, replaceEntry) => { - var currentEntry if (this.inPageIndex > -1 && !inPage) { // Navigated to a new page, clear in-page mark. this.inPageIndex = -1 @@ -46,12 +45,8 @@ var NavigationController = (function () { } else { // Normal navigation. Clear history. this.history = this.history.slice(0, this.currentIndex + 1) - currentEntry = this.history[this.currentIndex] - - if (currentEntry !== url) { - this.currentIndex++ - this.history.push(url) - } + this.currentIndex++ + this.history.push(url) } }) } diff --git a/spec/chromium-spec.js b/spec/chromium-spec.js index fe132166d602..f33fb284a47b 100644 --- a/spec/chromium-spec.js +++ b/spec/chromium-spec.js @@ -1100,11 +1100,32 @@ describe('chromium feature', function () { }) }) - describe('window.history.go(offset)', function () { - it('throws an exception when the argumnet cannot be converted to a string', function () { - assert.throws(function () { - window.history.go({toString: null}) - }, /Cannot convert object to primitive value/) + describe('window.history', function () { + describe('window.history.go(offset)', function () { + it('throws an exception when the argumnet cannot be converted to a string', function () { + assert.throws(function () { + window.history.go({toString: null}) + }, /Cannot convert object to primitive value/) + }) + }) + + describe('window.history.pushState', function () { + it('should push state after calling history.pushState() from the same url', (done) => { + w = new BrowserWindow({ + show: false + }) + w.webContents.once('did-finish-load', () => { + // History should have current page by now. + assert.equal(w.webContents.length(), 1) + + w.webContents.executeJavaScript('window.history.pushState({}, "")', () => { + // Initial page + pushed state + assert.equal(w.webContents.length(), 2) + done() + }) + }) + w.loadURL('about:blank') + }) }) }) })