tor-browser

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

test_docl10n.xhtml (1892B)


      1 <?xml version="1.0" encoding="UTF-8"?>
      2 <!-- This Source Code Form is subject to the terms of the Mozilla Public
      3   - License, v. 2.0. If a copy of the MPL was not distributed with this
      4   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
      5 
      6 <!DOCTYPE html>
      7 
      8 <html xmlns="http://www.w3.org/1999/xhtml">
      9 <head>
     10  <meta charset="utf-8"></meta>
     11  <title>Test DocumentL10n in HTML environment</title>
     12  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
     13  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"></link>
     14  <link rel="localization" href="crashreporter/aboutcrashes.ftl"/>
     15  <script type="application/javascript">
     16  "use strict";
     17  SimpleTest.waitForExplicitFinish();
     18 
     19  document.addEventListener("DOMContentLoaded", async function() {
     20    await document.l10n.ready;
     21 
     22    // Test for initial localization applied.
     23    let desc = document.getElementById("main-desc");
     24    is(!!desc.textContent.length, true);
     25 
     26    // Test for manual value formatting
     27    let msg = await document.l10n.formatValue("id-heading");
     28    is(!!msg.length, true);
     29 
     30    // Test for mutations applied.
     31    let verifyL10n = () => {
     32      if (label.textContent.length) {
     33        window.removeEventListener("MozAfterPaint", verifyL10n);
     34        SimpleTest.finish();
     35      }
     36    };
     37    window.addEventListener("MozAfterPaint", verifyL10n);
     38 
     39    let label = document.getElementById("label1");
     40    document.l10n.setAttributes(
     41      label,
     42      "date-crashed-heading",
     43      {
     44        name: "John",
     45      }
     46    );
     47 
     48    // Test for l10n.getAttributes
     49    let l10nArgs = document.l10n.getAttributes(label);
     50    is(l10nArgs.id, "date-crashed-heading");
     51    is(l10nArgs.args.name, "John");
     52  }, { once: true});
     53  </script>
     54 </head>
     55 <body>
     56  <h1 id="main-desc" data-l10n-id="crash-reports-title"></h1>
     57 
     58  <p id="label1" />
     59 </body>
     60 </html>