diff --git a/js/components/urlBar.js b/js/components/urlBar.js index 652f9995034..bde7882655f 100644 --- a/js/components/urlBar.js +++ b/js/components/urlBar.js @@ -377,6 +377,9 @@ class UrlBar extends ImmutableComponent { this.props.titleMode !== prevProps.titleMode || !this.isActive && !this.isFocused) { this.urlInput.value = this.locationValue + } else if (this.props.urlbar.get('location') !== prevProps.urlbar.get('location') && + this.urlInput.value !== this.props.urlbar.get('location')) { + this.urlInput.value = this.locationValue } } if (this.isSelected() && !prevProps.urlbar.get('selected')) { diff --git a/js/stores/windowStore.js b/js/stores/windowStore.js index dcc4662908a..c9e0ddeddfc 100644 --- a/js/stores/windowStore.js +++ b/js/stores/windowStore.js @@ -279,6 +279,7 @@ const doAction = (action) => { windowState = windowState.mergeIn(tabStatePath(action.key), { audioPlaybackActive: false }) + updateNavBarInput(frame.get('location'), frameStatePath(action.key)) } else { // If the user is changing back to the original src and they already navigated away then we need to // explicitly set a new location via webview.loadURL. diff --git a/test/components/urlBarTest.js b/test/components/urlBarTest.js index 8efc257e5ca..dd8b313bb03 100644 --- a/test/components/urlBarTest.js +++ b/test/components/urlBarTest.js @@ -1,7 +1,7 @@ /* global describe, it, before, beforeEach */ const Brave = require('../lib/brave') -const {urlInput, urlBarSuggestions, urlbarIcon, activeWebview} = require('../lib/selectors') +const {urlInput, urlBarSuggestions, urlbarIcon, activeWebview, reloadButton} = require('../lib/selectors') const searchProviders = require('../../js/data/searchProviders') const config = require('../../js/constants/config') const messages = require('../../js/constants/messages') @@ -383,4 +383,69 @@ describe('urlBar tests', function () { it('Retains user input on tab switches', tabLoadingTest) }) + + describe('loading same URL as current page with changed input', function () { + Brave.beforeAll(this) + + before(function * () { + this.page1Url = Brave.server.url('page1.html') + yield setup(this.app.client) + yield this.app.client + .waitForExist(urlInput) + .waitForElementFocus(urlInput) + .tabByIndex(0) + .loadUrl(this.page1Url) + .windowByUrl(Brave.browserWindowUrl) + .setValue(urlInput, '') + .waitUntil(function () { + return this.getValue(urlInput).then((val) => val === '') + }) + .windowByUrl(Brave.browserWindowUrl) + .click(reloadButton) + }) + + it('reverts the URL', function * () { + const page1Url = this.page1Url + yield this.app.client + .waitUntil(function () { + return this.getValue(urlInput).then((val) => { + return val === page1Url + }) + }) + }) + }) + + describe('loading different URL as current page with changed input', function () { + Brave.beforeAll(this) + + before(function * () { + this.page1Url = Brave.server.url('page1.html') + this.page2Url = Brave.server.url('page2.html') + yield setup(this.app.client) + yield this.app.client + .waitForExist(urlInput) + .waitForElementFocus(urlInput) + .tabByIndex(0) + .loadUrl(this.page1Url) + .windowByUrl(Brave.browserWindowUrl) + .setValue(urlInput, '') + .waitUntil(function () { + return this.getValue(urlInput).then((val) => val === '') + }) + .windowByUrl(Brave.browserWindowUrl) + .tabByIndex(0) + .loadUrl(this.page2Url) + .windowByUrl(Brave.browserWindowUrl) + }) + + it('reverts the URL', function * () { + const page2Url = this.page2Url + yield this.app.client + .waitUntil(function () { + return this.getValue(urlInput).then((val) => { + return val === page2Url + }) + }) + }) + }) }) diff --git a/test/lib/selectors.js b/test/lib/selectors.js index 0de4928bdbc..1e6042ca1eb 100644 --- a/test/lib/selectors.js +++ b/test/lib/selectors.js @@ -46,6 +46,7 @@ module.exports = { noScriptNavButton: '#navigator .noScript', backButton: '.backforward .backButton', forwardButton: '.backforward .forwardButton', + reloadButton: '.reloadButton', clearBrowsingDataPanel: '.clearBrowsingDataPanel', clearBrowsingDataButton: '.clearBrowsingDataButton', securityTab: '[data-l10n-id="security"]',