summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/webappapis/timers/clearinterval-from-callback.any.js
blob: bf4eb7cf5ac897f0bace75e951c50a08eaa3f03a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
async_test((t) => {
  let wasPreviouslyCalled = false;

  const handle = setInterval(
    t.step_func(() => {
      if (!wasPreviouslyCalled) {
        wasPreviouslyCalled = true;

        clearInterval(handle);

        // Make the test succeed after the callback would've run next.
        setInterval(t.step_func_done(), 750);
      } else {
        assert_unreached();
      }
    }),
    500
  );
}, "Clearing an interval from the callback should still clear it.");