blob: 4571589b8ef5fedb0c93f3a090fe6e88f088989d (
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test L10nOverlays Special treatment of the title element</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">
/* global L10nOverlays */
"use strict";
function elem(name) {
return function(str) {
const element = document.createElement(name);
// eslint-disable-next-line no-unsanitized/property
element.innerHTML = str;
return element;
};
}
const { translateElement } = L10nOverlays;
{
// Text is fine.
const element = elem("title")``;
const translation = {
value: 'Text',
attributes: null,
};
translateElement(element, translation);
is(
element.innerHTML,
'Text'
);
}
{
// Markup is ignored.
const element = elem("title")``;
const translation = {
value: '<em>Markup</em>',
attributes: null,
};
translateElement(element, translation);
is(
element.textContent,
'<em>Markup</em>'
);
is(
element.innerHTML,
'<em>Markup</em>'
);
}
</script>
</head>
<body>
</body>
</html>
|