Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Display changed URL for same location
Browse files Browse the repository at this point in the history
Auditors: @diracdeltas

Fix #5629
  • Loading branch information
bbondy committed Nov 20, 2016
1 parent d791401 commit e1201a6
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 1 deletion.
3 changes: 3 additions & 0 deletions js/components/urlBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand Down
1 change: 1 addition & 0 deletions js/stores/windowStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
67 changes: 66 additions & 1 deletion test/components/urlBarTest.js
Original file line number Diff line number Diff line change
@@ -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')
Expand Down Expand Up @@ -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
})
})
})
})
})
1 change: 1 addition & 0 deletions test/lib/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"]',
Expand Down

1 comment on commit e1201a6

@diracdeltas
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++

Please sign in to comment.