Bug 1543493 - ensure DOM localization in XUL docs can localize content that includes an <image>, r=zbraniecki
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Fri, 12 Apr 2019 00:47:15 +0000
changeset 469249 0cee09cf4016fa15f2d5904e2e1c9efc0f5032c8
parent 469248 4c4e45853808229f832e32f6bcdbd4c92a72b13b
child 469250 894487fe3fa04ee0c91aef059bcbab4005f6e3e2
push id112776
push usershindli@mozilla.com
push dateFri, 12 Apr 2019 16:20:17 +0000
treeherdermozilla-inbound@b4501ced5619 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerszbraniecki
bugs1543493
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1543493 - ensure DOM localization in XUL docs can localize content that includes an <image>, r=zbraniecki Differential Revision: https://phabricator.services.mozilla.com/D26989
intl/l10n/DOMLocalization.jsm
intl/l10n/test/dom/test_domloc.xul
--- a/intl/l10n/DOMLocalization.jsm
+++ b/intl/l10n/DOMLocalization.jsm
@@ -209,17 +209,21 @@ function namedChildFrom(sourceElement, t
 
   if (!sourceChild) {
     console.warn(
       `An element named "${childName}" wasn't found in the source.`
     );
     return textNode(translatedChild);
   }
 
-  if (sourceChild.localName !== translatedChild.localName) {
+  if (sourceChild.localName !== translatedChild.localName &&
+      // Create a specific exception for img vs. image mismatches,
+      // see bug 1543493
+      !(translatedChild.localName == "img" &&
+        sourceChild.localName == "image")) {
     console.warn(
       `An element named "${childName}" was found in the translation ` +
       `but its type ${translatedChild.localName} didn't match the ` +
       `element found in the source (${sourceChild.localName}).`
     );
     return textNode(translatedChild);
   }
 
--- a/intl/l10n/test/dom/test_domloc.xul
+++ b/intl/l10n/test/dom/test_domloc.xul
@@ -20,16 +20,17 @@
     const bundle = new FluentBundle(locales);
     bundle.addMessages(`
 file-menu =
     .label = File
     .accesskey = F
 new-tab =
     .label = New Tab
     .accesskey = N
+container = Some text with an <image data-l10n-name="foo"> inside it.
 `);
     yield bundle;
   }
 
   SimpleTest.waitForExplicitFinish();
 
 
   const domLoc = new DOMLocalization(
@@ -42,23 +43,27 @@ new-tab =
     domLoc.connectRoot(document.documentElement);
     await domLoc.translateRoots();
 
     is(document.getElementById('file-menu').getAttribute('label'), 'File');
     is(document.getElementById('file-menu').getAttribute('accesskey'), 'F');
 
     is(document.getElementById('new-tab').getAttribute('label'), 'New Tab');
     is(document.getElementById('new-tab').getAttribute('accesskey'), 'N');
+
+    ok(document.querySelector("image"),
+       "Image should still be present after localization.");
     SimpleTest.finish();
   }
 
   window.onload = foo;
 
   ]]>
   </script>
+  <description data-l10n-id="container"><image data-l10n-name="foo"/></description>
 
   <menubar id="main-menubar">
     <menu id="file-menu" data-l10n-id="file-menu">
       <menupopup id="menu_FilePopup">
         <menuitem id="new-tab" data-l10n-id="new-tab">
         </menuitem>
       </menupopup>
     </menu>