summaryrefslogtreecommitdiffstats
path: root/chrome/test/data/nacl/exit_status/pm_exit_status_test.html
blob: 323267711b4fef25be24a85ada66efb63c133877 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!--
  Copyright (c) 2011 The Chromium Authors. All rights reserved.
  Use of this source code is governed by a BSD-style license that can
  be found in the LICENSE file.
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Expires" content="-1" />
    <script type="text/javascript" src="nacltest.js"></script>
    <title>Native Client Exit Status Test</title>
  </head>

  <body>
    <h1>Native Client Exit Status Test</h1>

  <script type="text/javascript">
    //<![CDATA[
function createModule(id, src, type) {
  return createNaClEmbed({
    id: id,
    src: src,
    width: 400,
    height: 400,
    type: type
  });
}

var mime = "application/x-nacl";
if (getTestArguments()["pnacl"] !== undefined) {
  mime = "application/x-pnacl";
}
var embed = createModule("naclModule", "pm_exit_status_test.nmf", mime);
embed.basic_tests = "2";
embed.stress_tests = "0";
document.body.appendChild(embed);

var tester = new Tester($('body'));
var args = getTestArguments({'expected_exit' :
  'THIS TEST CANNOT RUN STANDALONE -- run using scons instead'});

function setupTests(tester, plugin) {
  tester.addAsyncTest('StartTest', function(status) {
    plugin.addEventListener('message', status.wrap(function(message_event) {
      this.removeEventListener('message', arguments.callee, false);
      status.assertEqual(message_event.data,
                         'hello world');
      status.pass();
    }), true);
    plugin.postMessage('init');
  });
  tester.addAsyncTest('Exit0Test', function(status) {
    plugin.addEventListener('crash', status.wrap(function(crash_event) {
      this.removeEventListener('crash', arguments.callee, false);
      status.assertEqual($('naclModule').exitStatus,
                         parseInt(args.expected_exit));
      status.pass();
    }), true);
    plugin.postMessage(args.trigger);
  });
}

var tester = new Tester();
setupTests(tester, $('naclModule'));
tester.waitFor($('naclModule'));
tester.run();
// otherwise trivially passes
    //]]>
  </script>
  </body>
</html>