5 <meta name="google" content="notranslate" />
14 font-family: monospace;
29 <section class="test" id="test-res"></section>
32 if (typeof performance !== 'object') {
34 mark: function(s) { this[s] = new Date() },
35 measure: function(_t, s1, s2) { this.t = this[s2] - this[s1] },
36 getEntriesByName: function() { return [ { duration: this.t } ] }
40 var Module = { preRun: function() { performance.mark('bench_start') } };
42 function runTest(tname) {
43 var xhr, expected, hn, idx = 0, passed = true;
45 function outputReceived(e) {
47 var p = document.createElement('p');
48 if (found !== expected[idx++]) {
52 p.appendChild(document.createTextNode(found));
53 document.getElementById('test-res').appendChild(p);
54 if (idx >= expected.length) {
56 performance.mark('bench_end')
57 performance.measure('bench', 'bench_start', 'bench_end');
58 var duration = Math.round(performance.getEntriesByName('bench')[0].duration);
59 hn.appendChild(document.createTextNode(' - PASSED (time: ' + duration + ' ms)'));
60 hn.className = 'passed';
62 hn.appendChild(document.createTextNode(' - FAILED'));
68 hn = document.getElementsByTagName('h1')[0];
69 hn.appendChild(document.createTextNode('Test: ' + tname));
72 xhr = new ActiveXObject('Microsoft.XMLHTTP');
74 xhr = new XMLHttpRequest();
76 xhr.open('GET', tname + '.exp');
77 xhr.onreadystatechange = function() {
78 if (xhr.readyState != 4 ||
79 (xhr.status != 200 && xhr.status != 302 && xhr.status != 0)) {
82 expected = xhr.responseText.split('\n');
83 if (expected.length > 0 && expected[expected.length - 1] === '') {
86 expected.push('--- SUCCESS ---');
87 window.addEventListener('test-output', outputReceived, false);
88 var s = document.getElementsByTagName('script')[0];
89 var st = document.createElement('script');
90 st.src = tname + '.js';
91 s.parentNode.insertBefore(st, s);