Bug 1514652 - Deal with async translations and their sizing in the sanitize dialog. r=zbraniecki, a=RyanVM
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 19 Dec 2018 13:47:17 +0000
changeset 509112 d57231c7ab800a5aed96eb1f05b2534bd39c44b8
parent 509111 6da52487092a73ee4e2164c07abc2bb7f850319e
child 509113 c4a08627b4e76fecf3a8a5dc856a67d2dba09731
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerszbraniecki, RyanVM
bugs1514652
milestone65.0
Bug 1514652 - Deal with async translations and their sizing in the sanitize dialog. r=zbraniecki, a=RyanVM Differential Revision: https://phabricator.services.mozilla.com/D14864
browser/base/content/sanitizeDialog.js
--- a/browser/base/content/sanitizeDialog.js
+++ b/browser/base/content/sanitizeDialog.js
@@ -35,19 +35,28 @@ var gSanitizePromptDialog = {
     this._inited = true;
 
     let OKButton = document.documentElement.getButton("accept");
     document.l10n.setAttributes(OKButton, "sanitize-button-ok");
 
     if (this.selectedTimespan === Sanitizer.TIMESPAN_EVERYTHING) {
       this.prepareWarning();
       this.warningBox.hidden = false;
-      window.document.l10n.setAttributes(window.document.documentElement, "dialog-title-everything");
-    } else
+      document.l10n.setAttributes(document.documentElement, "dialog-title-everything");
+      let warningDesc = document.getElementById("sanitizeEverythingWarning");
+      // Ensure we've translated and sized the warning.
+      document.mozSubdialogReady =
+        document.l10n.translateFragment(warningDesc).then(() => {
+          // And then ensure we've run layout.
+          let rootWin = window.docShell.rootTreeItem.QueryInterface(Ci.nsIDocShell).domWindow;
+          return rootWin.promiseDocumentFlushed(() => {});
+        });
+    } else {
       this.warningBox.hidden = true;
+    }
   },
 
   selectByTimespan() {
     // This method is the onselect handler for the duration dropdown.  As a
     // result it's called a couple of times before onload calls init().
     if (!this._inited)
       return;
 
@@ -55,26 +64,26 @@ var gSanitizePromptDialog = {
 
     // If clearing everything
     if (this.selectedTimespan === Sanitizer.TIMESPAN_EVERYTHING) {
       this.prepareWarning();
       if (warningBox.hidden) {
         warningBox.hidden = false;
         window.resizeBy(0, warningBox.boxObject.height);
       }
-      window.document.l10n.setAttributes(window.document.documentElement, "dialog-title-everything");
+      document.l10n.setAttributes(document.documentElement, "dialog-title-everything");
       return;
     }
 
     // If clearing a specific time range
     if (!warningBox.hidden) {
       window.resizeBy(0, -warningBox.boxObject.height);
       warningBox.hidden = true;
     }
-    window.document.l10n.setAttributes(window.document.documentElement, "dialog-title");
+    document.l10n.setAttributes(document.documentElement, "dialog-title");
   },
 
   sanitize() {
     // Update pref values before handing off to the sanitizer (bug 453440)
     this.updatePrefs();
 
     // As the sanitize is async, we disable the buttons, update the label on
     // the 'accept' button to indicate things are happening and return false -