Bug 1631593 - Wait for async localization in aboutNetError tests. r=johannh

Differential Revision: https://phabricator.services.mozilla.com/D77968
This commit is contained in:
Zibi Braniecki 2020-06-04 17:02:01 +00:00
Родитель 065441a790
Коммит 534f9bc2a1
3 изменённых файлов: 37 добавлений и 6 удалений

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

@ -497,18 +497,26 @@ add_task(async function checkSandboxedIframe() {
let bc = browser.browsingContext.children[0];
await SpecialPowers.spawn(bc, [], async function() {
let doc = content.document;
// aboutNetError.js is using async localization to format several messages
// and in result the translation may be applied later.
// We want to return the textContent of the element only after
// the translation completes, so let's wait for it here.
let elements = [
doc.querySelector(".title-text"),
doc.getElementById("errorCode"),
];
await ContentTaskUtils.waitForCondition(() => {
return elements.every(elem => !!elem.textContent.trim().length);
});
let titleText = doc.querySelector(".title-text");
Assert.ok(
titleText.textContent.endsWith("Security Issue"),
"Title shows Did Not Connect: Potential Security Issue"
);
// Wait until fluent sets the errorCode inner text.
let el;
await ContentTaskUtils.waitForCondition(() => {
el = doc.getElementById("errorCode");
return el.textContent != "";
}, "error code has been set inside the advanced button panel");
let el = doc.getElementById("errorCode");
Assert.equal(
el.textContent,

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

@ -138,6 +138,16 @@ add_task(async function checkBadStsCert() {
: content.document;
let advancedButton = doc.getElementById("advancedButton");
advancedButton.click();
// aboutNetError.js is using async localization to format several messages
// and in result the translation may be applied later.
// We want to return the textContent of the element only after
// the translation completes, so let's wait for it here.
let elements = [doc.getElementById("badCertTechnicalInfo")];
await ContentTaskUtils.waitForCondition(() => {
return elements.every(elem => !!elem.textContent.trim().length);
});
return doc.getElementById("badCertTechnicalInfo").textContent;
}
);

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

@ -92,6 +92,19 @@ async function setupPage(htmlPageName, blockedPage) {
// to open the blocked page in a new window/tab
await SpecialPowers.spawn(iframe, [], async function() {
let doc = content.document;
// aboutNetError.js is using async localization to format several messages
// and in result the translation may be applied later.
// We want to return the textContent of the element only after
// the translation completes, so let's wait for it here.
let elements = [
doc.getElementById("errorLongDesc"),
doc.getElementById("openInNewWindowButton"),
];
await ContentTaskUtils.waitForCondition(() => {
return elements.every(elem => !!elem.textContent.trim().length);
});
let textLongDescription = doc.getElementById("errorLongDesc").textContent;
Assert.ok(
textLongDescription.includes(