Bug 1444445 - Remove unsafeSetInnerHTML in browser_l10n_localizeMarkup.js. r=johannh
authorTrisha <guptatrisha97@gmail.com>
Fri, 06 Apr 2018 19:44:57 +0800
changeset 412849 8dbca44c0855c8f311124dc18a650f14c0e4f8ea
parent 412848 0008c21a14abceaa092c96777ed97c86b4298562
child 412850 48b494a5ea758984cb20782e6ccee828819a5212
push id33820
push usershindli@mozilla.com
push dateWed, 11 Apr 2018 23:46:03 +0000
treeherdermozilla-central@1a9a362b9288 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjohannh
bugs1444445
milestone61.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 1444445 - Remove unsafeSetInnerHTML in browser_l10n_localizeMarkup.js. r=johannh MozReview-Commit-ID: 1eaABunZe0B
devtools/shared/tests/browser/browser_l10n_localizeMarkup.js
--- a/devtools/shared/tests/browser/browser_l10n_localizeMarkup.js
+++ b/devtools/shared/tests/browser/browser_l10n_localizeMarkup.js
@@ -13,41 +13,54 @@ add_task(function* () {
   let TOOLBOX_L10N = new LocalizationHelper("devtools/client/locales/toolbox.properties");
   let str1 = STARTUP_L10N.getStr("inspector.label");
   let str2 = STARTUP_L10N.getStr("inspector.accesskey");
   let str3 = TOOLBOX_L10N.getStr("toolbox.defaultTitle");
   ok(str1 && str2 && str3, "If this failed, strings should be updated in the test");
 
   info("Create the test markup");
   let div = document.createElement("div");
-  div.unsafeSetInnerHTML(
-  `<div data-localization-bundle="devtools/client/locales/startup.properties">
-     <div id="d0" data-localization="content=inspector.someInvalidKey"></div>
-     <div id="d1" data-localization="content=inspector.label">Text will disappear</div>
-     <div id="d2" data-localization="content=inspector.label;title=inspector.accesskey">
-     </div>
-     <!-- keep the following data-localization on two separate lines -->
-     <div id="d3" data-localization="content=inspector.label;
-                                     title=inspector.accesskey"></div>
-     <div id="d4" data-localization="aria-label=inspector.label">Some content</div>
-     <div data-localization-bundle="devtools/client/locales/toolbox.properties">
-       <div id="d5" data-localization="content=toolbox.defaultTitle"></div>
-     </div>
-   </div>
-  `);
+  div.setAttribute("data-localization-bundle",
+                   "devtools/client/locales/startup.properties");
+  let div0 = document.createElement("div");
+  div0.setAttribute("id", "d0");
+  div0.setAttribute("data-localization", "content=inspector.someInvalidKey");
+  div.appendChild(div0);
+  let div1 = document.createElement("div");
+  div1.setAttribute("id", "d1");
+  div1.setAttribute("data-localization", "content=inspector.label");
+  div.appendChild(div1);
+  div1.append("Text will disappear");
+  let div2 = document.createElement("div");
+  div2.setAttribute("id", "d2");
+  div2.setAttribute("data-localization",
+                    "content=inspector.label;title=inspector.accesskey");
+  div.appendChild(div2);
+  let div3 = document.createElement("div");
+  div3.setAttribute("id", "d3");
+  div3.setAttribute("data-localization",
+                    "content=inspector.label;title=inspector.accesskey");
+  div.appendChild(div3);
+  let div4 = document.createElement("div");
+  div4.setAttribute("id", "d4");
+  div4.setAttribute("data-localization", "aria-label=inspector.label");
+  div.appendChild(div4);
+  div4.append("Some content");
+  let toolboxDiv = document.createElement("div");
+  toolboxDiv.setAttribute("data-localization-bundle",
+                          "devtools/client/locales/toolbox.properties");
+  div.appendChild(toolboxDiv);
+  let div5 = document.createElement("div");
+  div5.setAttribute("id", "d5");
+  div5.setAttribute("data-localization", "content=toolbox.defaultTitle");
+  toolboxDiv.appendChild(div5);
 
   info("Use localization helper to localize the test markup");
   localizeMarkup(div);
 
-  let div1 = div.querySelector("#d1");
-  let div2 = div.querySelector("#d2");
-  let div3 = div.querySelector("#d3");
-  let div4 = div.querySelector("#d4");
-  let div5 = div.querySelector("#d5");
-
   is(div1.innerHTML, str1, "The content of #d1 is localized");
   is(div2.innerHTML, str1, "The content of #d2 is localized");
   is(div2.getAttribute("title"), str2, "The title of #d2 is localized");
   is(div3.innerHTML, str1, "The content of #d3 is localized");
   is(div3.getAttribute("title"), str2, "The title of #d3 is localized");
   is(div4.innerHTML, "Some content", "The content of #d4 is not replaced");
   is(div4.getAttribute("aria-label"), str1, "The aria-label of #d4 is localized");
   is(div5.innerHTML, str3, "The content of #d5 is localized with another bundle");