summaryrefslogtreecommitdiffstats
path: root/dom/l10n/tests/mochitest/l10n_overlays/test_same_id_args.html
blob: e43c39497041c47fa31c5137fb7afbdbb6cabea9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <title>Test Amount of mutations generated from DOM Overlays</title>
  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
  <link rel="localization" href="toolkit/about/aboutTelemetry.ftl"/>
  <script type="application/javascript">
  "use strict";
  SimpleTest.waitForExplicitFinish();

  let config = {
    attributes: true,
    attributeOldValue: true,
    characterData: true,
    characterDataOldValue: true,
    childList: true,
    subtree: true,
  };
  let allMutations = [];

  document.addEventListener("DOMContentLoaded", async function() {
    await document.l10n.ready;

    let inputElem = document.getElementById("search-input");

    // Test for initial localization applied.
    is(!!inputElem.getAttribute("placeholder").length, true);

    let observer = new MutationObserver((mutations) => {
      for (let mutation of mutations) {
        allMutations.push(mutation);
      }
    });
    observer.observe(inputElem, config);

    document.l10n.setAttributes(inputElem, "about-telemetry-filter-placeholder", {selectedTitle: "Test"});

    // Due to the async iteractions between nsINode.localize
    // and DOMLocalization, we'll need to wait two frames
    // to verify that no mutations happened.
    requestAnimationFrame(() => {
      requestAnimationFrame(() => {
        // Since the l10n-id is the same as the previous one
        // no mutation should happen in result.
        is(allMutations.length, 0);
        SimpleTest.finish();
      });
    });
  }, { once: true});
  </script>
</head>
<body>
  <input id="search-input" data-l10n-id="about-telemetry-filter-placeholder" data-l10n-args='{"selectedTitle":"Test"}'></input>
</body>
</html>