Bug 1451992 - Spawn errors when encountering missing/empty search l10n ids. r?jaws draft
authorZibi Braniecki <zbraniecki@mozilla.com>
Thu, 05 Apr 2018 15:41:12 +0200
changeset 780806 c595f6691fcc8d9db27f56e1af772f9bf51dd157
parent 780805 94fc20ee34710383b274df6b669f17fd449bf2b3
child 780807 b53b809f471a60726672d4b317963116645d756e
push id106126
push userbmo:gandalf@aviary.pl
push dateThu, 12 Apr 2018 01:21:35 +0000
reviewersjaws
bugs1451992
milestone61.0a1
Bug 1451992 - Spawn errors when encountering missing/empty search l10n ids. r?jaws MozReview-Commit-ID: 7WbtaNqO1Dg
browser/components/preferences/in-content/findInPage.js
--- 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);
     }