commit 8fd15ae2b8de6a53474a7122676ca8da7a693f55
parent 9ba0186365f361d33bbb841c12c27a8b0eb75fb6
Author: Moritz Beier <mbeier@mozilla.com>
Date: Wed, 17 Dec 2025 16:39:07 +0000
Bug 2001378 - Stop manually restoring the search config in browser_contextualsearch.js. r=Standard8,urlbar-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D273443
Diffstat:
3 files changed, 17 insertions(+), 32 deletions(-)
diff --git a/browser/components/urlbar/tests/browser/browser_contextualsearch.js b/browser/components/urlbar/tests/browser/browser_contextualsearch.js
@@ -42,20 +42,12 @@ const CONFIG = [
];
let loadUri = async uri => {
- let loaded = BrowserTestUtils.browserLoaded(
- gBrowser.selectedBrowser,
- false,
- uri
- );
- BrowserTestUtils.startLoadingURIString(gBrowser.selectedBrowser, uri);
- await loaded;
-};
-
-let updateConfig = async config => {
- await waitForIdle();
- await SearchTestUtils.setRemoteSettingsConfig(config);
- await Services.search.wrappedJSObject.reset();
- await Services.search.init();
+ gBrowser.selectedBrowser.stop();
+ return BrowserTestUtils.loadURIString({
+ browser: gBrowser.selectedBrowser,
+ uriString: uri,
+ wantLoad: uri,
+ });
};
add_setup(async function setup() {
@@ -67,8 +59,6 @@ add_setup(async function setup() {
});
registerCleanupFunction(async () => {
- await updateConfig(null);
- Services.search.restoreDefaultEngines();
Services.prefs.clearUserPref(
"browser.urlbar.quickactions.timesShownOnboardingLabel"
);
@@ -95,7 +85,7 @@ add_task(async function test_engine_match() {
PlacesTestUtils.waitForNotification("history-cleared");
await PlacesUtils.history.clear();
await promiseClearHistory;
- await updateConfig(CONFIG);
+ await SearchTestUtils.updateRemoteSettingsConfig(CONFIG);
await loadUri("https://example.org/");
await UrlbarTestUtils.promiseAutocompleteResultPopup({
@@ -135,12 +125,10 @@ add_task(async function test_engine_match() {
EventUtils.synthesizeKey("KEY_Enter");
await onLoad;
- await updateConfig(null);
});
add_task(async function test_actions() {
let testActionCalled = 0;
- await updateConfig(CONFIG);
await loadUri("https://example.net/");
ActionsProviderQuickActions.addAction("testaction", {
@@ -161,7 +149,6 @@ add_task(async function test_actions() {
Assert.equal(testActionCalled, 1, "Test action was called");
- await updateConfig(null);
ActionsProviderQuickActions.removeAction("testaction");
});
@@ -240,7 +227,7 @@ add_task(async function test_tab_to_search_engine() {
},
},
]);
- await updateConfig(newConfig);
+ await SearchTestUtils.updateRemoteSettingsConfig(newConfig);
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
@@ -267,7 +254,7 @@ add_task(async function test_tab_to_search_engine() {
});
await onLoad;
- await updateConfig(null);
+ await SearchTestUtils.updateRemoteSettingsConfig(CONFIG);
});
add_task(async function test_onboarding_default_engine() {
@@ -275,8 +262,6 @@ add_task(async function test_onboarding_default_engine() {
set: [["browser.urlbar.quickactions.timesToShowOnboardingLabel", 3]],
});
- await updateConfig(CONFIG);
-
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
value: "default",
@@ -292,8 +277,6 @@ add_task(async function test_onboarding_default_engine() {
await UrlbarTestUtils.promisePopupClose(window, () => {
EventUtils.synthesizeKey("KEY_Escape");
});
-
- await updateConfig(null);
});
async function hasActions(index) {
@@ -304,9 +287,3 @@ async function hasActions(index) {
.result;
return result.providerName == "UrlbarProviderGlobalActions";
}
-
-async function waitForIdle() {
- for (let i = 0; i < 10; i++) {
- await new Promise(resolve => Services.tm.idleDispatchToMainThread(resolve));
- }
-}
diff --git a/toolkit/components/search/SearchSettings.sys.mjs b/toolkit/components/search/SearchSettings.sys.mjs
@@ -241,6 +241,13 @@ export class SearchSettings {
}
/**
+ * Test-only function to reset the settings.
+ */
+ _testResetSettings() {
+ this.#resetSettings(false);
+ }
+
+ /**
* Queues writing the settings until after SETTINGS_INVALIDATION_DELAY. If there
* is a currently queued task then it will be restarted.
*/
diff --git a/toolkit/components/search/tests/SearchTestUtils.sys.mjs b/toolkit/components/search/tests/SearchTestUtils.sys.mjs
@@ -68,6 +68,7 @@ class _SearchTestUtils {
if (this.#stubs.size) {
this.#stubs = new Map();
+ Services.search.wrappedJSObject._settings._testResetSettings();
let settingsWritten = SearchTestUtils.promiseSearchNotification(
"write-settings-to-disk-complete"
);