2 Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 Use of this source code is governed by a BSD-style license that can be
4 found in the LICENSE file.
7 <script type=
"text/javascript" src=
"nacltest.js"></script>
9 <div id=
"scratch_space"></div>
11 <script type=
"text/javascript">
13 var tester
= new Tester();
15 tester
.addAsyncTest('trusted_crash_during_startup', function(status
) {
16 var embed
= document
.createElement('embed');
19 // We trigger a crash in trusted code via the NACL_CRASH_TEST env var.
20 // Since the crash occurs during startup, untrusted code does not run,
21 // so the choice of NaCl executable is arbitrary.
22 embed
.src
= 'crash_test.nmf';
23 embed
.type
= 'application/x-nacl';
26 // Webkit Bug Workaround
27 // THIS SHOULD BE REMOVED WHEN Webkit IS FIXED
28 // http://code.google.com/p/nativeclient/issues/detail?id=2428
29 // http://code.google.com/p/chromium/issues/detail?id=103588
30 ForcePluginLoadOnTimeout(embed
, tester
, 15000);
32 var div
= document
.createElement('div');
33 div
.appendChild(embed
);
35 div
.addEventListener('load', status
.wrap(function(event
) {
36 status
.fail('We expected this process to crash during startup');
39 div
.addEventListener('error', status
.wrap(function(event
) {
40 var error
= embed
.lastError
;
41 status
.log('Received error: ' + error
);
42 // This error occurs only because NACL_CRASH_TEST is set. We would
43 // not normally expect to get this error in the browser.
44 var expected_error_prefix
= 'NaCl module load failed: ServiceRuntime: ';
45 var suffix1
= 'command channel creation failed';
46 var suffix2
= 'failed to start';
47 status
.assert(error
== expected_error_prefix
+ suffix1
||
48 error
== expected_error_prefix
+ suffix2
);
52 document
.getElementById('scratch_space').appendChild(div
);