Bug 942520 - Fix intermittent browser_sanitizeDialog.js failures by accounting for async Sanitizer window initialization r=mak
authorTim Taubert <ttaubert@mozilla.com>
Tue, 23 Jun 2015 15:15:31 -0700
changeset 250179 56b6a6eca59ac61cc863099f7407de007c23823d
parent 250178 8d99fb177495bb0224002941d30db435031f3ec9
child 250180 f26ddcd80269b3632d0fa646161a30bbacf6e3e7
push id61471
push usercbook@mozilla.com
push dateThu, 25 Jun 2015 09:33:34 +0000
treeherdermozilla-inbound@5b38df79819f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs942520
milestone41.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 942520 - Fix intermittent browser_sanitizeDialog.js failures by accounting for async Sanitizer window initialization r=mak
browser/base/content/test/general/browser_sanitizeDialog.js
--- a/browser/base/content/test/general/browser_sanitizeDialog.js
+++ b/browser/base/content/test/general/browser_sanitizeDialog.js
@@ -397,27 +397,32 @@ var gAllTests = [
                  "formdata pref should be true after accepting dialog with " +
                  "formdata checkbox checked");
 
 
       // Even though the formdata pref is true, because there is no history
       // left to clear, the checkbox will be disabled.
       var cb = this.win.document.querySelectorAll(
                  "#itemList > [preference='privacy.cpd.formdata']");
-      ok(cb.length == 1 && cb[0].disabled && !cb[0].checked,
-         "There is no formdata history, checkbox should be disabled and be " +
-         "cleared to reduce user confusion (bug 497664).");
+
+      // Wait until the checkbox is disabled. This is done asynchronously
+      // from Sanitizer.init() as FormHistory.count() is a purely async API.
+      promiseWaitForCondition(() => cb[0].disabled).then(() => {
+        ok(cb.length == 1 && cb[0].disabled && !cb[0].checked,
+           "There is no formdata history, checkbox should be disabled and be " +
+           "cleared to reduce user confusion (bug 497664).");
 
-      var cb = this.win.document.querySelectorAll(
-                 "#itemList > [preference='privacy.cpd.history']");
-      ok(cb.length == 1 && !cb[0].disabled && cb[0].checked,
-         "There is no history, but history checkbox should always be enabled " +
-         "and will be checked from previous preference.");
+        cb = this.win.document.querySelectorAll(
+                   "#itemList > [preference='privacy.cpd.history']");
+        ok(cb.length == 1 && !cb[0].disabled && cb[0].checked,
+           "There is no history, but history checkbox should always be enabled " +
+           "and will be checked from previous preference.");
 
-      this.acceptDialog();
+        this.acceptDialog();
+      });
     }
     wh.open();
   },
 
   /**
    * Add form history entry for the next test.
    */
   function () {