L10nCache.add() throws on an unknown Fluent ID instead of reporting it
Categories
(Firefox :: Address Bar, task, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox157 | --- | fixed |
People
(Reporter: dao, Assigned: rootzero.brain, Mentored)
References
Details
(Keywords: good-first-bug, Whiteboard: [lang=js][sng])
Attachments
(1 file)
Filing as a good first bug to learn workflows.
L10nCache.add() in browser/components/urlbar/content/L10nCache.mjs guards against l10n.formatMessages() returning an empty array, but not against it resolving with a null message, which is what happens when the requested Fluent ID does not exist. The messages[0].value access then throws TypeError: can't access property "value", messages[0] is null, and because add() is awaited while building the urlbar result menu, one unknown ID leaves the whole menu empty instead of dropping a single item. Bug 2066758 is an instance of that.
The fix is to treat a null message the same way the empty array is treated: report it with console.error and return.
Link to the code:
https://searchfox.org/firefox-main/rev/2aa0bcf95c98681376e30d6a9aa4df2b27885abc/browser/components/urlbar/content/L10nCache.mjs#122-131
A unit test belongs in browser/components/urlbar/tests/unit/test_l10nCache.js, which builds a Localization over a mock file source via its initL10n() helper: adding an ID that the mock source does not define should leave the cache empty rather than reject.
To verify the fix:
./mach test browser/components/urlbar/tests/unit/test_l10nCache.js
Tutorial to contribute:
https://firefox-source-docs.mozilla.org/contributing/contribution_quickref.html
https://firefox-source-docs.mozilla.org/contributing/stack_quickref.html
Please don't ask for the bug to be assigned. It will be automatically assigned to the first patch.
Updated•28 days ago
|
Updated•26 days ago
|
Comment 3•25 days ago
|
||
| bugherder | ||
Updated•24 days ago
|
Description
•