1 // Copyright 2014 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.
5 function moduleDidLoad() {
9 // Add event listeners after the NaCl module has loaded. These listeners will
10 // forward messages to the NaCl module via postMessage()
11 function attachListeners() {
12 setTimeout(function() { common.updateStatus('READY TO RUN'); }, 200);
13 document.getElementById('benchmark').addEventListener('click',
15 common.naclModule.postMessage({'message' : 'run_benchmark'});
16 common.updateStatus('BENCHMARKING... (please wait)');
17 var window = document.getElementById('result').contentWindow;
18 window.document.writeln('<samp>Starting Benchmark Suite<br>');
19 window.document.writeln('<table>');
24 // Handle a message coming from the NaCl module.
25 function handleMessage(message_event) {
26 if (message_event.data.message == 'benchmark_result') {
28 var name = message_event.data.benchmark.name;
29 var result = message_event.data.benchmark.result;
30 var text = '<tr><th>' + name + ': </th><th>' + result + '</th></tr>';
32 var window = document.getElementById('result').contentWindow;
33 window.document.writeln(text);
35 if (message_event.data.message == 'benchmark_finish') {
36 common.updateStatus('READY TO RUN');
37 var window = document.getElementById('result').contentWindow;
38 window.document.writeln('</table>');
39 window.document.writeln('Finished<br><br></samp>');