From 47df447e4f74abc60d5e210bd3f552cb03ea1adc Mon Sep 17 00:00:00 2001 From: Dave Townsend Date: Fri, 16 Sep 2016 17:06:16 -0700 Subject: [PATCH] :white_check_mark: Test that replacement history entries don't break forward navigation. This is a test for #7175 --- spec/fixtures/pages/history-replace.html | 10 +++++ spec/webview-spec.js | 47 ++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 spec/fixtures/pages/history-replace.html diff --git a/spec/fixtures/pages/history-replace.html b/spec/fixtures/pages/history-replace.html new file mode 100644 index 000000000000..a10feefd2b6c --- /dev/null +++ b/spec/fixtures/pages/history-replace.html @@ -0,0 +1,10 @@ + + + + + diff --git a/spec/webview-spec.js b/spec/webview-spec.js index 01374baf806a..340c15146950 100644 --- a/spec/webview-spec.js +++ b/spec/webview-spec.js @@ -623,6 +623,53 @@ describe(' tag', function () { }) }) + describe('.goForward()', function () { + it('should work after a replaced history entry', function (done) { + var loadCount = 1 + var listener = function (e) { + if (loadCount === 1) { + assert.equal(e.channel, 'history') + assert.equal(e.args[0], 1) + assert(!webview.canGoBack()) + assert(!webview.canGoForward()) + } else if (loadCount === 2) { + assert.equal(e.channel, 'history') + assert.equal(e.args[0], 2) + assert(!webview.canGoBack()) + assert(webview.canGoForward()) + webview.removeEventListener('ipc-message', listener) + } + } + + var loadListener = function (e) { + if (loadCount === 1) { + webview.src = 'file://' + fixtures + '/pages/base-page.html' + } else if (loadCount === 2) { + assert(webview.canGoBack()) + assert(!webview.canGoForward()) + + webview.goBack() + } else if (loadCount === 3) { + webview.goForward() + } else if (loadCount === 4) { + assert(webview.canGoBack()) + assert(!webview.canGoForward()) + + webview.removeEventListener('did-finish-load', loadListener) + done() + } + + loadCount++ + } + + webview.addEventListener('ipc-message', listener) + webview.addEventListener('did-finish-load', loadListener) + webview.setAttribute('nodeintegration', 'on') + webview.src = 'file://' + fixtures + '/pages/history-replace.html' + document.body.appendChild(webview) + }) + }) + describe('.clearHistory()', function () { it('should clear the navigation history', function (done) { var listener = function (e) {