tor-browser

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

test_overlay_missing_children.html (1694B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <meta charset="utf-8">
      5  <title>Test DOMLocalization's DOMOverlay functionality</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 title = Visit <a data-l10n-name="mozilla-link">Mozilla</a> or <a data-l10n-name="firefox-link">Firefox</a> website!
     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 domLoc = new DOMLocalization(
     23      ["/mock.ftl"],
     24      false,
     25      l10nReg,
     26      ["en-US"],
     27    );
     28 
     29    await domLoc.translateFragment(document.body);
     30 
     31    const p1 = document.querySelectorAll("p")[0];
     32    const linkList = p1.querySelectorAll("a");
     33 
     34 
     35    is(linkList[0].getAttribute("href"), "http://www.mozilla.org");
     36    is(linkList[0].textContent, "Mozilla");
     37    is(linkList[1].getAttribute("href"), "http://www.firefox.com");
     38    is(linkList[1].textContent, "Firefox");
     39 
     40    is(linkList.length, 2, "There should be exactly two links in the result.");
     41 
     42    SimpleTest.finish();
     43  };
     44  </script>
     45 </head>
     46 <body>
     47  <p data-l10n-id="title">
     48    <a href="http://www.mozilla.org" data-l10n-name="mozilla-link"></a>
     49    <a href="http://www.firefox.com" data-l10n-name="firefox-link"></a>
     50    <a href="http://www.w3.org" data-l10n-name="w3-link"></a>
     51  </p>
     52 </body>
     53 </html>