testing/mochitest/tests/browser/browser_add_task.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/testing/mochitest/tests/browser/browser_add_task.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,31 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +"use strict";
     1.8 +
     1.9 +let test1Complete = false;
    1.10 +let test2Complete = false;
    1.11 +
    1.12 +function executeWithTimeout() {
    1.13 +  let deferred = Promise.defer();
    1.14 +  executeSoon(function() {
    1.15 +    ok(true, "we get here after a timeout");
    1.16 +    deferred.resolve();
    1.17 +  });
    1.18 +  return deferred.promise;
    1.19 +}
    1.20 +
    1.21 +add_task(function asyncTest_no1() {
    1.22 +  yield executeWithTimeout();
    1.23 +  test1Complete = true;
    1.24 +});
    1.25 +
    1.26 +add_task(function asyncTest_no2() {
    1.27 +  yield executeWithTimeout();
    1.28 +  test2Complete = true;
    1.29 +});
    1.30 +
    1.31 +add_task(function() {
    1.32 +  ok(test1Complete, "We have been through test 1");
    1.33 +  ok(test2Complete, "We have been through test 2");
    1.34 +});

mercurial