function doAsyncStuff(numAsyncCalls, name) {
  if (numAsyncCalls > 0) {
    curTestIsDone = false;
    asyncTestCase.waitForAsync(
        `doAsyncStuff-${name}` +
        '(' + numAsyncCalls + ')');
    window.setTimeout(() => {
      doAsyncStuff(numAsyncCalls - 1, name);
    }, 0);
  } else {
    curTestIsDone = true;
    asyncTestCase.continueTesting();
  }
}
Uses window.setTimeout() to perform asynchronous behaviour and uses
asyncTestCase.waitForAsync() and asyncTestCase.continueTesting() to mark
the beginning and end of it.
@param {number} numAsyncCalls The number of asynchronous calls to make.
@param {string} name The name of the current step.