summaryrefslogtreecommitdiffstats
path: root/dom/l10n/tests/mochitest/document_l10n/test_docl10n.xhtml
diff options
context:
space:
mode:
Diffstat (limited to 'dom/l10n/tests/mochitest/document_l10n/test_docl10n.xhtml')
-rw-r--r--dom/l10n/tests/mochitest/document_l10n/test_docl10n.xhtml60
1 files changed, 60 insertions, 0 deletions
diff --git a/dom/l10n/tests/mochitest/document_l10n/test_docl10n.xhtml b/dom/l10n/tests/mochitest/document_l10n/test_docl10n.xhtml
new file mode 100644
index 0000000000..2d51d8689e
--- /dev/null
+++ b/dom/l10n/tests/mochitest/document_l10n/test_docl10n.xhtml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- This Source Code Form is subject to the terms of the Mozilla Public
+ - License, v. 2.0. If a copy of the MPL was not distributed with this
+ - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
+
+<!DOCTYPE html>
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <meta charset="utf-8"></meta>
+ <title>Test DocumentL10n in HTML environment</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"></link>
+ <link rel="localization" href="crashreporter/aboutcrashes.ftl"/>
+ <script type="application/javascript">
+ "use strict";
+ SimpleTest.waitForExplicitFinish();
+
+ document.addEventListener("DOMContentLoaded", async function() {
+ await document.l10n.ready;
+
+ // Test for initial localization applied.
+ let desc = document.getElementById("main-desc");
+ is(!!desc.textContent.length, true);
+
+ // Test for manual value formatting
+ let msg = await document.l10n.formatValue("id-heading");
+ is(!!msg.length, true);
+
+ // Test for mutations applied.
+ let verifyL10n = () => {
+ if (label.textContent.length) {
+ window.removeEventListener("MozAfterPaint", verifyL10n);
+ SimpleTest.finish();
+ }
+ };
+ window.addEventListener("MozAfterPaint", verifyL10n);
+
+ let label = document.getElementById("label1");
+ document.l10n.setAttributes(
+ label,
+ "date-crashed-heading",
+ {
+ name: "John",
+ }
+ );
+
+ // Test for l10n.getAttributes
+ let l10nArgs = document.l10n.getAttributes(label);
+ is(l10nArgs.id, "date-crashed-heading");
+ is(l10nArgs.args.name, "John");
+ }, { once: true});
+ </script>
+</head>
+<body>
+ <h1 id="main-desc" data-l10n-id="crash-reports-title"></h1>
+
+ <p id="label1" />
+</body>
+</html>