2 Copyright 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.
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>
19 <embed id=
"naclModule"
22 src=
"pm_redir_test.nmf"
25 style=
"background-color:gray"
26 type=
"application/x-nacl" />
29 <script type=
"text/javascript">
31 function setupTests(tester
, plugin
) {
32 tester
.addAsyncTest('Test_output', function(status
) {
33 plugin
.addEventListener('message', function(message_event
) {
34 var prefix
= 'DEBUG_POSTMESSAGE:';
35 if (message_event
.data
.indexOf(prefix
) == 0) {
36 var expected_output
= 'BOGUS STRING';
37 if (args
.stream
== 'stdout' && args
.thread
== 'fg') {
39 ('In the year 1878 I took my degree of Doctor of Medicine...\n');
40 } else if (args
.stream
== 'stderr' && args
.thread
== 'fg') {
42 ('A merry little surge of electricity piped by automatic'
44 } else if (args
.stream
== 'stdout' && args
.thread
== 'bg') {
46 ('Squire Trelawney, Dr. Livesey, and the rest of these'
48 } else if (args
.stream
== 'stderr' && args
.thread
== 'bg') {
50 ('It is a truth universally acknowledged, that a single man'
51 +' in possession...\n');
53 var msg_string
= message_event
.data
.substring(prefix
.length
);
54 console
.log('expected output ' + expected_output
);
56 console
.log(msg_string
);
57 if (msg_string
== expected_output
) {
59 this.removeEventListener('message', arguments
.callee
, true);
62 // comment this out if test framework args=['--debug'] is
63 // used, since that causes lots of SRPC and PPAPI_PROXY
64 // debug output to be generated on stdout/err, and the test
65 // has no debugging output
67 status
.fail('unexpected output: ' + msg_string
);
71 message
=('stream=' + args
.stream
+ ',thread=' + args
.thread
+
72 ',delay_us=' + args
.delay_us
);
74 plugin
.postMessage(message
);
78 var tester
= new Tester();
79 var args
= getTestArguments({
80 'stream' : 'THIS TEST CANNOT RUN STANDALONE -- run using scons instead',
81 'thread' : 'THIS TEST CANNOT RUN STANDALONE -- run using scons instead',
83 setupTests(tester
, $('naclModule'));
84 tester
.waitFor($('naclModule'));