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.
6 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
7 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
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>
17 <h1>Native Client I/O Redirection to Post Message Test
</h1>
20 <script type=
"text/javascript">
22 function createModule(id
, src
, type
) {
23 return createNaClEmbed({
32 var mime
= 'application/x-nacl';
33 if (getTestArguments()['pnacl'] !== undefined) {
34 mime
= 'application/x-pnacl';
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
);
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') {
49 ('In the year 1878 I took my degree of Doctor of Medicine...\n');
50 } else if (args
.stream
== 'stderr' && args
.thread
== 'fg') {
52 ('A merry little surge of electricity piped by automatic'
54 } else if (args
.stream
== 'stdout' && args
.thread
== 'bg') {
56 ('Squire Trelawney, Dr. Livesey, and the rest of these'
58 } else if (args
.stream
== 'stderr' && args
.thread
== 'bg') {
60 ('It is a truth universally acknowledged, that a single man'
61 +' in possession...\n');
63 var msg_string
= message_event
.data
.substring(prefix
.length
);
64 console
.log('expected output ' + expected_output
);
66 console
.log(msg_string
);
67 if (msg_string
== expected_output
) {
69 this.removeEventListener('message', arguments
.callee
, true);
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
77 status
.fail('unexpected output: ' + msg_string
);
81 message
=('stream=' + args
.stream
+ ',thread=' + args
.thread
+
82 ',delay_us=' + args
.delay_us
);
84 plugin
.postMessage(message
);
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',
93 setupTests(tester
, $('naclModule'));
94 tester
.waitFor($('naclModule'));