<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <title>Test DOMLocalization.prototype.translateElements</title>
  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
  <script type="application/javascript">
  "use strict";
  const l10nReg = new L10nRegistry();
  const fs = [
    { path: "/localization/en-US/mock.ftl", source: `
title = Hello World
link =
    .title = Click me
` },
  ];
  const source = L10nFileSource.createMock("test", "app", ["en-US"], "/localization/{locale}", fs);
  l10nReg.registerSources([source]);

  window.onload = async function() {
    SimpleTest.waitForExplicitFinish();

    const domLoc = new DOMLocalization(
      ["/mock.ftl"],
      false,
      l10nReg,
      ["en-US"],
    );

    const p1 = document.querySelectorAll("p")[0];
    const link1 = document.querySelectorAll("a")[0];

    await domLoc.translateElements([p1, link1]);

    is(p1.textContent, "Hello World");
    is(link1.getAttribute("title"), "Click me");

    SimpleTest.finish();
  };
  </script>
</head>
<body>
  <p data-l10n-id="title" />
  <a data-l10n-id="link" />
</body>
</html>
