- add sources.
[platform/framework/web/crosswalk.git] / src / ppapi / native_client / tests / breakpad_crash_test / trusted_crash_in_startup.html
1 <!--
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.
5 -->
6
7 <script type="text/javascript" src="nacltest.js"></script>
8
9 <div id="scratch_space"></div>
10
11 <script type="text/javascript">
12
13 var tester = new Tester();
14
15 tester.addAsyncTest('trusted_crash_during_startup', function(status) {
16   var embed = document.createElement('embed');
17   embed.width = 0;
18   embed.height = 0;
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';
24   embed.name = 'foo';
25
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);
31
32   var div = document.createElement('div');
33   div.appendChild(embed);
34
35   div.addEventListener('load', status.wrap(function(event) {
36     status.fail('We expected this process to crash during startup');
37   }), true);
38
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);
49     status.pass();
50   }), true);
51
52   document.getElementById('scratch_space').appendChild(div);
53 });
54
55 tester.run();
56
57 </script>