blob: 83b83757f16af69199d0a4ca76f61c66ff159a48 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test DOMLocalization.prototype.connectRoot</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: `
key1 = Value for Key 1
` },
];
const source = L10nFileSource.createMock("test", "app", ["en-US"], "/localization/{locale}", fs);
l10nReg.registerSources([source]);
window.onload = async function() {
SimpleTest.waitForExplicitFinish();
const p1 = document.getElementById("p1");
const domLoc = new DOMLocalization(
["/mock.ftl"],
false,
l10nReg,
["en-US"],
);
await domLoc.translateRoots();
is(!p1.textContent.length, true);
const body = document.body;
domLoc.connectRoot(body);
await domLoc.translateRoots();
is(!!p1.textContent.length, true);
SimpleTest.finish();
};
</script>
</head>
<body>
<p id="p1" data-l10n-id="key1"></p>
</body>
</html>
|