Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!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);
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,
'&lt;em&gt;Markup&lt;/em&gt;'
);
}
</script>
</head>
<body>
</body>
</html>