<commit_before><html>
<body onload="test()">
<div id="result">
<p>
This tests that the chromium.Interval functionality works correctly.
</p>
</div>
<script>
if (window.layoutTestController) {
  layoutTestController.dumpAsText();
}

var resultDiv = document.getElementById("result");

function check(name, passed) {
  if (passed) {
    resultDiv.innerHTML += "PASS - " + name + "<br>";
  } else {
    resultDiv.innerHTML += "FAIL - " + name + "<br>";
  }
}

// Spin loop for a short time
function pause(millisecs) {
  var start = new Date();
  while ((new Date() - start) < millisecs);
}


function test() {
  var interval = new chromium.Interval();

  // Verify initialization.
  check("initial zero", interval.microseconds() == 0);

  // Verify that starting the timer works.
  interval.start();
  pause(500);
  check("start", interval.microseconds() >= 500000);

  // Verify that restarting the interval should reset the beginning time
  interval.start();
  pause(1);
  check("restart", interval.microseconds() > 0 && interval.microseconds() < 500000);

  // Verify that calling stop() before start() has no effect.
  var interval = new chromium.Interval();
  interval.stop();
  check("initial stop", interval.microseconds() == 0);

  // Verify a start/stop sequence.
  interval.start();
  pause(50);
  interval.stop();
  var ms = interval.microseconds();
  check("stop", ms > 0 && ms < 1000000);

  // Verify that the timer is really stopped.
  check("stopped", ms == interval.microseconds());

  // Verify that re-stopping the timer works.
  pause(50);
  interval.stop();
  check("re-stopped", interval.microseconds() > ms);<commit_msg>Increase the pause() for the re-stopped portion of the interval test to try to prevent timer races. Add debugging information to the check() to see what values the timer is actually returning.<commit_after><html>
<body onload="test()">
<div id="result">
<p>
This tests that the chromium.Interval functionality works correctly.
</p>
</div>
<script>
if (window.layoutTestController) {
  layoutTestController.dumpAsText();
}

var resultDiv = document.getElementById("result");

function check(name, passed, debug_output) {
  if (passed) {
    resultDiv.innerHTML += "PASS - " + name + "<br>";
  } else {
    resultDiv.innerHTML += "FAIL - " + name + ", debug_output: " + debug_output + "<br>";
  }
}

// Spin loop for a short time
function pause(millisecs) {
  var start = new Date();
  while ((new Date() - start) < millisecs);
}


function test() {
  var interval = new chromium.Interval();

  // Verify initialization.
  var ms = interval.microseconds();
  check("initial zero", ms == 0, "[ms: " + ms + "]");

  // Verify that starting the timer works.
  interval.start();
  pause(500);
  ms = interval.microseconds();
  check("start", ms >= 500000, "[ms: " + ms + "]");

  // Verify that restarting the interval should reset the beginning time
  interval.start();
  pause(1);
  ms = interval.microseconds();
  check("restart", ms > 0 && ms < 500000, "[ms: " + ms + "]");

  // Verify that calling stop() before start() has no effect.
  var interval = new chromium.Interval();
  interval.stop();
  ms = interval.microseconds();
  check("initial stop", ms == 0, "[ms: " + ms + "]");

  // Verify a start/stop sequence.
  interval.start();
  pause(50);
  interval.stop();
  ms = interval.microseconds();
  check("stop", ms > 0 && ms < 1000000, "[ms: " + ms + "]");

  // Verify that the timer is really stopped.
  var ms2 = interval.microseconds();
  check("stopped", ms == ms2, "[ms: " + ms + "]" + "[ms2: " + ms2 + "]");

  // Verify that re-stopping the timer works.
  pause(500);
  interval.stop();
  ms2 = interval.microseconds();
  check("re-stopped", ms2 > ms, "[ms: " + ms + "]" + "[ms2: " + ms2 + "]");
{'fraction_non_alphanumeric': 0.16991197652707388, 'fraction_numerical': 0.018938383568951722, 'mean_word_length': 3.722921914357683, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4044390', 'n_tokens_mistral': 1242, 'n_tokens_neox': 1153, 'n_words': 360}