cc: Added inline to Tile::IsReadyToDraw
[chromium-blink-merge.git] / ppapi / native_client / tests / nacl_browser / inbrowser_test_runner / test_runner.html
blobe3220b32c30ba84785a798a94f9a4ef6af6358fc
1 <!DOCTYPE html>
2 <!--
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
5 found in the LICENSE file.
6 -->
7 <html>
8 <head>
9 <title>
10 NativeClient browser test runner
11 </title>
12 <script type="text/javascript" src="nacltest.js"></script>
13 <script type="text/javascript" src="nmf_test_list.js"></script>
14 </head>
15 <body>
17 <div id="scratch_space"></div>
19 <div id="load_warning">
20 Javascript has failed to load.
21 </div>
23 <script type="text/javascript">
25 function addTest(tester, url) {
26 tester.addAsyncTest(url, function(status) {
27 var embed = document.createElement('embed');
28 embed.width = 0;
29 embed.height = 0;
30 embed.src = url;
31 embed.type = 'application/x-nacl';
32 embed.name = 'foo';
34 // Webkit Bug Workaround
35 // THIS SHOULD BE REMOVED WHEN Webkit IS FIXED
36 // http://code.google.com/p/nativeclient/issues/detail?id=2428
37 // http://code.google.com/p/chromium/issues/detail?id=103588
38 ForcePluginLoadOnTimeout(embed, tester, 15000);
40 var div = document.createElement('div');
41 div.appendChild(embed);
43 var cleanup = function() {
44 document.getElementById('scratch_space').removeChild(div);
47 // This is the prefix prepended by NaCl's unofficial
48 // "dev://postmessage" feature.
49 var stdout_prefix = 'DEBUG_POSTMESSAGE:';
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 = [];
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]();
64 end_of_log_callbacks = [];
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);
83 // Set up an event listener for success messages.
84 div.addEventListener('message', status.wrap(function(message_event) {
85 if (message_event.data.substr(0, stdout_prefix.length) == stdout_prefix) {
86 var msg = message_event.data.substr(stdout_prefix.length);
87 if (msg == '\nEND_OF_LOG\n') {
88 runEndOfLogCallbacks();
89 } else {
90 status.log(msg.replace(/\n/g, '\\n'));
92 } else {
93 callAtEndOfLog(function() {
94 status.assertEqual(message_event.data, 'passed');
95 cleanup();
96 status.pass();
97 });
99 }), true);
101 // Wait for the load event, which indicates successful loading.
102 div.addEventListener('load', status.wrap(function(e) {
103 status.log('Loaded ' + embed.src);
104 // Start tests in the module.
105 embed.postMessage('run_tests');
106 }), true);
108 var onError = status.wrap(function(e) {
109 callAtEndOfLog(function() {
110 cleanup();
111 status.fail(embed.lastError);
115 div.addEventListener('error', onError, true);
116 div.addEventListener('crash', onError, true);
118 // Insert div into the DOM. This starts the load of the nacl plugin, etc.
119 document.getElementById('scratch_space').appendChild(div);
123 // Remove the "failed to load" message.
124 document.getElementById('load_warning').innerHTML = '';
126 var tester = new Tester();
127 for (var i = 0; i < G_NMF_TEST_LIST.length; i++) {
128 addTest(tester, G_NMF_TEST_LIST[i]);
131 var args = getTestArguments({'parallel': '0'});
133 if (parseInt(args['parallel'])) {
134 tester.runParallel();
135 } else {
136 tester.run();
139 </script>
140 </body>
141 </html>