From 62d253d96e166bda33961a2d637abc8d3d3368b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 10 Apr 2025 20:30:46 +0000 Subject: [PATCH] Bug 1959758 - Don't depend on MozAfterPaint timing in test_set_attributes.html. r=Gijs I'm doing changes in the area and this test really doesn't need it. Differential Revision: https://phabricator.services.mozilla.com/D245098 --- .../l10n_mutations/test_set_attributes.html | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/dom/l10n/tests/mochitest/l10n_mutations/test_set_attributes.html b/dom/l10n/tests/mochitest/l10n_mutations/test_set_attributes.html index 762353a06c45..ce2655e89549 100644 --- a/dom/l10n/tests/mochitest/l10n_mutations/test_set_attributes.html +++ b/dom/l10n/tests/mochitest/l10n_mutations/test_set_attributes.html @@ -17,16 +17,19 @@ let elem2 = document.getElementById("elem2"); is(elem.textContent.length, 0); is(elem2.textContent.includes("Initial string"), true); + + let promiseMutations = new Promise(r => { + document.addEventListener("L10nMutationsFinished", r, { once: 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); + await promiseMutations; + + isnot(elem.textContent.length, 0); + ok(elem2.textContent.includes("New string"), "Should include new string"); + SimpleTest.finish(); });