Closed Bug 1791974 Opened 2 years ago Closed 1 year ago

Extend SearchTestUtils utility functions to provide options for automatically setting an installed engine as default

Categories

(Firefox :: Search, task, P3)

task

Tracking

()

RESOLVED FIXED
109 Branch
Tracking Status
firefox109 --- fixed

People

(Reporter: standard8, Assigned: standard8)

Details

Attachments

(3 files)

In working on a different bug that was changing the setDefault and setDefaultPrivate interfaces, I realised that we have a lot of boilerplate in tests along the lines of:

let originalEngine = await Services.search.getDefault
await SearchTestUtils.installSearchExtension(...);
const defaultEngine = Services.search.getEngineByName("Example");
await Services.search.setDefault(defaultEngine);
registerCleanupFunction(async => {
  await Services.search.setDefault(originalEngine);
});

Generally the purpose of this is to set an alternative engine as default for use in the tests - for suggestions or other reasons.

If we added an additional argument to the various install functions to set the engine as default, we could avoid most of this boilerplate. We may also be able to use resetToAppDefaultEngine in the cleanup function.

and convert existing would-be-broken consumers to use the new format arguments

Depends on D161043

Attachment #9301566 - Attachment description: Bug 1791974 - Add set as default (private) search engine options to SearchTestUtils.promiseNewSearchEngine. r?mcheang → Bug 1791974 - Add set as default (private) search engine options to SearchTestUtils.promiseNewSearchEngine. r?mcheang!
Attachment #9301567 - Attachment description: Bug 1791974 - Add set as default (private) search engine options to SearchTestUtils.installSearchExtension. r?mcheang → Bug 1791974 - Add set as default (private) search engine options to SearchTestUtils.installSearchExtension. r?mcheang!
Attachment #9301568 - Attachment description: Bug 1791974 - Use setAsDefault* parameters where appropriate for consumers of SearchTestUtils.installSearchExtension. r?mcheang → Bug 1791974 - Use setAsDefault* parameters where appropriate for consumers of SearchTestUtils.installSearchExtension. r?mcheang!
Pushed by mbanner@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/e20401f6948b
Add set as default (private) search engine options to SearchTestUtils.promiseNewSearchEngine. r=mcheang
https://hg.mozilla.org/integration/autoland/rev/182ff17fa508
Add set as default (private) search engine options to SearchTestUtils.installSearchExtension. r=mcheang
https://hg.mozilla.org/integration/autoland/rev/4c5648a82120
Use setAsDefault* parameters where appropriate for consumers of SearchTestUtils.installSearchExtension. r=mcheang
Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 109 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: