tor-browser

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

test_same_id_args.html (1889B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <meta charset="utf-8">
      5  <title>Test Amount of mutations generated from DOM Overlays</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="toolkit/about/aboutTelemetry.ftl"/>
      9  <script type="application/javascript">
     10  "use strict";
     11  SimpleTest.waitForExplicitFinish();
     12 
     13  let config = {
     14    attributes: true,
     15    attributeOldValue: true,
     16    characterData: true,
     17    characterDataOldValue: true,
     18    childList: true,
     19    subtree: true,
     20  };
     21  let allMutations = [];
     22 
     23  document.addEventListener("DOMContentLoaded", async function() {
     24    await document.l10n.ready;
     25 
     26    let inputElem = document.getElementById("search-input");
     27 
     28    // Test for initial localization applied.
     29    is(!!inputElem.getAttribute("placeholder").length, true);
     30 
     31    let observer = new MutationObserver((mutations) => {
     32      for (let mutation of mutations) {
     33        allMutations.push(mutation);
     34      }
     35    });
     36    observer.observe(inputElem, config);
     37 
     38    document.l10n.setAttributes(inputElem, "about-telemetry-filter-placeholder", {selectedTitle: "Test"});
     39 
     40    // Due to the async iteractions between nsINode.localize
     41    // and DOMLocalization, we'll need to wait two frames
     42    // to verify that no mutations happened.
     43    requestAnimationFrame(() => {
     44      requestAnimationFrame(() => {
     45        // Since the l10n-id is the same as the previous one
     46        // no mutation should happen in result.
     47        is(allMutations.length, 0);
     48        SimpleTest.finish();
     49      });
     50    });
     51  }, { once: true});
     52  </script>
     53 </head>
     54 <body>
     55  <input id="search-input" data-l10n-id="about-telemetry-filter-placeholder" data-l10n-args='{"selectedTitle":"Test"}'></input>
     56 </body>
     57 </html>