toolkit/content/tests/widgets/head.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 "use strict";
     3 function waitForCondition(condition, nextTest, errorMsg) {
     4   var tries = 0;
     5   var interval = setInterval(function() {
     6     if (tries >= 30) {
     7       ok(false, errorMsg);
     8       moveOn();
     9     }
    10     var conditionPassed;
    11     try {
    12       conditionPassed = condition();
    13     } catch (e) {
    14       ok(false, e + "\n" + e.stack);
    15       conditionPassed = false;
    16     }
    17     if (conditionPassed) {
    18       moveOn();
    19     }
    20     tries++;
    21   }, 100);
    22   var moveOn = function() { clearInterval(interval); nextTest(); };
    23 }

mercurial