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.
10 NativeClient browser test runner
12 <script type=
"text/javascript" src=
"nacltest.js"></script>
13 <script type=
"text/javascript" src=
"nmf_test_list.js"></script>
17 <div id=
"scratch_space"></div>
19 <div id=
"load_warning">
20 Javascript has failed to load.
23 <script type=
"text/javascript">
25 function addTest(tester
, url
) {
26 tester
.addAsyncTest(url
, function(status
) {
27 var embed
= document
.createElement('embed');
31 embed
.type
= 'application/x-nacl';
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 // Set up an event listener for success messages.
48 div
.addEventListener('message', status
.wrap(function(message_event
) {
49 status
.assertEqual(message_event
.data
, 'passed');
54 // Wait for the load event, which indicates successful loading.
55 div
.addEventListener('load', status
.wrap(function(e
) {
56 status
.log('Loaded ' + embed
.src
);
57 // Start tests in the module.
58 embed
.postMessage('run_tests');
61 var onError
= status
.wrap(function(e
) {
63 status
.fail(embed
.lastError
);
66 div
.addEventListener('error', onError
, true);
67 div
.addEventListener('crash', onError
, true);
69 // Insert div into the DOM. This starts the load of the nacl plugin, etc.
70 document
.getElementById('scratch_space').appendChild(div
);
74 // Remove the "failed to load" message.
75 document
.getElementById('load_warning').innerHTML
= '';
77 var tester
= new Tester();
78 for (var i
= 0; i
< G_NMF_TEST_LIST
.length
; i
++) {
79 addTest(tester
, G_NMF_TEST_LIST
[i
]);
82 var args
= getTestArguments({'parallel': '0'});
84 if (parseInt(args
['parallel'])) {