summaryrefslogtreecommitdiffstats
path: root/dom/l10n/tests/mochitest/dom_localization/test_domloc.xhtml
diff options
context:
space:
mode:
Diffstat (limited to 'dom/l10n/tests/mochitest/dom_localization/test_domloc.xhtml')
-rw-r--r--dom/l10n/tests/mochitest/dom_localization/test_domloc.xhtml68
1 files changed, 68 insertions, 0 deletions
diff --git a/dom/l10n/tests/mochitest/dom_localization/test_domloc.xhtml b/dom/l10n/tests/mochitest/dom_localization/test_domloc.xhtml
new file mode 100644
index 0000000000..a4d4fcc506
--- /dev/null
+++ b/dom/l10n/tests/mochitest/dom_localization/test_domloc.xhtml
@@ -0,0 +1,68 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
+ type="text/css"?>
+
+
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ title="Testing DOMLocalization in XUL environment">
+
+ <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
+ <script type="application/javascript">
+ <![CDATA[
+ const l10nReg = new L10nRegistry();
+ const fs = [
+ { path: "/localization/en-US/mock.ftl", source: `
+file-menu =
+ .label = File
+ .accesskey = F
+new-tab =
+ .label = New Tab
+ .accesskey = N
+container = Some text with an <image data-l10n-name="foo"> inside it.
+` },
+ ];
+ const source = L10nFileSource.createMock("test", "app", ["en-US"], "/localization/{locale}", fs);
+ l10nReg.registerSources([source]);
+
+ SimpleTest.waitForExplicitFinish();
+
+
+ const domLoc = new DOMLocalization(
+ [],
+ false,
+ l10nReg,
+ ["en-US"],
+ );
+
+ async function foo() {
+ domLoc.addResourceIds(["/mock.ftl"]);
+ domLoc.connectRoot(document.documentElement);
+ await domLoc.translateRoots();
+
+ is(document.getElementById('file-menu').getAttribute('label'), 'File');
+ is(document.getElementById('file-menu').getAttribute('accesskey'), 'F');
+
+ is(document.getElementById('new-tab').getAttribute('label'), 'New Tab');
+ is(document.getElementById('new-tab').getAttribute('accesskey'), 'N');
+
+ ok(document.querySelector("image"),
+ "Image should still be present after localization.");
+ SimpleTest.finish();
+ }
+
+ window.onload = foo;
+
+ ]]>
+ </script>
+ <description data-l10n-id="container"><image data-l10n-name="foo"/></description>
+
+ <menubar id="main-menubar">
+ <menu id="file-menu" data-l10n-id="file-menu">
+ <menupopup id="menu_FilePopup">
+ <menuitem id="new-tab" data-l10n-id="new-tab">
+ </menuitem>
+ </menupopup>
+ </menu>
+ </menubar>
+</window>