Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: ppapi/native_client/tests/nacl_browser/inbrowser_test_runner/test_runner.html

Issue 513273003: Drop NaCl support for posting stdout/stderr to JS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Back out documentation changes. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <!-- 2 <!--
3 Copyright (c) 2012 The Chromium Authors. All rights reserved. 3 Copyright (c) 2012 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be 4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file. 5 found in the LICENSE file.
6 --> 6 -->
7 <html> 7 <html>
8 <head> 8 <head>
9 <title> 9 <title>
10 NativeClient browser test runner 10 NativeClient browser test runner
(...skipping 26 matching lines...) Expand all
37 // http://code.google.com/p/chromium/issues/detail?id=103588 37 // http://code.google.com/p/chromium/issues/detail?id=103588
38 ForcePluginLoadOnTimeout(embed, tester, 15000); 38 ForcePluginLoadOnTimeout(embed, tester, 15000);
39 39
40 var div = document.createElement('div'); 40 var div = document.createElement('div');
41 div.appendChild(embed); 41 div.appendChild(embed);
42 42
43 var cleanup = function() { 43 var cleanup = function() {
44 document.getElementById('scratch_space').removeChild(div); 44 document.getElementById('scratch_space').removeChild(div);
45 }; 45 };
46 46
47 // This is the prefix prepended by NaCl's unofficial
48 // "dev://postmessage" feature.
49 var stdout_prefix = 'DEBUG_POSTMESSAGE:';
50
51 // NaCl's "dev://postmessage" feature is unsynchronized, in the
52 // sense that the DEBUG_POSTMESSAGE messages can arrive after the
53 // test result event. As a workaround, we look for an
54 // "END_OF_LOG" string that the nexe prints.
55 var saw_end_of_log = false;
56 var end_of_log_callbacks = [];
57
58 var runEndOfLogCallbacks = function() {
59 if (!saw_end_of_log) {
60 saw_end_of_log = true;
61 for (var i = 0; i < end_of_log_callbacks.length; i++) {
62 end_of_log_callbacks[i]();
63 }
64 end_of_log_callbacks = [];
65 }
66 };
67
68 var callAtEndOfLog = function(func) {
69 if (saw_end_of_log) {
70 func();
71 } else {
72 end_of_log_callbacks.push(func);
73 // If we do not see the end of the log soon, end the test
74 // anyway. This will happen if the nexe crashes or exits.
75 window.setTimeout(status.wrap(function() {
76 status.log('Did not see the END_OF_LOG message after timeout; ' +
77 'continuing anyway');
78 runEndOfLogCallbacks();
79 }), 500);
80 }
81 };
82
83 // Set up an event listener for success messages. 47 // Set up an event listener for success messages.
84 div.addEventListener('message', status.wrap(function(message_event) { 48 div.addEventListener('message', status.wrap(function(message_event) {
85 if (message_event.data.substr(0, stdout_prefix.length) == stdout_prefix) { 49 status.assertEqual(message_event.data, 'passed');
86 var msg = message_event.data.substr(stdout_prefix.length); 50 cleanup();
87 if (msg == '\nEND_OF_LOG\n') { 51 status.pass();
88 runEndOfLogCallbacks();
89 } else {
90 status.log(msg.replace(/\n/g, '\\n'));
91 }
92 } else {
93 callAtEndOfLog(function() {
94 status.assertEqual(message_event.data, 'passed');
95 cleanup();
96 status.pass();
97 });
98 }
99 }), true); 52 }), true);
100 53
101 // Wait for the load event, which indicates successful loading. 54 // Wait for the load event, which indicates successful loading.
102 div.addEventListener('load', status.wrap(function(e) { 55 div.addEventListener('load', status.wrap(function(e) {
103 status.log('Loaded ' + embed.src); 56 status.log('Loaded ' + embed.src);
104 // Start tests in the module. 57 // Start tests in the module.
105 embed.postMessage('run_tests'); 58 embed.postMessage('run_tests');
106 }), true); 59 }), true);
107 60
108 var onError = status.wrap(function(e) { 61 var onError = status.wrap(function(e) {
109 callAtEndOfLog(function() { 62 cleanup();
110 cleanup(); 63 status.fail(embed.lastError);
111 status.fail(embed.lastError);
112 });
113 }); 64 });
114 65
115 div.addEventListener('error', onError, true); 66 div.addEventListener('error', onError, true);
116 div.addEventListener('crash', onError, true); 67 div.addEventListener('crash', onError, true);
117 68
118 // Insert div into the DOM. This starts the load of the nacl plugin, etc. 69 // Insert div into the DOM. This starts the load of the nacl plugin, etc.
119 document.getElementById('scratch_space').appendChild(div); 70 document.getElementById('scratch_space').appendChild(div);
120 }); 71 });
121 } 72 }
122 73
123 // Remove the "failed to load" message. 74 // Remove the "failed to load" message.
124 document.getElementById('load_warning').innerHTML = ''; 75 document.getElementById('load_warning').innerHTML = '';
125 76
126 var tester = new Tester(); 77 var tester = new Tester();
127 for (var i = 0; i < G_NMF_TEST_LIST.length; i++) { 78 for (var i = 0; i < G_NMF_TEST_LIST.length; i++) {
128 addTest(tester, G_NMF_TEST_LIST[i]); 79 addTest(tester, G_NMF_TEST_LIST[i]);
129 } 80 }
130 81
131 var args = getTestArguments({'parallel': '0'}); 82 var args = getTestArguments({'parallel': '0'});
132 83
133 if (parseInt(args['parallel'])) { 84 if (parseInt(args['parallel'])) {
134 tester.runParallel(); 85 tester.runParallel();
135 } else { 86 } else {
136 tester.run(); 87 tester.run();
137 } 88 }
138 89
139 </script> 90 </script>
140 </body> 91 </body>
141 </html> 92 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698