• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright (c) 2013 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5function addTests() {
6  function getNaClTimeMs() {
7    return parseFloat(document.getElementById('NaCl').textContent);
8  }
9
10  function getRoundTimeMs() {
11    return parseFloat(document.getElementById('Round').textContent);
12  }
13
14  function getTotalTimeMs() {
15    return parseFloat(document.getElementById('Total').textContent);
16  }
17
18  function delayTest(test, delayMs) {
19    test.log('Setting delay to ' + delayMs + 'ms');
20    document.getElementById('delay').value = delayMs;
21
22    test.log('Clicking start.');
23    var startEl = document.getElementById('start');
24    startEl.dispatchEvent(new CustomEvent('click'));
25
26    test.log('Waiting 1 second for test to finish.');
27    var intervalId = window.setInterval(function() {
28      if (itrCount !== itrMax) {
29        test.log('Not finished, waiting another second.');
30        return;
31      }
32
33      window.clearInterval(intervalId);
34      test.log('NaCl time: ' + getNaClTimeMs().toFixed(2) + 'ms');
35      test.log('Roundtrip time: ' + getRoundTimeMs().toFixed(2) + 'ms');
36      test.log('Total time: ' + getTotalTimeMs().toFixed(2) + 'ms');
37      test.log('Finished.');
38      test.pass();
39    }, 1000);
40  }
41
42  common.tester.addAsyncTest('delay_0', function(test) {
43    var delayMs = 0;
44    delayTest(test, delayMs);
45  });
46
47  common.tester.addAsyncTest('delay_3', function(test) {
48    var delayMs = 3;
49    delayTest(test, delayMs);
50  });
51}
52