Bug 1336395 - Disallow same alias in search engines r=jaws

MozReview-Commit-ID: 1GidMz0dimv

--HG--
extra : rebase_source : ac9bcf278012c498b6eeb5098f7d3887623ec0bf
This commit is contained in:
tfe 2017-05-24 12:51:58 +02:00
Родитель a9760d2cbe
Коммит 9ab5ad0312
4 изменённых файлов: 33 добавлений и 2 удалений

Просмотреть файл

@ -266,8 +266,10 @@ var gSearchPane = {
// Check for duplicates in changes we haven't committed yet
let engines = gEngineView._engineStore.engines;
let lc_keyword = keyword.toLocaleLowerCase();
for (let engine of engines) {
if (engine.alias == keyword &&
if (engine.alias &&
engine.alias.toLocaleLowerCase() == lc_keyword &&
engine.name != aEngine.name) {
eduplicate = true;
dupName = engine.name;

Просмотреть файл

@ -1045,8 +1045,10 @@ var gMainPane = {
// Check for duplicates in changes we haven't committed yet
let engines = gEngineView._engineStore.engines;
let lc_keyword = keyword.toLocaleLowerCase();
for (let engine of engines) {
if (engine.alias == keyword &&
if (engine.alias &&
engine.alias.toLocaleLowerCase() == lc_keyword &&
engine.name != aEngine.name) {
eduplicate = true;
dupName = engine.name;

Просмотреть файл

@ -18,6 +18,7 @@ skip-if = !updater
[browser_bug1018066_resetScrollPosition.js]
[browser_bug1020245_openPreferences_to_paneContent.js]
[browser_bug1184989_prevent_scrolling_when_preferences_flipped.js]
[browser_engines.js]
support-files =
browser_bug1184989_prevent_scrolling_when_preferences_flipped.xul
[browser_change_app_handler.js]

Просмотреть файл

@ -0,0 +1,26 @@
// Test Engine list
add_task(async function() {
let prefs = await openPreferencesViaOpenPreferencesAPI("general-search", {leaveOpen: true});
is(prefs.selectedPane, "paneGeneral", "General pane is selected by default");
let doc = gBrowser.contentDocument;
let tree = doc.querySelector("#engineList");
ok(!tree.hidden, "The search engine list should be visible when Search is requested");
// Check for default search engines to be displayed in the engineList
let defaultEngines = Services.search.getDefaultEngines();
for (let i = 0; i < defaultEngines.length; i++) {
let engine = defaultEngines[i];
let cellName = tree.view.getCellText(i, tree.columns.getNamedColumn("engineName"));
is(cellName, engine.name, "Default search engine " + engine.name + " displayed correctly");
}
// Avoid duplicated keywords
tree.view.setCellText(0, tree.columns.getNamedColumn("engineKeyword"), "keyword");
tree.view.setCellText(1, tree.columns.getNamedColumn("engineKeyword"), "keyword");
let cellKeyword = tree.view.getCellText(1, tree.columns.getNamedColumn("engineKeyword"));
isnot(cellKeyword, "keyword", "Do not allow duplicated keywords");
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
});