Bug 1518252 - Make docl10n tests non-racy. r=Pike
authorZibi Braniecki <zbraniecki@mozilla.com>
Fri, 25 Jan 2019 21:34:38 +0000
changeset 515536 4c5dafe7351892a28095a98f8f161f41126168c6
parent 515535 33ca2ea6b37064d12c0d4fefc81bf689396a5e57
child 515537 9ae7ae0acee4f8807cffaf64fef4f2e3a614b997
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersPike
bugs1518252
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1518252 - Make docl10n tests non-racy. r=Pike Differential Revision: https://phabricator.services.mozilla.com/D17333
intl/l10n/test/dom/test_docl10n.html
intl/l10n/test/dom/test_docl10n.xhtml
intl/l10n/test/dom/test_docl10n.xul
--- a/intl/l10n/test/dom/test_docl10n.html
+++ b/intl/l10n/test/dom/test_docl10n.html
@@ -8,44 +8,46 @@
   <link rel="localization" href="crashreporter/aboutcrashes.ftl"/>
   <script type="application/javascript">
   "use strict";
   SimpleTest.waitForExplicitFinish();
 
   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,
       "date-crashed-heading",
       {
         name: "John",
       }
     );
 
     // Test for l10n.getAttributes
     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>
 <body>
   <h1 id="main-desc" data-l10n-id="crash-reports-title"></h1>
 
   <p id="label1"></p>
 </body>
--- a/intl/l10n/test/dom/test_docl10n.xhtml
+++ b/intl/l10n/test/dom/test_docl10n.xhtml
@@ -14,44 +14,46 @@
   <link rel="localization" href="crashreporter/aboutcrashes.ftl"/>
   <script type="application/javascript">
   "use strict";
   SimpleTest.waitForExplicitFinish();
 
   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
     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,
       "date-crashed-heading",
       {
         name: "John",
       }
     );
 
     // Test for l10n.getAttributes
     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>
 <body>
   <h1 id="main-desc" data-l10n-id="crash-reports-title"></h1>
 
   <p id="label1" />
 </body>
--- a/intl/l10n/test/dom/test_docl10n.xul
+++ b/intl/l10n/test/dom/test_docl10n.xul
@@ -16,44 +16,46 @@
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
   <script type="application/javascript">
   <![CDATA[
   SimpleTest.waitForExplicitFinish();
 
   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
     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,
       "date-crashed-heading",
       {
         name: "John"
       }
     );
 
     // Test for l10n.getAttributes
     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>
 
   <description id="main-desc" data-l10n-id="crash-reports-title"/>
 
   <label id="label1" />
 </window>