{"size": 1687, "ext": "js", "max_stars_repo_path": "B2G/gecko/dom/tests/js/timer.js", "max_stars_repo_name": "wilebeast/FireFox-OS", "max_stars_repo_stars_event_min_datetime": "2015-08-31T15:24:31.000Z", "max_stars_repo_stars_event_max_datetime": "2020-04-24T20:31:29.000Z", "max_issues_repo_path": "B2G/gecko/dom/tests/js/timer.js", "max_issues_repo_name": "wilebeast/FireFox-OS", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "B2G/gecko/dom/tests/js/timer.js", "max_forks_repo_name": "wilebeast/FireFox-OS", "max_forks_repo_forks_event_min_datetime": "2015-07-29T07:17:15.000Z", "max_forks_repo_forks_event_max_datetime": "2020-11-04T06:55:37.000Z"}
{"max_stars_count": 3, "max_issues_count": null, "max_forks_count": 3, "avg_line_length": 23.7605633803, "max_line_length": 94, "alphanum_fraction": 0.630112626}

function oneShot(testNum, str)
{
  dump("Test #" + testNum + " successful:" + str + "\n");
}

setTimeout(oneShot, 1000, 1, "one shot timer with function argument");
setTimeout("oneShot(2, 'one shot timer with string argument');", 2000);

function reschedule(testNum, numTimes)
{
  if (numTimes == 4) { 
    dump("Test #" + testNum + " successful: Creating a timeout in a timeout\n");
    kickoff4();
  }
  else {
    dump("Test #" + testNum + " in progress: " + numTimes + "\n");
    setTimeout(reschedule, 500, 3, numTimes+1);
  }
}

setTimeout(reschedule, 3000, 3, 0); 

var count = 0;
var repeat_timer = null;
function repeat(testNum, numTimes, str, func, delay)
{
  dump("Test #" + testNum + " in progress: interval delayed by " + delay + " milliseconds\n");
  if (count++ > numTimes) {
    clearInterval(repeat_timer);
    dump("Test #" + testNum + " successful: " + str + "\n");
    if (func != null) {
      func();
    }
  }
}

function kickoff4()
{
  repeat_timer = setInterval(repeat, 500, 4, 5, "interval test", kickoff5);
}

//setTimeout(kickoff4, 5000);

function oneShot2(testNum)
{
  dump("Test #" + testNum + " in progress: one shot timer\n");
  if (count++ == 4) {
    dump("Test #" + testNum + " in progress: end of one shots\n");
  }
  else {
    setTimeout(oneShot2, 500, 5);
  }
}

function kickoff5()
{
  count = 0;
  setTimeout(oneShot2, 500, 5);
  repeat_timer = setInterval("repeat(5, 8, 'multiple timer test', kickoff6)", 600);
}

//setTimeout(kickoff5, 12000);

function kickoff6()
{
  dump("Test #6: Interval timeout should end when you go to a new page\n");
  setInterval(repeat, 1000, 6, 1000, "endless timer test", null);
}

//setTimeout(kickoff6, 18000);