Open Bug 1973899 Opened 9 months ago Updated 9 months ago

Search settings use name instead of id to check if app provided search engine is inactive

Categories

(Firefox :: Search, defect, P2)

Firefox 142
defect

Tracking

()

Tracking Status
firefox-esr128 --- affected
firefox-esr140 --- affected
firefox140 --- affected
firefox141 --- affected
firefox142 --- affected

People

(Reporter: mbeier, Unassigned)

References

Details

(Whiteboard: [sng])

https://searchfox.org/mozilla-central/rev/ec8a326713f60dec138a3e3383b03ac739870fc7/toolkit/components/search/SearchSettings.sys.mjs#316

In this line, search settings persists old entries for app provided engines if no app provided engine with the entry's name is currently available. If we rename an app provided engine, search settings will create a new entry with the new name but also keep the old entry with the old name but same id.

The following test case

const CONFIG = [{ identifier: "default" }];

add_setup(async function () {
  SearchTestUtils.updateRemoteSettingsConfig(CONFIG);
  await Services.search.init();
});

add_task(async function () {
  CONFIG[0].base = { name: "default2" };
  await SearchTestUtils.updateRemoteSettingsConfig(CONFIG);

  let settings = await Services.search.wrappedJSObject._settings.get();
  console.log(settings.engines);
});

produces the following output

[{id:"default", _name:"default2", _isAppProvided:true, _metaData:{}}, {id:"default", _name:"default", _isAppProvided:true, _metaData:{}}]

This doesn't cause the search service to crash immediately, but I think it might still lead to issues.

Severity: -- → S4
Priority: -- → P2
Whiteboard: [sng]
You need to log in before you can comment on or make changes to this bug.