Bug 1754454 - update urlbar placeholder when search engine is removed on restart and idle. r=Standard8

Differential Revision: https://phabricator.services.mozilla.com/D139553
This commit is contained in:
mcheang 2022-02-24 10:53:53 +00:00
Родитель 35b7a1cfc4
Коммит 9b6063d943
2 изменённых файлов: 52 добавлений и 0 удалений

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

@ -4338,6 +4338,12 @@ const BrowserSearch = {
},
button
);
// Update engine name in the placeholder to the new default engine name.
this._updateURLBarPlaceholderFromDefaultEngine(
PrivateBrowsingUtils.isWindowPrivate(window),
false
).catch(Cu.reportError);
},
};

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

@ -272,6 +272,52 @@ add_task(async function test_search_mode_history() {
);
});
add_task(async function test_change_default_engine_updates_placeholder() {
tabs.push(await BrowserTestUtils.openNewForegroundTab(gBrowser));
info(`Set engine to ${extraEngine.name}`);
await Services.search.setDefault(extraEngine);
await TestUtils.waitForCondition(
() => gURLBar.placeholder == noEngineString,
"The placeholder should match the default placeholder for non-built-in engines."
);
Assert.equal(gURLBar.placeholder, noEngineString);
info(`Set engine to ${originalEngine.name}`);
await Services.search.setDefault(originalEngine);
await TestUtils.waitForCondition(
() => gURLBar.placeholder == expectedString,
"The placeholder should include the engine name for built-in engines."
);
// Simulate the placeholder not having changed due to the delayed update
// on startup.
BrowserSearch._setURLBarPlaceholder("");
await TestUtils.waitForCondition(
() => gURLBar.placeholder == noEngineString,
"The placeholder should have been reset."
);
info("Show search engine removal info bar");
BrowserSearch.removalOfSearchEngineNotificationBox(
extraEngine.name,
originalEngine.name
);
const notificationBox = gNotificationBox.getNotificationWithValue(
"search-engine-removal"
);
Assert.ok(notificationBox, "Search engine removal should be shown.");
await TestUtils.waitForCondition(
() => gURLBar.placeholder == expectedString,
"The placeholder should include the engine name for built-in engines."
);
Assert.equal(gURLBar.placeholder, expectedString);
notificationBox.close();
});
/**
* Opens the view, clicks a one-off button to enter search mode, and asserts
* that the placeholder is corrrect.