Bug 1518252 - Make docl10n tests non-racy. r=Pike

Differential Revision: https://phabricator.services.mozilla.com/D17333

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Zibi Braniecki 2019-01-25 21:34:38 +00:00
Родитель a489431ca6
Коммит 47566628cd
3 изменённых файлов: 31 добавлений и 25 удалений

Просмотреть файл

@ -13,13 +13,23 @@
document.addEventListener("DOMContentLoaded", async function() {
await document.l10n.ready;
// Test for initial localization applied.
let desc = document.getElementById("main-desc");
is(desc.textContent.length > 0, true);
// Test for manual value formatting
// Test for manual value formatting.
let msg = await document.l10n.formatValue("id-heading");
is(msg.length > 0, true);
// Test for mutations applied.
let verifyL10n = () => {
if (label.textContent.length > 0) {
window.removeEventListener("MozAfterPaint", verifyL10n);
SimpleTest.finish();
}
};
window.addEventListener("MozAfterPaint", verifyL10n);
let label = document.getElementById("label1");
document.l10n.setAttributes(
label,
@ -33,14 +43,6 @@
let l10nArgs = document.l10n.getAttributes(label);
is(l10nArgs.id, "date-crashed-heading");
is(l10nArgs.args.name, "John");
let verifyL10n = () => {
if (label.textContent.length > 0) {
window.removeEventListener("MozAfterPaint", verifyL10n);
SimpleTest.finish();
}
};
window.addEventListener("MozAfterPaint", verifyL10n);
}, { once: true});
</script>
</head>

Просмотреть файл

@ -19,6 +19,7 @@
document.addEventListener("DOMContentLoaded", async function() {
await document.l10n.ready;
// Test for initial localization applied.
let desc = document.getElementById("main-desc");
is(desc.textContent.length > 0, true);
@ -26,6 +27,15 @@
let msg = await document.l10n.formatValue("id-heading");
is(msg.length > 0, true);
// Test for mutations applied.
let verifyL10n = () => {
if (label.textContent.length > 0) {
window.removeEventListener("MozAfterPaint", verifyL10n);
SimpleTest.finish();
}
};
window.addEventListener("MozAfterPaint", verifyL10n);
let label = document.getElementById("label1");
document.l10n.setAttributes(
label,
@ -39,14 +49,6 @@
let l10nArgs = document.l10n.getAttributes(label);
is(l10nArgs.id, "date-crashed-heading");
is(l10nArgs.args.name, "John");
let verifyL10n = () => {
if (label.textContent.length > 0) {
window.removeEventListener("MozAfterPaint", verifyL10n);
SimpleTest.finish();
}
};
window.addEventListener("MozAfterPaint", verifyL10n);
}, { once: true});
</script>
</head>

Просмотреть файл

@ -21,6 +21,7 @@
document.addEventListener("DOMContentLoaded", async function() {
await document.l10n.ready;
// Test for initial localization applied.
let desc = document.getElementById("main-desc");
is(desc.textContent.length > 0, true);
@ -28,6 +29,15 @@
let msg = await document.l10n.formatValue("id-heading");
is(msg.length > 0, true);
// Test for mutations applied.
let verifyL10n = () => {
if (label.textContent.length > 0) {
window.removeEventListener("MozAfterPaint", verifyL10n);
SimpleTest.finish();
}
};
window.addEventListener("MozAfterPaint", verifyL10n);
let label = document.getElementById("label1");
document.l10n.setAttributes(
label,
@ -41,14 +51,6 @@
let l10nArgs = document.l10n.getAttributes(label);
is(l10nArgs.id, "date-crashed-heading");
is(l10nArgs.args.name, "John");
let verifyL10n = () => {
if (label.textContent.length > 0) {
window.removeEventListener("MozAfterPaint", verifyL10n);
SimpleTest.finish();
}
};
window.addEventListener("MozAfterPaint", verifyL10n);
}, { once: true});
]]>
</script>