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

Commit

Permalink
fix urlbar escape tests and behavior
Browse files Browse the repository at this point in the history
fixes #2914
related #2920
cc @bbondy @willy-b
  • Loading branch information
bridiver committed Aug 9, 2016
1 parent d9a579e commit f551bbd
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 14 deletions.
10 changes: 7 additions & 3 deletions js/components/urlBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,13 @@ class UrlBar extends ImmutableComponent {
}

onActiveFrameStop () {
this.restore()
windowActions.setUrlBarSelected(true)
windowActions.setUrlBarActive(false)
if (this.isFocused()) {
windowActions.setUrlBarActive(false)
if (!this.shouldRenderUrlBarSuggestions) {
this.restore()
windowActions.setUrlBarSelected(true)
}
}
}

componentWillMount () {
Expand Down
54 changes: 43 additions & 11 deletions test/components/navigationBarTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,14 +445,52 @@ describe('navigationBar', function () {
})
})

describe('escape', function * () {
describe('type escape once', function () {
before(function * () {
yield this.app.client.ipcSend('shortcut-active-frame-stop')
this.page = Brave.server.url('page1.html')
return yield this.app.client
.tabByIndex(0)
.loadUrl(this.page)
.windowByUrl(Brave.browserWindowUrl)
.ipcSend('shortcut-focus-url')
.waitForElementFocus(urlInput)
.setValue(urlInput, 'blah')
// hit escape
.keys('\uE00C')
.waitForElementFocus(urlInput)
})

it('does not select the urlbar text', function * () {
yield selectsText(this.app.client, '')
})

it('does not revert the urlbar text', function * () {
yield this.app.client.getValue(urlInput).should.eventually.be.equal('blah')
})
})

describe('type escape twice', function () {
before(function * () {
this.page = Brave.server.url('page1.html')
return yield this.app.client
.tabByIndex(0)
.loadUrl(this.page)
.windowByUrl(Brave.browserWindowUrl)
.ipcSend('shortcut-focus-url')
.waitForElementFocus(urlInput)
.setValue(urlInput, 'blah')
// hit escape
.keys('\uE00C')
.waitForElementFocus(urlInput)
.keys('\uE00C')
})

it('reverts typing on escape', function * () {
yield this.app.client.getValue(urlInput).should.eventually.be.equal(config.defaultUrl)
yield selectsText(this.app.client)
it('selects the urlbar text', function * () {
yield selectsText(this.app.client, this.page)
})

it('sets the urlbar text to the webview src', function * () {
yield this.app.client.getValue(urlInput).should.eventually.be.equal(this.page)
})
})

Expand Down Expand Up @@ -643,12 +681,6 @@ describe('navigationBar', function () {
})
})

describe('escape', function () {
it('sets the urlbar text to the webview src')

it('selects the urlbar text')
})

describe('shortcut-focus-url', function () {
Brave.beforeAll(this)

Expand Down
14 changes: 14 additions & 0 deletions test/components/urlBarSuggestionsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ describe('urlbarSuggestions', function () {
.waitForElementFocus(urlInput)
})

it('deactivates suggestions on escape', function * () {
yield this.app.client.ipcSend('shortcut-focus-url')
.waitForElementFocus(urlInput)
.setValue(urlInput, 'Page 1')
.waitUntil(function () {
return this.getValue(urlInput).then((val) => val === 'Page 1')
})
.waitForExist(urlBarSuggestions)
.keys('\uE00C')
.waitUntil(function () {
return this.isExisting(urlBarSuggestions).then((exists) => exists === false)
})
})

it('navigates to a suggestion when clicked', function * () {
yield this.app.client.ipcSend('shortcut-focus-url')
.waitForElementFocus(urlInput)
Expand Down

0 comments on commit f551bbd

Please sign in to comment.