tor-browser

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

test_remove_fragment.html (2270B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <meta charset="utf-8">
      5  <title>Test L10n Mutations for removing fragment</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  <script type="application/javascript">
     10  "use strict";
     11  SimpleTest.waitForExplicitFinish();
     12 
     13  document.addEventListener("DOMContentLoaded", async function() {
     14    let div = document.createElement("div");
     15    let div2 = document.createElement("div");
     16 
     17    let elem = document.createElement("p");
     18    let elem2 = document.createElement("p");
     19    let elem3 = document.createElement("p");
     20    let elem4 = document.createElement("p");
     21 
     22    document.l10n.setAttributes(elem, "crash-reports-title");
     23    document.l10n.setAttributes(elem2, "crash-reports-title");
     24    document.l10n.setAttributes(elem3, "crash-reports-title");
     25    document.l10n.setAttributes(elem4, "crash-reports-title");
     26 
     27    div.appendChild(elem);
     28    div.appendChild(elem2);
     29    div.appendChild(elem3);
     30    div.appendChild(elem4);
     31 
     32    document.body.appendChild(div);
     33 
     34    is(elem.textContent.length, 0);
     35    is(elem2.textContent.length, 0);
     36    is(elem3.textContent.length, 0);
     37    is(elem4.textContent.length, 0);
     38 
     39    document.body.removeChild(div);
     40 
     41    div2.appendChild(elem);
     42    div2.appendChild(elem3);
     43 
     44    document.body.appendChild(div2);
     45 
     46    // 1. `elem` should be localized since it is in DOM.
     47    await SimpleTest.waitForCondition(() => !!elem.textContent.length);
     48 
     49    // 2. `elem2` was removed before l10n frame, so it should remain not localized.
     50    is(elem2.textContent.length, 0);
     51 
     52    // 3. `elem3` was added/removed/re-added so it should become localized.
     53    await SimpleTest.waitForCondition(() => !!elem3.textContent.length);
     54 
     55    // 4. `elem4` was not re-added, so it shouldn't be localized.
     56    is(elem4.textContent.length, 0);
     57 
     58    document.body.appendChild(div);
     59    // 5. Now we re-added `elem4` to DOM so it should get localized.
     60    await SimpleTest.waitForCondition(() => !!elem4.textContent.length);
     61    SimpleTest.finish();
     62  });
     63  </script>
     64 </head>
     65 <body>
     66 </body>
     67 </html>