diff --git a/lib/browser/api/navigation-controller.js b/lib/browser/api/navigation-controller.js index a911a6c6533f0..7eb21ddb3ea9c 100644 --- a/lib/browser/api/navigation-controller.js +++ b/lib/browser/api/navigation-controller.js @@ -21,6 +21,11 @@ var NavigationController = (function () { this.webContents = webContents this.clearHistory() + // webContents may have already navigated to a page. + if (this.webContents._getURL()) { + this.currentIndex++ + this.history.push(this.webContents._getURL()) + } this.webContents.on('navigation-entry-commited', (event, url, inPage, replaceEntry) => { if (this.inPageIndex > -1 && !inPage) { // Navigated to a new page, clear in-page mark. @@ -101,12 +106,6 @@ var NavigationController = (function () { this.currentIndex = -1 this.pendingIndex = -1 this.inPageIndex = -1 - - // webContents may have already navigated to a page. - if (this.webContents._getURL()) { - this.currentIndex++ - this.history.push(this.webContents._getURL()) - } } NavigationController.prototype.goBack = function () {