tor-browser

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

test_connectRoot.html (1194B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <meta charset="utf-8">
      5  <title>Test DOMLocalization.prototype.connectRoot</title>
      6  <script 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  <script type="application/javascript">
      9  "use strict";
     10  const l10nReg = new L10nRegistry();
     11  const fs = [
     12    { path: "/localization/en-US/mock.ftl", source: `
     13 key1 = Value for Key 1
     14 ` },
     15  ];
     16  const source = L10nFileSource.createMock("test", "app", ["en-US"], "/localization/{locale}", fs);
     17  l10nReg.registerSources([source]);
     18 
     19  window.onload = async function() {
     20    SimpleTest.waitForExplicitFinish();
     21 
     22    const p1 = document.getElementById("p1");
     23 
     24    const domLoc = new DOMLocalization(
     25      ["/mock.ftl"],
     26      false,
     27      l10nReg,
     28      ["en-US"],
     29    );
     30 
     31    await domLoc.translateRoots();
     32    is(!p1.textContent.length, true);
     33    const body = document.body;
     34    domLoc.connectRoot(body);
     35    await domLoc.translateRoots();
     36    is(!!p1.textContent.length, true);
     37 
     38    SimpleTest.finish();
     39  };
     40  </script>
     41 </head>
     42 <body>
     43  <p id="p1" data-l10n-id="key1"></p>
     44 </body>
     45 </html>