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

Commit

Permalink
URLbar should not remain focused when no back history
Browse files Browse the repository at this point in the history
Fix #5563

Auditors: @diracdeltas
  • Loading branch information
bbondy committed Nov 12, 2016
1 parent 019a910 commit 7f1d0a2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
7 changes: 5 additions & 2 deletions js/components/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -1032,8 +1032,11 @@ class Frame extends ImmutableComponent {
appActions.hideMessageBox(message)
}
this.notificationCallbacks = {}
// only give focus focus is this is not the initial default page load
if (this.props.isActive && this.webview.canGoBack() && document.activeElement !== this.webview) {
const isNewTabPage = e.url === getTargetAboutUrl('about:newtab')
if (isNewTabPage) {
windowActions.setUrlBarActive(true)
windowActions.setUrlBarFocused(true)
} else if (this.props.isActive && !isNewTabPage && document.activeElement !== this.webview) {
this.webview.focus()
}
windowActions.setNavigated(e.url, this.props.frameKey, false, this.frame.get('tabId'))
Expand Down
28 changes: 28 additions & 0 deletions test/components/navigationBarTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,34 @@ describe('navigationBar', function () {
}

describe('navigation', function () {
describe('focus', function () {
Brave.beforeAll(this)
before(function * () {
const page1 = Brave.server.url('page1.html')
yield this.app.client.waitForExist(urlInput)
yield this.app.client
.windowByUrl(Brave.browserWindowUrl)
.tabByIndex(0)
.url(page1)
.waitForUrl(page1)
.windowByUrl(Brave.browserWindowUrl)
.ipcSend('shortcut-focus-url')
.waitForElementFocus(urlInput)
.keys(Brave.keys.ENTER)
})

it('webview has focus after initial load', function * () {
yield this.app.client.waitForElementFocus(activeWebview)
})

it('webview has focus after second load', function * () {
yield this.app.client
.ipcSend('shortcut-focus-url')
.waitForElementFocus(urlInput)
.keys(Brave.keys.ENTER)
.waitForElementFocus(activeWebview)
})
})
describe('tabnapping', function () {
Brave.beforeAll(this)

Expand Down

0 comments on commit 7f1d0a2

Please sign in to comment.