• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1function timeout_trampoline(t, timeout, message) {
2  t.step_timeout(function() {
3    // Yield in case we managed to be called before the second interval callback.
4    t.step_timeout(function() {
5      assert_unreached(message);
6    }, timeout);
7  }, timeout);
8}
9
10async_test(function(t) {
11  let ctr = 0;
12  let h = setInterval(t.step_func(function() {
13    if (++ctr == 2) {
14      clearInterval(h);
15      t.done();
16      return;
17    }
18  }) /* no interval */);
19
20  timeout_trampoline(t, 100, "Expected setInterval callback to be called two times");
21}, "Calling setInterval with no interval should be the same as if called with 0 interval");
22
23async_test(function(t) {
24  let ctr = 0;
25  let h = setInterval(t.step_func(function() {
26    if (++ctr == 2) {
27      clearInterval(h);
28      t.done();
29      return;
30    }
31  }),  undefined);
32
33  timeout_trampoline(t, 100, "Expected setInterval callback to be called two times");
34}, "Calling setInterval with undefined interval should be the same as if called with 0 interval");
35