Bug 1451992 - Spawn errors when encountering missing/empty search l10n ids. r?jaws
MozReview-Commit-ID: 7WbtaNqO1Dg
--- a/browser/components/preferences/in-content/findInPage.js
+++ b/browser/components/preferences/in-content/findInPage.js
@@ -472,26 +472,34 @@ var gSearchResultsPane = {
.split(",")
.map(s => s.trim().split(".")).filter(s => s[0].length > 0);
const messages = await document.l10n.formatMessages(refs.map(ref => [ref[0]]));
// Map the localized messages taking value or a selected attribute and
// building a string of concatenated translated strings out of it.
let keywords = messages.map((msg, i) => {
- if (msg === null) {
- console.warn(`Missing search l10n id "${refs[i][0]}"`);
+ let [refId, refAttr] = refs[i];
+ if (!msg) {
+ console.error(`Missing search l10n id "${refId}"`);
return null;
}
- if (refs[i][1]) {
- let attr = msg.attrs.find(a => a.name === refs[i][1]);
- if (attr) {
- return attr.value;
+ if (refAttr) {
+ let attr = msg.attrs.find(a => a.name === refAttr);
+ if (!attr) {
+ console.error(`Missing search l10n id "${refId}.${refAttr}"`);
+ return null;
}
- return null;
+ if (attr.value === "") {
+ console.error(`Empty value added to search-l10n-ids "${refId}.${refAttr}"`);
+ }
+ return attr.value;
+ }
+ if (msg.value === "") {
+ console.error(`Empty value added to search-l10n-ids "${refId}"`);
}
return msg.value;
}).filter(keyword => keyword !== null).join(" ");
this.searchKeywords.set(nodeObject, keywords);
return this.queryMatchesContent(keywords, searchPhrase);
}