Bug 942520 - Fix intermittent browser_sanitizeDialog.js failures by accounting for async Sanitizer window initialization. r=mak, a=test-only
authorTim Taubert <ttaubert@mozilla.com>
Tue, 23 Jun 2015 15:15:31 -0700
changeset 275197 f6c40537025b5d72d2e87b00dd491e1818e2b3e3
parent 275196 130ee566deeaa646523f13873ae839bc638c36a8
child 275198 9d730445138d57d0e646eb9813ebc2d2af61ee50
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak, test-only
bugs942520
milestone40.0a2
Bug 942520 - Fix intermittent browser_sanitizeDialog.js failures by accounting for async Sanitizer window initialization. r=mak, a=test-only
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 () {