Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test L10n Mutations for AttributeChange after DOMContentLoaded</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">
<link rel="localization" href="crashreporter/aboutcrashes.ftl"/>
<link rel="localization" href="toolkit/about/aboutCompat.ftl"/>
<script type="application/javascript">
"use strict";
SimpleTest.waitForExplicitFinish();
document.addEventListener("DOMContentLoaded", async function() {
await document.l10n.ready;
let elem = document.getElementById("elem1");
let elem2 = document.getElementById("elem2");
is(elem.textContent.length, 0);
is(elem2.textContent.includes("Initial string"), true);
document.l10n.setAttributes(elem, "crash-reports-title");
elem2.setAttribute("data-l10n-args", JSON.stringify({bug: "New string"}));
let verifyL10n = () => {
if (elem.textContent.length && elem2.textContent.includes("New string")) {
window.removeEventListener("MozAfterPaint", verifyL10n);
SimpleTest.finish();
}
};
window.addEventListener("MozAfterPaint", verifyL10n);
});
</script>
</head>
<body>
<div id="elem1"></div>
<div id="elem2" data-l10n-id="label-more-information" data-l10n-args='{"bug":"Initial string"}'></div>
</body>
</html>