intl/l10n/test/dom/test_domloc_getAttributes.html
author Kris Maglione <maglione.k@gmail.com>
Mon, 29 Jan 2018 15:20:18 -0800
changeset 454011 e6a7b5e11ba856ee3535f76c6bcca17ea29e3d5f
parent 453889 c6e0fe339cb1e7c0c029e68be5332e52f53ab6b7
child 457215 2a34dd4ed3e384d031da4a0aa70290b0707bec35
permissions -rw-r--r--
Bug 1431533: Part 5a - Auto-rewrite code to use ChromeUtils import methods. r=florian This was done using the following script: https://bitbucket.org/kmaglione/m-c-rewrites/src/37e3803c7a23385bab5ea077ba8692bcfe1608fc/processors/chromeutils-import.jsm MozReview-Commit-ID: 1Nc3XDu0wGl

<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <title>Test DOMLocalization.prototype.getAttributes</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">
  <script type="application/javascript">
  "use strict";
  const { DOMLocalization } =
    ChromeUtils.import("resource://gre/modules/DOMLocalization.jsm", {});

  async function * mockGenerateMessages(locales, resourceIds) {}

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

    const domLoc = new DOMLocalization(
      window,
      [],
      mockGenerateMessages
    );

    const p1 = document.querySelectorAll('p')[0];
    const p2 = document.querySelectorAll('p')[1];
    const p3 = document.querySelectorAll('p')[2];
    const attrs1 = domLoc.getAttributes(p1);
    const attrs2 = domLoc.getAttributes(p2);
    const attrs3 = domLoc.getAttributes(p3);
    isDeeply(attrs1, {
      id: null,
      args: null
    });
    isDeeply(attrs2, {
      id: "id1",
      args: null
    });
    isDeeply(attrs3, {
      id: "id2",
      args: {
        userName: "John"
      }
    });

    SimpleTest.finish();
  };
  </script>
</head>
<body>
  <p />
  <p data-l10n-id="id1" />
  <p data-l10n-id="id2" data-l10n-args='{"userName": "John"}' />
</body>
</html>