From 670b4d4eecd274fa77e9a87955d536114963777c Mon Sep 17 00:00:00 2001 From: yan Date: Fri, 9 Sep 2016 17:45:57 -0700 Subject: [PATCH] If directly-entered URL load fails, show the location of the displayed page Fix #3851 Add regression test for #2723 Auditors: @bridiver Test Plan: open bankofamerica.com in a tab put http://bayden.com/test/redir/goscript.aspx in the urlbar and hit enter verify that the URL bar still says bankofamerica.com --- js/stores/windowStore.js | 3 -- test/components/navigationBarTest.js | 48 ++++++++++++++++++++++++++++ test/fixtures/urlbarSpoof.html | 10 ++++++ 3 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 test/fixtures/urlbarSpoof.html diff --git a/js/stores/windowStore.js b/js/stores/windowStore.js index 5366e2c91c5..a7317d965b3 100644 --- a/js/stores/windowStore.js +++ b/js/stores/windowStore.js @@ -293,9 +293,6 @@ const doAction = (action) => { windowState = windowState.mergeIn(tabStatePath(action.key), { location: action.location }) - // force a navbar update in case this was called from an app - // initiated navigation (bookmarks, etc...) - updateNavBarInput(action.location, frameStatePath(action.key)) } break case WindowConstants.WINDOW_SET_NAVIGATED: diff --git a/test/components/navigationBarTest.js b/test/components/navigationBarTest.js index 248b4d4e7f2..814e2e3aa06 100644 --- a/test/components/navigationBarTest.js +++ b/test/components/navigationBarTest.js @@ -82,6 +82,31 @@ describe('navigationBar', function () { }) }) + describe('document.write spoofing', function () { + Brave.beforeAll(this) + + before(function * () { + var page1 = Brave.server.url('urlbarSpoof.html') + yield setup(this.app.client) + yield this.app.client + .tabByUrl(Brave.newTabUrl) + .url(page1) + .waitForUrl(page1) + .waitForExist('input') + .leftClick('input') + }) + + it('updates the location in the navbar to blank', function * () { + yield this.app.client + .windowByUrl(Brave.browserWindowUrl) + .waitUntil(function () { + return this.getValue(urlInput).then((val) => { + return val === '' + }) + }) + }) + }) + describe('page with a title', function () { Brave.beforeAll(this) @@ -559,6 +584,29 @@ describe('navigationBar', function () { }) describe('submit', function () { + describe('page that does not load', function () { + Brave.beforeAll(this) + + before(function * () { + var page1 = 'https://bayden.com/test/redir/goscript.aspx' + yield setup(this.app.client) + yield this.app.client.waitForExist(urlInput) + yield this.app.client.keys(page1) + // hit enter + yield this.app.client.keys('\uE007') + }) + + it('clears urlbar if page does not load', function * () { + yield this.app.client + .waitUntil(function () { + return this.getValue(urlInput).then((val) => { + console.log('value', val) + return val === '' + }) + }) + }) + }) + describe('with url input value', function () { Brave.beforeAll(this) diff --git a/test/fixtures/urlbarSpoof.html b/test/fixtures/urlbarSpoof.html new file mode 100644 index 00000000000..dfaf6f6d267 --- /dev/null +++ b/test/fixtures/urlbarSpoof.html @@ -0,0 +1,10 @@ + + + +