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

Commit 2b0c9df

Browse files
committed
Clear active search engine info when removed
Auditors: @darkdh Fix #6683
1 parent 415e343 commit 2b0c9df

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

app/renderer/reducers/urlBarSuggestionsReducer.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,17 @@ const updateSearchEngineInfoFromInput = (state, frameProps) => {
2929
if (!isLocationUrl &&
3030
!(frameSearchDetail && input.startsWith(frameSearchDetail.get('shortcut') + ' '))) {
3131
let entries = searchProviders.providers
32-
entries.forEach((entry) => {
32+
const searchDetailPath = frameStatePath(state, frameProps.get('key')).concat(['navbar', 'urlbar', 'searchDetail'])
33+
for (let i = 0; i < entries.length; i++) {
34+
const entry = entries[i]
3335
if (input.startsWith(entry.shortcut + ' ')) {
3436
state = state.setIn(
35-
frameStatePath(state, frameProps.get('key')).concat(['navbar', 'urlbar', 'searchDetail']),
37+
searchDetailPath,
3638
Immutable.fromJS(Object.assign({}, entry, { activateSearchEngine: true })))
39+
return state
3740
}
38-
})
41+
}
42+
state = state.setIn(searchDetailPath, Immutable.fromJS({}))
3943
}
4044
}
4145
return state

app/sessionStore.js

+1
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ module.exports.cleanPerWindowData = (perWindowData, isShutdown) => {
203203
frame.navbar.urlbar.suggestions.selectedIndex = null
204204
frame.navbar.urlbar.suggestions.suggestionList = null
205205
}
206+
delete frame.navbar.urlbar.searchDetail
206207
}
207208
}
208209
const clearHistory = isShutdown && getSetting(settings.SHUTDOWN_CLEAR_HISTORY) === true

test/components/urlBarTest.js

+15
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,21 @@ describe('urlBar tests', function () {
356356
})
357357
})
358358
})
359+
it('Clears last search engine when removed', function * () {
360+
const entry = entries[0]
361+
yield this.app.client
362+
.keys(`${entry.shortcut} hi`)
363+
.waitForElementCount(urlbarIcon, 1)
364+
.waitUntil(function () {
365+
return this
366+
.getCssProperty(urlbarIcon, 'background-image')
367+
.then((backgroundImage) => backgroundImage.value === `url("${entry.image}")`)
368+
})
369+
.keys(Brave.keys.BACKSPACE)
370+
.keys(Brave.keys.BACKSPACE)
371+
.keys(Brave.keys.BACKSPACE)
372+
.waitForElementCount(urlbarIcon + '.fa-search', 1)
373+
})
359374
})
360375

361376
const tabLoadingTest = function * () {

0 commit comments

Comments
 (0)