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

Commit

Permalink
update urlbar suggestion list on componentWillUpdate
Browse files Browse the repository at this point in the history
auditors: @bbondy
  • Loading branch information
bridiver committed Aug 23, 2016
1 parent 2a2beae commit f83a22a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion js/components/urlBarSuggestions.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class UrlBarSuggestions extends ImmutableComponent {
this.updateSuggestions(parseInt(e.target.dataset.index, 10))
}

componentDidUpdate (prevProps) {
componentWillUpdate (prevProps) {
if (this.selectedElement) {
this.selectedElement.scrollIntoView()
}
Expand Down
24 changes: 10 additions & 14 deletions test/components/urlBarSuggestionsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,18 @@ describe('urlbarSuggestions', function () {
yield this.app.client
.tabByUrl(Brave.newTabUrl)
.loadUrl(this.page1Url)
// TODO(bridiver) - creating a new frame here should not be necessary
.loadUrl(this.page2Url)
.windowByUrl(Brave.browserWindowUrl)
.ipcSend(messages.SHORTCUT_NEW_FRAME)
.waitForUrl(Brave.newTabUrl)
.loadUrl(this.page2Url)
.windowByUrl(Brave.browserWindowUrl)
.waitForExist('.tab[data-frame-key="2"].active')
.waitForElementFocus(urlInput)
.waitUntil(function () {
return this.getAppState().then((val) => {
return val.value.sites.length === 2
})
})
.ipcSend(messages.SHORTCUT_NEW_FRAME)
.waitForUrl(Brave.newTabUrl)
.windowByUrl(Brave.browserWindowUrl)
.waitForExist('.tab[data-frame-key="3"].active')
.waitForElementFocus(urlInput)
})

it('deactivates suggestions on escape', function * () {
Expand All @@ -47,7 +43,7 @@ describe('urlbarSuggestions', function () {
.waitUntil(function () {
return this.getValue(urlInput).then((val) => val === 'Page 1')
})
.waitForExist(urlBarSuggestions)
.waitForExist(urlBarSuggestions + ' li.suggestionItem[data-index="2"]')
.keys('\uE00C')
.waitUntil(function () {
return this.isExisting(urlBarSuggestions).then((exists) => exists === false)
Expand All @@ -60,9 +56,9 @@ describe('urlbarSuggestions', function () {
.waitUntil(function () {
return this.getValue(urlInput).then((val) => val === 'Page 1')
})
.waitForExist(urlBarSuggestions + ' li.suggestionItem[data-index="2"]')
.click(urlBarSuggestions + ' li.suggestionItem[data-index="2"]')
.waitForExist('.tab[data-frame-key="1"].active')
.waitForExist(urlBarSuggestions + ' li.suggestionItem[data-index="1"]')
.click(urlBarSuggestions + ' li.suggestionItem[data-index="1"]')
.tabByIndex(1).getUrl().should.eventually.equal(this.page1Url)
})

it('navigates to a suggestion with keyboard', function * () {
Expand All @@ -73,11 +69,11 @@ describe('urlbarSuggestions', function () {
})
.waitForExist(urlBarSuggestions)
.keys('Down arrow')
.waitForExist(urlBarSuggestions + ' li+li.selected')
.waitForExist(urlBarSuggestions + ' li.suggestionItem[data-index="1"].selected')
.keys('Down arrow')
.waitForExist(urlBarSuggestions + ' li+li+li+li.selected')
.waitForExist(urlBarSuggestions + ' li.suggestionItem[data-index="2"].selected')
.keys('Enter')
.waitForExist('.tab[data-frame-key="1"].active')
.tabByIndex(1).getUrl().should.become(this.page2Url)
})

it('selects a location auto complete result but not for titles', function * () {
Expand Down

1 comment on commit f83a22a

@bbondy
Copy link
Member

@bbondy bbondy commented on f83a22a Aug 24, 2016

Choose a reason for hiding this comment

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

ideally this will move to the store layer eventually but this seems ok.

Please sign in to comment.