Bug 1455048 - Revert the workaround added to Fluent for microtasks bug. r=mossop
authorZibi Braniecki <zbraniecki@mozilla.com>
Wed, 18 Apr 2018 11:05:19 -0700
changeset 467859 884e583667a9c249262ecd2aa2bb16936751f291
parent 467858 c612d5be87ca4e3bf62df49c0766889c989e3b9c
child 467860 c7fc12c5f34e21a1e15deeb6472af26d06d78ae8
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmossop
bugs1455048
milestone61.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 1455048 - Revert the workaround added to Fluent for microtasks bug. r=mossop MozReview-Commit-ID: AFpNRPfJpm7
intl/l10n/l10n.js
--- a/intl/l10n/l10n.js
+++ b/intl/l10n/l10n.js
@@ -1,45 +1,36 @@
 {
   const { DOMLocalization } =
     ChromeUtils.import("resource://gre/modules/DOMLocalization.jsm", {});
 
   /**
    * Polyfill for document.ready polyfill.
    * See: https://github.com/whatwg/html/issues/127 for details.
    *
-   * XXX: The callback is a temporary workaround for bug 1193394. Once Promises in Gecko
-   *      start beeing a microtask and stop pushing translation post-layout, we can
-   *      remove it and start using the returned Promise again.
-   *
-   * @param {Function} callback - function to be called when the document is ready.
    * @returns {Promise}
    */
-  function documentReady(callback) {
+  function documentReady() {
     if (document.contentType === "application/vnd.mozilla.xul+xml") {
       // XUL
       return new Promise(
         resolve => document.addEventListener(
-          "MozBeforeInitialXULLayout", () => {
-            resolve(callback());
-          }, { once: true }
+          "MozBeforeInitialXULLayout", resolve, { once: true }
         )
       );
     }
 
     // HTML
     const rs = document.readyState;
     if (rs === "interactive" || rs === "completed") {
-      return Promise.resolve(callback);
+      return Promise.resolve();
     }
     return new Promise(
       resolve => document.addEventListener(
-        "readystatechange", () => {
-          resolve(callback());
-        }, { once: true }
+        "readystatechange", resolve, { once: true }
       )
     );
   }
 
   /**
    * Scans the `elem` for links with localization resources.
    *
    * @param {Element} elem
@@ -53,14 +44,14 @@
 
   const resourceIds = getResourceLinks(document.head || document);
 
   document.l10n = new DOMLocalization(window, resourceIds);
 
   // trigger first context to be fetched eagerly
   document.l10n.ctxs.touchNext();
 
-  document.l10n.ready = documentReady(() => {
+  document.l10n.ready = documentReady().then(() => {
     document.l10n.registerObservers();
     document.l10n.connectRoot(document.documentElement);
     return document.l10n.translateRoots();
   });
 }