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

Commit

Permalink
Clear active search engine info when removed
Browse files Browse the repository at this point in the history
Auditors: @darkdh

Fix #6683
  • Loading branch information
bbondy committed Jan 16, 2017
1 parent 415e343 commit 2b0c9df
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/renderer/reducers/urlBarSuggestionsReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,17 @@ const updateSearchEngineInfoFromInput = (state, frameProps) => {
if (!isLocationUrl &&
!(frameSearchDetail && input.startsWith(frameSearchDetail.get('shortcut') + ' '))) {
let entries = searchProviders.providers
entries.forEach((entry) => {
const searchDetailPath = frameStatePath(state, frameProps.get('key')).concat(['navbar', 'urlbar', 'searchDetail'])
for (let i = 0; i < entries.length; i++) {
const entry = entries[i]
if (input.startsWith(entry.shortcut + ' ')) {
state = state.setIn(
frameStatePath(state, frameProps.get('key')).concat(['navbar', 'urlbar', 'searchDetail']),
searchDetailPath,
Immutable.fromJS(Object.assign({}, entry, { activateSearchEngine: true })))
return state
}
})
}
state = state.setIn(searchDetailPath, Immutable.fromJS({}))
}
}
return state
Expand Down
1 change: 1 addition & 0 deletions app/sessionStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ module.exports.cleanPerWindowData = (perWindowData, isShutdown) => {
frame.navbar.urlbar.suggestions.selectedIndex = null
frame.navbar.urlbar.suggestions.suggestionList = null
}
delete frame.navbar.urlbar.searchDetail
}
}
const clearHistory = isShutdown && getSetting(settings.SHUTDOWN_CLEAR_HISTORY) === true
Expand Down
15 changes: 15 additions & 0 deletions test/components/urlBarTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,21 @@ describe('urlBar tests', function () {
})
})
})
it('Clears last search engine when removed', function * () {
const entry = entries[0]
yield this.app.client
.keys(`${entry.shortcut} hi`)
.waitForElementCount(urlbarIcon, 1)
.waitUntil(function () {
return this
.getCssProperty(urlbarIcon, 'background-image')
.then((backgroundImage) => backgroundImage.value === `url("${entry.image}")`)
})
.keys(Brave.keys.BACKSPACE)
.keys(Brave.keys.BACKSPACE)
.keys(Brave.keys.BACKSPACE)
.waitForElementCount(urlbarIcon + '.fa-search', 1)
})
})

const tabLoadingTest = function * () {
Expand Down

1 comment on commit 2b0c9df

@darkdh
Copy link
Member

@darkdh darkdh commented on 2b0c9df Jan 17, 2017

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.