tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_set_attributes.html (1497B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <meta charset="utf-8">
      5  <title>Test L10n Mutations for AttributeChange after DOMContentLoaded</title>
      6  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
      7  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
      8  <link rel="localization" href="crashreporter/aboutcrashes.ftl"/>
      9  <link rel="localization" href="toolkit/about/aboutCompat.ftl"/>
     10  <script type="application/javascript">
     11  "use strict";
     12  SimpleTest.waitForExplicitFinish();
     13 
     14  document.addEventListener("DOMContentLoaded", async function() {
     15    await document.l10n.ready;
     16    let elem = document.getElementById("elem1");
     17    let elem2 = document.getElementById("elem2");
     18    is(elem.textContent.length, 0);
     19    is(elem2.textContent.includes("Initial string"), true);
     20 
     21    let promiseMutations = new Promise(r => {
     22      document.addEventListener("L10nMutationsFinished", r, { once: true });
     23    });
     24 
     25    document.l10n.setAttributes(elem, "crash-reports-title");
     26    elem2.setAttribute("data-l10n-args", JSON.stringify({bug: "New string"}));
     27 
     28    await promiseMutations;
     29 
     30    isnot(elem.textContent.length, 0);
     31    ok(elem2.textContent.includes("New string"), "Should include new string");
     32    SimpleTest.finish();
     33  });
     34  </script>
     35 </head>
     36 <body>
     37  <div id="elem1"></div>
     38  <div id="elem2" data-l10n-id="label-more-information" data-l10n-args='{"bug":"Initial string"}'></div>
     39 </body>
     40 </html>