OLD | NEW |
| (Empty) |
1 <!-- | |
2 Copyright 2013 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 I/O Redirection to Post Message Test</title> | |
14 </head> | |
15 | |
16 <body> | |
17 <h1>Native Client I/O Redirection to Post Message Test</h1> | |
18 <div> | |
19 | |
20 <script type="text/javascript"> | |
21 //<![CDATA[ | |
22 function createModule(id, src, type) { | |
23 return createNaClEmbed({ | |
24 id: id, | |
25 src: src, | |
26 width: 400, | |
27 height: 400, | |
28 type: type | |
29 }); | |
30 } | |
31 | |
32 var mime = 'application/x-nacl'; | |
33 if (getTestArguments()['pnacl'] !== undefined) { | |
34 mime = 'application/x-pnacl'; | |
35 } | |
36 var embed = createModule('naclModule', 'pm_redir_test.nmf', mime); | |
37 embed.basic_tests ='2'; | |
38 embed.stress_tests = '0'; | |
39 document.body.appendChild(embed); | |
40 | |
41 function setupTests(tester, plugin) { | |
42 tester.addAsyncTest('Test_output', function(status) { | |
43 plugin.addEventListener('message', function(message_event) { | |
44 var prefix = 'DEBUG_POSTMESSAGE:'; | |
45 if (message_event.data.indexOf(prefix) == 0) { | |
46 var expected_output = 'BOGUS STRING'; | |
47 if (args.stream == 'stdout' && args.thread == 'fg') { | |
48 expected_output = | |
49 ('In the year 1878 I took my degree of Doctor of Medicine...\n'); | |
50 } else if (args.stream == 'stderr' && args.thread == 'fg') { | |
51 expected_output = | |
52 ('A merry little surge of electricity piped by automatic' | |
53 +' alarm...\n'); | |
54 } else if (args.stream == 'stdout' && args.thread == 'bg') { | |
55 expected_output = | |
56 ('Squire Trelawney, Dr. Livesey, and the rest of these' | |
57 +' gentlemen...\n'); | |
58 } else if (args.stream == 'stderr' && args.thread == 'bg') { | |
59 expected_output = | |
60 ('It is a truth universally acknowledged, that a single man' | |
61 +' in possession...\n'); | |
62 } | |
63 var msg_string = message_event.data.substring(prefix.length); | |
64 console.log('expected output ' + expected_output); | |
65 | |
66 console.log(msg_string); | |
67 if (msg_string == expected_output) { | |
68 console.log('pass!'); | |
69 this.removeEventListener('message', arguments.callee, true); | |
70 status.pass(); | |
71 } else { | |
72 // comment this out if test framework args=['--debug'] is | |
73 // used, since that causes lots of SRPC and PPAPI_PROXY | |
74 // debug output to be generated on stdout/err, and the test | |
75 // has no debugging output | |
76 // | |
77 status.fail('unexpected output: ' + msg_string); | |
78 } | |
79 } | |
80 }, true); | |
81 message=('stream=' + args.stream + ',thread=' + args.thread + | |
82 ',delay_us=' + args.delay_us); | |
83 console.log(message); | |
84 plugin.postMessage(message); | |
85 }); | |
86 } | |
87 | |
88 var tester = new Tester(); | |
89 var args = getTestArguments({ | |
90 'stream' : 'THIS TEST CANNOT RUN STANDALONE -- run using scons instead', | |
91 'thread' : 'THIS TEST CANNOT RUN STANDALONE -- run using scons instead', | |
92 }); | |
93 setupTests(tester, $('naclModule')); | |
94 tester.waitFor($('naclModule')); | |
95 tester.run(); | |
96 //]]> | |
97 </script> | |
98 </body> | |
99 </html> | |
OLD | NEW |