- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / test / data / nacl / exit_status / pm_exit_status_test.html
1 <!--
2   Copyright (c) 2011 The Chromium Authors. All rights reserved.
3   Use of this source code is governed by a BSD-style license that can
4   be found in the LICENSE file.
5 -->
6 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
7   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
8 <html>
9   <head>
10     <meta http-equiv="Pragma" content="no-cache" />
11     <meta http-equiv="Expires" content="-1" />
12     <script type="text/javascript" src="nacltest.js"></script>
13     <title>Native Client Exit Status Test</title>
14   </head>
15
16   <body>
17     <h1>Native Client Exit Status Test</h1>
18
19   <script type="text/javascript">
20     //<![CDATA[
21 function createModule(id, src, type) {
22   return createNaClEmbed({
23     id: id,
24     src: src,
25     width: 400,
26     height: 400,
27     type: type
28   });
29 }
30
31 var mime = "application/x-nacl";
32 if (getTestArguments()["pnacl"] !== undefined) {
33   mime = "application/x-pnacl";
34 }
35 var embed = createModule("naclModule", "pm_exit_status_test.nmf", mime);
36 embed.basic_tests = "2";
37 embed.stress_tests = "0";
38 document.body.appendChild(embed);
39
40 var tester = new Tester($('body'));
41 var args = getTestArguments({'expected_exit' :
42   'THIS TEST CANNOT RUN STANDALONE -- run using scons instead'});
43
44 function setupTests(tester, plugin) {
45   tester.addAsyncTest('StartTest', function(status) {
46     plugin.addEventListener('message', status.wrap(function(message_event) {
47       this.removeEventListener('message', arguments.callee, false);
48       status.assertEqual(message_event.data,
49                          'hello world');
50       status.pass();
51     }), true);
52     plugin.postMessage('init');
53   });
54   tester.addAsyncTest('Exit0Test', function(status) {
55     plugin.addEventListener('crash', status.wrap(function(crash_event) {
56       this.removeEventListener('crash', arguments.callee, false);
57       status.assertEqual($('naclModule').exitStatus,
58                          parseInt(args.expected_exit));
59       status.pass();
60     }), true);
61     plugin.postMessage(args.trigger);
62   });
63 }
64
65 var tester = new Tester();
66 setupTests(tester, $('naclModule'));
67 tester.waitFor($('naclModule'));
68 tester.run();
69 // otherwise trivially passes
70     //]]>
71   </script>
72   </body>
73 </html>