1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5 Copyright (c) 2012 The Chromium Authors. All rights reserved.
6 Use of this source code is governed by a BSD-style license that can be
7 found in the LICENSE file.
10 <META HTTP-EQUIV="Pragma" CONTENT="no-cache" />
11 <META HTTP-EQUIV="Expires" CONTENT="-1" />
12 <script type="text/javascript" src="nacltest.js"></script>
13 <script type="text/javascript" src="ppapi_bad.js"></script>
14 <title>PNaCl Error Handling Test</title>
15 <style type="text/css">
16 .naclModule { background-color: gray; margin: 2px 2px; }
20 <script type="text/javascript">
23 function declareTests(tester) {
24 // 'bad_pexe' loads a manifest, then loads a pexe that is invalid.
29 'application/x-pnacl',
30 'NaCl module load failed: PnaclCoordinator: PNaCl Translator Error: ' +
31 'Invalid PNaCl bitcode header');
33 // 'nonexistent_pexe' loads a manifest, then tries to to load a nonexistent
38 'pnacl_bad_doesnotexist.nmf',
39 'application/x-pnacl',
40 'NaCl module load failed: PnaclCoordinator: ' +
41 'pexe load failed (pp_error=-2).');
43 // 'illformed_manifest' loads a manifest that isn't quite right for pexes
44 // (looks like the format for NaCl portable data files).
48 'pnacl_illformed_manifest.nmf',
49 'application/x-pnacl',
50 'NaCl module load failed: manifest: program property \'portable\' does ' +
51 'not have required key: \'pnacl-translate\'.');
53 // 'wrong_mimetype' loads an okay manifest, but with the wrong mimetype
54 // (the NaCl mimetype instead of PNaCl mimetype).
60 'NaCl module load failed: manifest: PNaCl-like NMF with ' +
61 'application/x-nacl mimetype instead of x-pnacl mimetype ' +
62 '(has pnacl-translate).');
65 // Test that when a surfaway causes the plugin to be destroyed, the PnaclHost
66 // receives a TranslationFinished message and clears its state so subsequent
67 // translations do not get blocked.
68 function surfawayTest(tester) {
69 tester.addAsyncTest('surfaway', function(test) {
70 var progress_event_count = 0;
71 var module = createModule('surfaway', 'simple.nmf', 'application/x-pnacl');
73 progress_event_count += 1;
74 if (progress_event_count < 2) {
75 // The first 'progress' event indicates that we read the manifest and
76 // got a nexe URL. The actual translation has not started until the
77 // second event. On the first call, just re-hook to catch the next event
78 test.expectEvent(module, 'progress', f);
80 // Removing the embed will shutdown the plugin, and adding it will
81 // re-create it and start a new translation
86 test.expectEvent(module, 'progress', f);
87 test.expectEvent(module, 'load', function(e) {
88 test.assertEqual(progress_event_count, 2);
96 // The driver invoked when the body has finished loading.
98 var tester = new Tester($('body'));
99 tester.loadErrorsAreOK();
100 declareTests(tester);
101 surfawayTest(tester);
107 <!-- The tests will create and remove embeds from this div. -->
108 <div id="embeds"></div>
110 <script type="text/javascript">