summaryrefslogtreecommitdiffstats
path: root/ppapi/native_client
diff options
context:
space:
mode:
authorksakamoto@chromium.org <ksakamoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-18 01:33:54 +0000
committerksakamoto@chromium.org <ksakamoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-18 01:33:54 +0000
commit45c71343a3e6b19d3b86319f3b52c3d9e239b298 (patch)
tree6e604efeaf323b09c9594396ddb7f2619fa69f09 /ppapi/native_client
parent8fc674ea11b1c4d9662845d6d86ad53c2bbc773e (diff)
downloadchromium_src-45c71343a3e6b19d3b86319f3b52c3d9e239b298.zip
chromium_src-45c71343a3e6b19d3b86319f3b52c3d9e239b298.tar.gz
chromium_src-45c71343a3e6b19d3b86319f3b52c3d9e239b298.tar.bz2
Revert 241424 "Port ppapi_bad test from nacl_integration to brow..."
Broke cros_daisy Build. http://build.chromium.org/p/tryserver.chromium/builders/cros_daisy/builds/3191 > Port ppapi_bad test from nacl_integration to browser_tests. > > PNaCl is not supported because crash throttling interferes with the test. > CORS tests were removed because they were redunant with existing tests and would > have been difficult to port because of how browser_test's http server behaves. > The dynamic loading test was removed because it required a golden file and would > likely never work as a browser_test. > > BUG=154400 > > Review URL: https://codereview.chromium.org/116843002 TBR=ncbray@chromium.org Review URL: https://codereview.chromium.org/109283007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@241441 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/native_client')
-rw-r--r--ppapi/native_client/chrome_main.scons1
-rw-r--r--ppapi/native_client/tests/ppapi_browser/bad/nacl.scons131
-rw-r--r--ppapi/native_client/tests/ppapi_browser/bad/partly_invalid.nmf7
-rw-r--r--ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad.html237
-rw-r--r--ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad.js48
-rw-r--r--ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_crossorigin.nmf7
-rw-r--r--ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_doesnotexist.nmf7
-rw-r--r--ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_event_replay_crash.cc65
-rw-r--r--ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_get_ppp_instance_crash.cc33
-rw-r--r--ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_get_ppp_messaging_crash.cc72
-rw-r--r--ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_get_ppp_printing_crash.cc72
-rw-r--r--ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_magic.nmf7
-rw-r--r--ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_manifest_bad_files.nmf12
-rw-r--r--ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_manifest_nexe_arch.nmf5
-rw-r--r--ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_manifest_uses_nexes.nmf7
-rw-r--r--ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_native.html50
-rw-r--r--ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_native_glibc.html37
-rw-r--r--ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_native_glibc.stderr1
-rw-r--r--ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_no_ppp_instance.cc39
-rw-r--r--ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_ppp_initialize.cc30
-rw-r--r--ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_ppp_initialize_crash.cc72
-rw-r--r--ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_ppp_instance_didcreate.cc69
-rw-r--r--ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_ppp_instance_didcreate_crash.cc60
23 files changed, 1069 insertions, 0 deletions
diff --git a/ppapi/native_client/chrome_main.scons b/ppapi/native_client/chrome_main.scons
index c43b9a1..e8593a4 100644
--- a/ppapi/native_client/chrome_main.scons
+++ b/ppapi/native_client/chrome_main.scons
@@ -39,6 +39,7 @@ ppapi_scons_files['nonvariant_test_scons_files'] = [
'tests/nacl_browser/browser_dynamic_library/nacl.scons',
'tests/nacl_browser/manifest_file/nacl.scons',
'tests/nacl_browser/nameservice/nacl.scons',
+ 'tests/ppapi_browser/bad/nacl.scons',
'tests/ppapi_browser/extension_mime_handler/nacl.scons',
'tests/ppapi_browser/manifest/nacl.scons',
'tests/ppapi_test_lib/nacl.scons',
diff --git a/ppapi/native_client/tests/ppapi_browser/bad/nacl.scons b/ppapi/native_client/tests/ppapi_browser/bad/nacl.scons
new file mode 100644
index 0000000..28eeb4a
--- /dev/null
+++ b/ppapi/native_client/tests/ppapi_browser/bad/nacl.scons
@@ -0,0 +1,131 @@
+# -*- python -*-
+# Copyright (c) 2012 The Native Client Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+#
+# Tests fatal errors that occur during loading.
+# (See ppapi_browser/crash for fatal errors that occur after loading).
+# TODO(polina): rename the directory and browser test to bad_load
+#
+# Manual testing with localhost:5103/scons-out/.../staging/ppapi_bad.html:
+# scons --mode=nacl ppapi_bad
+# Automatic testing:
+# scons run_ppapi_bad_browser_test
+#
+
+Import('env')
+
+# TODO(robertm): those should not be necessary once we go -std=c99
+env.FilterOut(CFLAGS=['-pedantic'])
+env.FilterOut(CCFLAGS=['-pedantic'])
+env.Replace(TEST_DIR='${SOURCE_ROOT}/ppapi/native_client/tests/ppapi_browser/' +
+ 'bad')
+
+ppapi_bad_files = [
+ 'ppapi_bad.html',
+ 'ppapi_bad.js',
+ 'ppapi_bad_crossorigin.nmf',
+ 'ppapi_bad_doesnotexist.nmf',
+ 'ppapi_bad_magic.nmf',
+ 'ppapi_bad_manifest_uses_nexes.nmf',
+ 'ppapi_bad_manifest_bad_files.nmf',
+ 'ppapi_bad_manifest_nexe_arch.nmf',
+ env.File('${SCONSTRUCT_DIR}/tools/browser_tester/browserdata/nacltest.js')
+ ]
+ppapi_bad = env.Replicate('${STAGING_DIR}', ppapi_bad_files)
+
+nmf_names = []
+# Compile all nexes embedded into the above html
+# TODO(bbudge) Re-enable tests as the IPC proxy gets equivalent error reporting
+# or delete them after the proxy switch if they're specific to SRPC.
+# http://crbug.com/160076
+for kind in [ 'ppp_initialize', 'ppp_initialize_crash',
+ 'no_ppp_instance', 'get_ppp_instance_crash',
+ #'get_ppp_messaging_crash', 'get_ppp_printing_crash',
+ 'ppp_instance_didcreate', 'ppp_instance_didcreate_crash',
+ #'event_replay_crash'
+ ]:
+ bad_nmf = 'ppapi_bad_%s' % kind
+ bad_nexe = env.ProgramNameForNmf('ppapi_bad_%s' % kind)
+ env.ComponentProgram(bad_nexe,
+ ['ppapi_bad_%s.cc' % kind],
+ EXTRA_LIBS=['ppapi',
+ 'platform',
+ 'pthread',
+ 'gio'])
+ nmf_names.append(bad_nmf)
+ ppapi_bad_files.extend(env.ExtractPublishedFiles(bad_nexe))
+ env.Depends(ppapi_bad, env.Alias(bad_nexe))
+
+# "scons --mode=nacl ppapi_bad" will publish the html and all of its
+# dependencies to scons-out.
+env.Alias('ppapi_bad', ppapi_bad)
+
+node = env.PPAPIBrowserTester(
+ 'ppapi_bad_browser_test.out',
+ url='ppapi_bad.html',
+ nmf_names=nmf_names,
+ test_args=[('is_pnacl', int(env.Bit('pnacl_generate_pexe')))],
+ files=[env.File(f) for f in ppapi_bad_files],
+ args=['--allow_404'])
+
+# This test is failing on Windows:
+# crbug.com/98720
+# This test is failing on Valgrind because of multiple nexes.
+env.AddNodeToTestSuite(node,
+ ['chrome_browser_tests'],
+ 'run_ppapi_bad_browser_test',
+ is_broken=env.PPAPIBrowserTesterIsBroken() or
+ env.Bit('host_windows') or
+ env.Bit('running_on_valgrind'))
+
+
+# Bad nexe tests that won't work in PNaCl (native)
+# For example, partly_invalid.nexe has inline assembly in its source files.
+# Just bail out here for PNaCl, since the NMF will require the .nexe
+# to be built.
+if env.Bit('bitcode'):
+ Return()
+
+nacltest_js = env.File('${SCONSTRUCT_DIR}/tools/browser_tester/browserdata/' +
+ 'nacltest.js')
+partly_invalid = env.File('${STAGING_DIR}/partly_invalid${PROGSUFFIX}')
+nmf = '${TEST_DIR}/partly_invalid.nmf'
+if not env.Bit('nacl_glibc'):
+ ppapi_bad_native_files = [
+ env.File('ppapi_bad_native.html'),
+ env.File('${SCONSTRUCT_DIR}/tests/ppapi_browser/' +
+ 'progress_event_listener.js'),
+ nacltest_js]
+ replicated_files = env.Replicate('${STAGING_DIR}', ppapi_bad_native_files)
+ env.Alias('all_programs', replicated_files)
+ ppapi_bad_native_files.append(partly_invalid)
+
+ node = env.PPAPIBrowserTester(
+ 'ppapi_bad_native_test.out',
+ url='ppapi_bad_native.html',
+ nmfs=[nmf],
+ files=ppapi_bad_native_files,
+ )
+else:
+ ppapi_bad_native_files = [
+ env.File('${TEST_DIR}/ppapi_bad_native_glibc.html'),
+ nacltest_js]
+ replicated_files = env.Replicate('${STAGING_DIR}', ppapi_bad_native_files)
+ env.Alias('all_programs', replicated_files)
+ ppapi_bad_native_files.append(partly_invalid)
+
+ node = env.PPAPIBrowserTester(
+ 'ppapi_bad_native_test.out',
+ url='ppapi_bad_native_glibc.html',
+ nmfs=[nmf],
+ files=ppapi_bad_native_files,
+ nacl_exe_stderr={
+ 'file': '${TARGET_ROOT}/test_results/ppapi_bad_native_test.log',
+ 'golden': '${TEST_DIR}/ppapi_bad_native_glibc.stderr'}
+ )
+
+env.AddNodeToTestSuite(node,
+ ['chrome_browser_tests'],
+ 'run_ppapi_bad_native_test',
+ is_broken=env.PPAPIBrowserTesterIsBroken())
diff --git a/ppapi/native_client/tests/ppapi_browser/bad/partly_invalid.nmf b/ppapi/native_client/tests/ppapi_browser/bad/partly_invalid.nmf
new file mode 100644
index 0000000..c5e122f
--- /dev/null
+++ b/ppapi/native_client/tests/ppapi_browser/bad/partly_invalid.nmf
@@ -0,0 +1,7 @@
+{
+ "program": {
+ "x86-32": {"url": "partly_invalid.nexe"},
+ "x86-64": {"url": "partly_invalid.nexe"},
+ "arm": {"url": "partly_invalid.nexe"}
+ }
+}
diff --git a/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad.html b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad.html
new file mode 100644
index 0000000..8889403
--- /dev/null
+++ b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad.html
@@ -0,0 +1,237 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+ <!--
+ Copyright (c) 2012 The Chromium Authors. All rights reserved.
+ Use of this source code is governed by a BSD-style license that can be
+ found in the LICENSE file.
+ -->
+ <head>
+ <META HTTP-EQUIV="Pragma" CONTENT="no-cache" />
+ <META HTTP-EQUIV="Expires" CONTENT="-1" />
+ <script type="text/javascript" src="nacltest.js"> </script>
+ <script type="text/javascript" src="ppapi_bad.js"> </script>
+ <title> PPAPI bad manifest/nexe URLs </title>
+ <style type="text/css">
+ .naclModule { background-color: gray; margin: 2px 2px; }
+ </style>
+ </head>
+<body id="body">
+<script type="text/javascript">
+//<![CDATA[
+
+var prefix = 'NaCl module load failed: ';
+
+// PNaCl may have slightly different error messages (pexe instead of nexe).
+function couldNotAccessNexe(is_pnacl) {
+ if (!is_pnacl) {
+ return prefix + 'access to nexe url was denied.';
+ } else {
+ return prefix + 'PnaclCoordinator: pexe load failed (no access).';
+ }
+}
+
+// PNaCl may have slightly different error messages (pexe instead of nexe).
+function couldNotLoadNexe(is_pnacl) {
+ if (!is_pnacl) {
+ return prefix + 'could not load nexe url.';
+ } else {
+ /* PP_ERROR_FAILED */
+ return prefix + 'PnaclCoordinator: pexe load failed (pp_error=-2).';
+ }
+}
+
+function declareTests(tester) {
+ var test_args = getTestArguments({'is_pnacl': '0'});
+ var is_pnacl = parseInt(test_args['is_pnacl']);
+ var mime_type = "application/x-nacl";
+ if (is_pnacl) {
+ mime_type = "application/x-pnacl";
+ }
+
+ // 'bad_magic' loads a manifest, then loads a nexe that tests as invalid.
+ badLoadTest(
+ tester,
+ 'bad_magic',
+ 'ppapi_bad_magic.nmf',
+ mime_type,
+ 'NaCl module load failed: Bad ELF header magic number');
+
+ // 'cross_origin' loads a manifest, then tries to load a cross-origin nexe.
+ badLoadTest(
+ tester,
+ 'cross_origin',
+ 'ppapi_bad_crossorigin.nmf',
+ mime_type,
+ couldNotAccessNexe(is_pnacl));
+
+ // 'cross_manifest' tries to load a cross-origin manifest.
+ badLoadTest(
+ tester,
+ 'cross_manifest',
+ 'http://www.google.com/crossorigin.manifest',
+ mime_type,
+ 'NaCl module load failed: access to manifest url was denied.');
+
+ // 'nonexistent_nexe' loads a manifest, then tries to load a nonexistent nexe.
+ badLoadTest(
+ tester,
+ 'nonexistent_nexe',
+ 'ppapi_bad_doesnotexist.nmf',
+ mime_type,
+ couldNotLoadNexe(is_pnacl));
+
+ // 'nonexistent_manifest' tries to load a nonexistent manifest.
+ badLoadTest(
+ tester,
+ 'nonexistent_manifest',
+ 'doesnotexist.manifest',
+ mime_type,
+ 'NaCl module load failed: could not load manifest url.');
+
+ // 'bad_manifest' loads an invalid manifest.
+ badLoadTest(
+ tester,
+ 'bad_manifest',
+ 'ppapi_bad.html',
+ mime_type,
+ 'NaCl module load failed: manifest JSON parsing failed: * Line 1, Column 1\n Syntax error: value, object or array expected.\n');
+
+ // 'bad_manifest_uses_nexes' loads a manifest with an obsolete 'nexes' section.
+ badLoadTest(
+ tester,
+ 'bad_manifest_uses_nexes',
+ 'ppapi_bad_manifest_uses_nexes.nmf',
+ mime_type,
+ 'NaCl module load failed: manifest: missing \'program\' section.');
+
+ // 'bad_manifest_bad_files' loads a manifest with a bad 'files' section.
+ badLoadTest(
+ tester,
+ 'bad_manifest_bad_files',
+ 'ppapi_bad_manifest_bad_files.nmf',
+ mime_type,
+ // Manifest loader expects either 'url' or 'pnacl-translate' key present.
+ // If neither is found, it complains about the last one.
+ 'NaCl module load failed: manifest: file.txt property \'unknown_arch\' does not have required key: \'url\'.');
+
+ // 'bad_manifest_nexe_arch' loads a manifest with no program entry for the
+ // user's architecture
+ badLoadTest(
+ tester,
+ 'bad_manifest_nexe_arch',
+ 'ppapi_bad_manifest_nexe_arch.nmf',
+ mime_type,
+ 'NaCl module load failed: manifest: no version of program given for current arch and no portable version found.');
+
+ //////////////////////////////////////
+ // Initialization errors begin here //
+ //////////////////////////////////////
+
+ // 'bad_ppp_initialize' loads a manifest, then loads a nexe that fails to
+ // initialize PPAPI module
+ badLoadTest(
+ tester,
+ 'bad_ppp_initialize',
+ 'ppapi_bad_ppp_initialize.nmf',
+ mime_type,
+ 'NaCl module load failed: could not initialize module.');
+
+ // 'bad_ppp_initialize_crash' loads a manifest, then loads a nexe that crashes
+ // before initializing PPAPI module
+ badLoadTest(
+ tester,
+ 'bad_ppp_initialize_crash',
+ 'ppapi_bad_ppp_initialize_crash.nmf',
+ mime_type,
+ 'NaCl module load failed: could not initialize module.');
+
+ // 'bad_no_ppp_instance' loads a manifest, then loads a nexe that fails to
+ // get the required PPP_Instance interface
+ badLoadTest(
+ tester,
+ 'bad_no_ppp_instance',
+ 'ppapi_bad_no_ppp_instance.nmf',
+ mime_type,
+ 'NaCl module load failed: could not initialize module.');
+
+ // 'bad_get_ppp_instance_crash' loads a manifest, then loads a nexe that
+ // crashes when getting the required PPP_Instance interface
+ badLoadTest(
+ tester,
+ 'bad_get_ppp_instance_crash',
+ 'ppapi_bad_get_ppp_instance_crash.nmf',
+ mime_type,
+ 'NaCl module load failed: could not initialize module.');
+
+ // 'bad_ppp_instance_didcreate' loads a manifest, then loads a nexe that fails
+ // to create the instance
+ badLoadTest(
+ tester,
+ 'bad_ppp_instance_didcreate',
+ 'ppapi_bad_ppp_instance_didcreate.nmf',
+ mime_type,
+ 'NaCl module load failed: could not create instance.');
+
+ // 'bad_ppp_instance_didcreate_crash' loads a manifest, then loads a nexe that
+ // crashes before creating the instance.
+ badLoadTest(
+ tester,
+ 'bad_ppp_instance_didcreate_crash',
+ 'ppapi_bad_ppp_instance_didcreate_crash.nmf',
+ mime_type,
+ 'NaCl module load failed: could not create instance.');
+
+/* TODO(bbudge) Re-enable this test when the IPC proxy can report these errors.
+ http://crbug.com/160076
+ // 'bad_event_replay_crash' loads a manifest, then loads a nexe and replays
+ // the events that occured during loading causing the nexe to crash before
+ // proxy start-up was completed.
+ badLoadTest(
+ tester,
+ 'bad_event_replay_crash',
+ 'ppapi_bad_event_replay_crash.nmf',
+ mime_type,
+ 'NaCl module load failed: instance crashed after creation.');
+*/
+}
+
+
+// The driver invoked when the body has finished loading.
+function runTests() {
+ var tester = new Tester($('body'));
+ tester.loadErrorsAreOK();
+ declareTests(tester);
+ tester.run();
+}
+//]]>
+</script>
+
+<!-- The tests will create and remove embeds from this div. -->
+<div id="embeds"></div>
+
+<!-- These two embeds are not automatically tested - visual inspection only. -->
+
+<embed id="cross_manifest_pdf"
+ width=100 height=20
+ src="http://www.google.com/crossorigin.manifest"
+ style="background-color:gray"
+ type="application/pdf" />
+
+<!-- This load would have succeeded if the NEXE was from a chrome-extension
+ URL and NaCl had been registered as handling the PDF MIME type using
+ the nacl_modules attribute in a Chrome extension manifest. -->
+
+<embed id="cross_origin_pdf"
+ width=100 height=20
+ src="ppapi_bad_crossorigin.nmf"
+ style="background-color:gray"
+ type="application/pdf" />
+
+<script type="text/javascript">
+//<![CDATA[
+runTests();
+//]]>
+</script>
+</body>
+</html>
diff --git a/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad.js b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad.js
new file mode 100644
index 0000000..4ab712b
--- /dev/null
+++ b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad.js
@@ -0,0 +1,48 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Helper routines for generating bad load tests.
+// Webpage must have an 'embeds' div for injecting NaCl modules.
+// Depends on nacltest.js.
+
+function createModule(id, src, type) {
+ return createNaClEmbed({
+ id: id,
+ src: src,
+ width: 100,
+ height: 20,
+ type: type
+ });
+}
+
+
+function addModule(module) {
+ $('embeds').appendChild(module);
+}
+
+
+function removeModule(module) {
+ $('embeds').removeChild(module);
+}
+
+
+function badLoadTest(tester, id, src, type, error_string) {
+ tester.addAsyncTest(id, function(test){
+ var module = createModule(id, src, type);
+
+ test.expectEvent(module, 'load', function(e) {
+ removeModule(module);
+ test.fail('Module loaded successfully.');
+ });
+ test.expectEvent(module, 'error', function(e) {
+ test.assertEqual(module.readyState, 4);
+ test.assertEqual(module.lastError, error_string);
+ test.expectEvent(module, 'loadend', function(e) {
+ removeModule(module);
+ test.pass();
+ });
+ });
+ addModule(module);
+ });
+}
diff --git a/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_crossorigin.nmf b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_crossorigin.nmf
new file mode 100644
index 0000000..22dba61
--- /dev/null
+++ b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_crossorigin.nmf
@@ -0,0 +1,7 @@
+{
+ "program": {
+ "x86-32": {"url": "http://www.google.com/crossorigin.nexe"},
+ "x86-64": {"url": "http://www.google.com/crossorigin.nexe"},
+ "arm": {"url": "http://www.google.com/crossorigin.nexe"}
+ }
+}
diff --git a/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_doesnotexist.nmf b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_doesnotexist.nmf
new file mode 100644
index 0000000..8578bcb
--- /dev/null
+++ b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_doesnotexist.nmf
@@ -0,0 +1,7 @@
+{
+ "program": {
+ "x86-32": {"url": "doesnotexist.nexe"},
+ "x86-64": {"url": "doesnotexist.nexe"},
+ "arm": {"url": "doesnotexist.nexe"}
+ }
+}
diff --git a/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_event_replay_crash.cc b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_event_replay_crash.cc
new file mode 100644
index 0000000..77c9591
--- /dev/null
+++ b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_event_replay_crash.cc
@@ -0,0 +1,65 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+
+#include "native_client/src/shared/platform/nacl_check.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/pp_instance.h"
+#include "ppapi/c/pp_module.h"
+#include "ppapi/c/pp_var.h"
+
+#include "ppapi/c/ppb.h"
+#include "ppapi/c/ppb_instance.h"
+#include "ppapi/c/ppp_instance.h"
+#include "ppapi/c/ppp.h"
+
+PP_EXPORT int32_t PPP_InitializeModule(PP_Module module_id,
+ PPB_GetInterface get_browser_interface) {
+ printf("PPP_InitializeModule\n");
+ return PP_OK;
+}
+
+PP_EXPORT void PPP_ShutdownModule() {
+ printf("PPP_ShutdownModule\n");
+ fflush(stdout);
+}
+
+namespace {
+
+PP_Bool DidCreate(PP_Instance /*instance*/,
+ uint32_t /*argc*/,
+ const char* /*argn*/[],
+ const char* /*argv*/[]) {
+ return PP_TRUE;
+}
+
+void DidDestroy(PP_Instance /*instance*/) {
+}
+
+void DidChangeFocus(PP_Instance /*instance*/, PP_Bool /*has_focus*/) {
+}
+
+PP_Bool HandleDocumentLoad(PP_Instance /*instance*/, PP_Resource /*loader*/) {
+ return PP_FALSE;
+}
+
+const PPP_Instance instance_interface = {
+ DidCreate,
+ DidDestroy,
+ NULL, // Calling DidChangeView will cause a crash!
+ DidChangeFocus,
+ HandleDocumentLoad
+};
+
+} // namespace
+
+PP_EXPORT const void* PPP_GetInterface(const char* interface_name) {
+ printf("PPP_GetInterface(%s)\n", interface_name);
+ if (0 == std::strcmp(interface_name, PPP_INSTANCE_INTERFACE)) // Required.
+ return reinterpret_cast<const void*>(&instance_interface);
+ return NULL;
+}
diff --git a/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_get_ppp_instance_crash.cc b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_get_ppp_instance_crash.cc
new file mode 100644
index 0000000..44328de
--- /dev/null
+++ b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_get_ppp_instance_crash.cc
@@ -0,0 +1,33 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+
+#include "native_client/src/shared/platform/nacl_check.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/pp_module.h"
+#include "ppapi/c/ppb.h"
+#include "ppapi/c/ppp.h"
+#include "ppapi/c/ppp_instance.h"
+#include "ppapi/native_client/tests/ppapi_test_lib/test_interface.h"
+
+int32_t PPP_InitializeModule(PP_Module module_id,
+ PPB_GetInterface get_browser_interface) {
+ printf("PPP_InitializeModule\n");
+ return PP_OK;
+}
+
+PP_EXPORT void PPP_ShutdownModule() {
+ printf("PPP_ShutdownModule\n");
+ fflush(stdout);
+}
+
+PP_EXPORT const void* PPP_GetInterface(const char* interface_name) {
+ printf("PPP_GetInterface(%s)\n", interface_name);
+ if (0 == std::strcmp(interface_name, PPP_INSTANCE_INTERFACE)) // Required.
+ CRASH;
+ return NULL;
+}
diff --git a/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_get_ppp_messaging_crash.cc b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_get_ppp_messaging_crash.cc
new file mode 100644
index 0000000..481b5db
--- /dev/null
+++ b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_get_ppp_messaging_crash.cc
@@ -0,0 +1,72 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+
+#include "native_client/src/shared/platform/nacl_check.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/pp_instance.h"
+#include "ppapi/c/pp_module.h"
+#include "ppapi/c/pp_var.h"
+
+#include "ppapi/c/ppb.h"
+#include "ppapi/c/ppp_instance.h"
+#include "ppapi/c/ppp_messaging.h"
+#include "ppapi/c/ppp.h"
+
+#include "ppapi/native_client/tests/ppapi_test_lib/test_interface.h"
+
+PP_EXPORT int32_t PPP_InitializeModule(PP_Module module_id,
+ PPB_GetInterface get_browser_interface) {
+ printf("PPP_InitializeModule\n");
+ return PP_OK;
+}
+
+PP_EXPORT void PPP_ShutdownModule() {
+ printf("PPP_ShutdownModule\n");
+ fflush(stdout);
+}
+
+namespace {
+
+PP_Bool DidCreate(PP_Instance /*instance*/,
+ uint32_t /*argc*/,
+ const char* /*argn*/[],
+ const char* /*argv*/[]) {
+ return PP_TRUE;
+}
+
+void DidDestroy(PP_Instance /*instance*/) {
+}
+
+void DidChangeView(PP_Instance /*instance*/, PP_Resource /*view*/) {
+}
+
+void DidChangeFocus(PP_Instance /*instance*/, PP_Bool /*has_focus*/) {
+}
+
+PP_Bool HandleDocumentLoad(PP_Instance /*instance*/, PP_Resource /*loader*/) {
+ return PP_FALSE;
+}
+
+const PPP_Instance instance_interface = {
+ DidCreate,
+ DidDestroy,
+ DidChangeView,
+ DidChangeFocus,
+ HandleDocumentLoad
+};
+
+} // namespace
+
+PP_EXPORT const void* PPP_GetInterface(const char* interface_name) {
+ printf("PPP_GetInterface(%s)\n", interface_name);
+ if (0 == std::strcmp(interface_name, PPP_INSTANCE_INTERFACE)) // Required.
+ return reinterpret_cast<const void*>(&instance_interface);
+ if (0 == std::strcmp(interface_name, PPP_MESSAGING_INTERFACE))
+ CRASH;
+ return NULL;
+}
diff --git a/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_get_ppp_printing_crash.cc b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_get_ppp_printing_crash.cc
new file mode 100644
index 0000000..c2b660e
--- /dev/null
+++ b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_get_ppp_printing_crash.cc
@@ -0,0 +1,72 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+
+#include "native_client/src/shared/platform/nacl_check.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/pp_instance.h"
+#include "ppapi/c/pp_module.h"
+#include "ppapi/c/pp_var.h"
+
+#include "ppapi/c/ppb.h"
+#include "ppapi/c/ppp_instance.h"
+#include "ppapi/c/dev/ppp_printing_dev.h"
+#include "ppapi/c/ppp.h"
+
+#include "ppapi/native_client/tests/ppapi_test_lib/test_interface.h"
+
+PP_EXPORT int32_t PPP_InitializeModule(PP_Module module_id,
+ PPB_GetInterface get_browser_interface) {
+ printf("PPP_InitializeModule\n");
+ return PP_OK;
+}
+
+PP_EXPORT void PPP_ShutdownModule() {
+ printf("PPP_ShutdownModule\n");
+ fflush(stdout);
+}
+
+namespace {
+
+PP_Bool DidCreate(PP_Instance /*instance*/,
+ uint32_t /*argc*/,
+ const char* /*argn*/[],
+ const char* /*argv*/[]) {
+ return PP_TRUE;
+}
+
+void DidDestroy(PP_Instance /*instance*/) {
+}
+
+void DidChangeView(PP_Instance /*instance*/, PP_Resource /*view*/) {
+}
+
+void DidChangeFocus(PP_Instance /*instance*/, PP_Bool /*has_focus*/) {
+}
+
+PP_Bool HandleDocumentLoad(PP_Instance /*instance*/, PP_Resource /*loader*/) {
+ return PP_FALSE;
+}
+
+const PPP_Instance instance_interface = {
+ DidCreate,
+ DidDestroy,
+ DidChangeView,
+ DidChangeFocus,
+ HandleDocumentLoad
+};
+
+} // namespace
+
+PP_EXPORT const void* PPP_GetInterface(const char* interface_name) {
+ printf("PPP_GetInterface(%s)\n", interface_name);
+ if (0 == std::strcmp(interface_name, PPP_INSTANCE_INTERFACE)) // Required.
+ return reinterpret_cast<const void*>(&instance_interface);
+ if (0 == std::strcmp(interface_name, PPP_PRINTING_DEV_INTERFACE))
+ CRASH;
+ return NULL;
+}
diff --git a/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_magic.nmf b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_magic.nmf
new file mode 100644
index 0000000..756c42e
--- /dev/null
+++ b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_magic.nmf
@@ -0,0 +1,7 @@
+{
+ "program": {
+ "x86-32": {"url": "ppapi_bad.html"},
+ "x86-64": {"url": "ppapi_bad.html"},
+ "arm": {"url": "ppapi_bad.html"}
+ }
+}
diff --git a/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_manifest_bad_files.nmf b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_manifest_bad_files.nmf
new file mode 100644
index 0000000..588901b
--- /dev/null
+++ b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_manifest_bad_files.nmf
@@ -0,0 +1,12 @@
+{
+ "program": {
+ "x86-32": {"url": "ppapi_bad_no_ppp_instance_x86-32.nexe"},
+ "x86-64": {"url": "ppapi_bad_no_ppp_instance_x86-64.nexe"},
+ "arm": {"url": "ppapi_bad_no_ppp_instance_arm.nexe"}
+ },
+ "files": {
+ "file.txt": {
+ "unknown_arch": {}
+ }
+ }
+}
diff --git a/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_manifest_nexe_arch.nmf b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_manifest_nexe_arch.nmf
new file mode 100644
index 0000000..8ef44e9
--- /dev/null
+++ b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_manifest_nexe_arch.nmf
@@ -0,0 +1,5 @@
+{
+ "program": {
+ "unknown_arch": {"url": "ppapi_bad_no_ppp_instance_x86-32.nexe"}
+ }
+}
diff --git a/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_manifest_uses_nexes.nmf b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_manifest_uses_nexes.nmf
new file mode 100644
index 0000000..286ed7b
--- /dev/null
+++ b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_manifest_uses_nexes.nmf
@@ -0,0 +1,7 @@
+{
+ "nexes": {
+ "x86-32": "doesnotexist.nexe",
+ "x86-64": "doesnotexist.nexe",
+ "arm": "doesnotexist.nexe"
+ }
+}
diff --git a/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_native.html b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_native.html
new file mode 100644
index 0000000..3004e05
--- /dev/null
+++ b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_native.html
@@ -0,0 +1,50 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+ <!-- Copyright 2011 Google Inc. All rights reserved. -->
+ <head>
+ <META HTTP-EQUIV="Pragma" CONTENT="no-cache" />
+ <META HTTP-EQUIV="Expires" CONTENT="-1" />
+ <script type="text/javascript" src="nacltest.js"> </script>
+ <script type="text/javascript" src="progress_event_listener.js"> </script>
+ <title> PPAPI bad manifest/nexe URLs </title>
+ </head>
+ <body id="body">
+<script type="text/javascript">
+//<![CDATA[
+var tester = new Tester($('body'));
+
+// This nexe should fail validation inside the sel_ldr.
+testProgressEventStateMachine(
+ tester,
+ 'partly_invalid',
+ 1, // progressMinCount
+ 1, // errorCount
+ 0, // abortCount
+ 0, // loadCount
+ 'NaCl module load failed: Validation failure. File violates Native Client safety rules.');
+
+// The driver invoked when the body has finished loading.
+function runTests() {
+ tester.loadErrorsAreOK();
+ tester.waitFor($('partly_invalid'));
+ tester.run();
+}
+// Set all the listeners on the body.
+setListeners($('body'));
+//]]>
+</script>
+ <embed id="partly_invalid"
+ class="naclModule"
+ width=100 height=20
+ src="partly_invalid.nmf"
+ style="background-color:gray"
+ type="application/x-nacl" />
+
+ <script type="text/javascript">
+ //<![CDATA[
+ runTests();
+ //]]>
+ </script>
+ </body>
+</html>
diff --git a/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_native_glibc.html b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_native_glibc.html
new file mode 100644
index 0000000..ef03798
--- /dev/null
+++ b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_native_glibc.html
@@ -0,0 +1,37 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+ <!-- Copyright 2011 Google Inc. All rights reserved. -->
+ <head>
+ <META HTTP-EQUIV="Pragma" CONTENT="no-cache" />
+ <META HTTP-EQUIV="Expires" CONTENT="-1" />
+ <script type="text/javascript" src="nacltest.js"> </script>
+ <title> PPAPI bad manifest/nexe URLs, glibc. </title>
+ </head>
+ <body id="body">
+ <embed id="partly_invalid"
+ class="naclModule"
+ width=100 height=20
+ src="partly_invalid.nmf"
+ style="background-color:gray"
+ type="application/x-nacl" />
+
+ <script type="text/javascript">
+ //<![CDATA[
+ var tester = new Tester($('body'));
+ tester.loadErrorsAreOK();
+ // This is a dummy test so that we can check output of runnable-ld.so
+ // using golden file.
+ tester.addAsyncTest('load_finished', function(status) {
+ status.expectEvent($('partly_invalid'), 'load', function(event) {
+ status.fail();
+ });
+ status.expectEvent($('partly_invalid'), 'loadend', function(event) {
+ status.pass();
+ });
+ });
+ tester.run();
+ //]]>
+ </script>
+ </body>
+</html>
diff --git a/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_native_glibc.stderr b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_native_glibc.stderr
new file mode 100644
index 0000000..27378c5
--- /dev/null
+++ b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_native_glibc.stderr
@@ -0,0 +1 @@
+/lib/main.nexe: error while loading shared libraries: /lib/main.nexe: failed to load code from shared object: Invalid argument \ No newline at end of file
diff --git a/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_no_ppp_instance.cc b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_no_ppp_instance.cc
new file mode 100644
index 0000000..699cd46
--- /dev/null
+++ b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_no_ppp_instance.cc
@@ -0,0 +1,39 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+
+#include "native_client/src/shared/platform/nacl_check.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/pp_module.h"
+#include "ppapi/c/ppb.h"
+#include "ppapi/c/ppp_instance.h"
+
+#include "ppapi/c/ppp.h"
+
+int32_t PPP_InitializeModule(PP_Module module_id,
+ PPB_GetInterface get_browser_interface) {
+ printf("PPP_InitializeModule\n");
+
+ // Request an unsupported interface.
+ CHECK(NULL == get_browser_interface("UnsupportedInterface;1.0"));
+ // Request a supported interface with a bad revision number.
+ CHECK(NULL == get_browser_interface("PPB_Instance;0.0"));
+
+ return PP_OK;
+}
+
+PP_EXPORT void PPP_ShutdownModule() {
+ printf("PPP_ShutdownModule\n");
+ fflush(stdout);
+}
+
+PP_EXPORT const void* PPP_GetInterface(const char* interface_name) {
+ printf("PPP_GetInterface(%s)\n", interface_name);
+ if (0 == std::strcmp(interface_name, PPP_INSTANCE_INTERFACE)) // Required.
+ return NULL;
+ return NULL;
+}
diff --git a/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_ppp_initialize.cc b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_ppp_initialize.cc
new file mode 100644
index 0000000..7b6a3b7
--- /dev/null
+++ b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_ppp_initialize.cc
@@ -0,0 +1,30 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+
+#include "native_client/src/include/nacl_macros.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/pp_module.h"
+#include "ppapi/c/ppb.h"
+#include "ppapi/c/ppp.h"
+
+PP_EXPORT int32_t PPP_InitializeModule(PP_Module module_id,
+ PPB_GetInterface get_browser_interface) {
+ printf("PPP_InitializeModule\n");
+ return PP_ERROR_FAILED;
+}
+
+PP_EXPORT void PPP_ShutdownModule() {
+ printf("PPP_ShutdownModule\n");
+ NACL_NOTREACHED(); // If initialization fails, this should not be called.
+}
+
+PP_EXPORT const void* PPP_GetInterface(const char* interface_name) {
+ printf("PPP_GetInterface\n");
+ NACL_NOTREACHED(); // If initialization fails, this should not be called.
+ return NULL;
+}
diff --git a/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_ppp_initialize_crash.cc b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_ppp_initialize_crash.cc
new file mode 100644
index 0000000..9910f3a
--- /dev/null
+++ b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_ppp_initialize_crash.cc
@@ -0,0 +1,72 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+
+#include "native_client/src/include/nacl_macros.h"
+#include "native_client/src/shared/platform/nacl_check.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/pp_instance.h"
+#include "ppapi/c/pp_module.h"
+#include "ppapi/c/pp_var.h"
+#include "ppapi/c/ppb.h"
+#include "ppapi/c/ppp.h"
+#include "ppapi/c/ppp_instance.h"
+#include "ppapi/native_client/tests/ppapi_test_lib/test_interface.h"
+
+PP_EXPORT int32_t PPP_InitializeModule(PP_Module module_id,
+ PPB_GetInterface get_browser_interface) {
+ printf("PPP_InitializeModule\n");
+ CRASH;
+
+ return PP_OK;
+}
+
+PP_EXPORT void PPP_ShutdownModule() {
+ printf("PPP_ShutdownModule\n");
+}
+
+// Ensure that all other loading steps do not generate errors that might mask
+// a missing crash above.
+
+namespace {
+
+PP_Bool DidCreate(PP_Instance /*instance*/,
+ uint32_t /*argc*/,
+ const char* /*argn*/[],
+ const char* /*argv*/[]) {
+ return PP_TRUE;
+}
+
+void DidDestroy(PP_Instance /*instance*/) {
+}
+
+void DidChangeView(PP_Instance /*instance*/, PP_Resource /*view*/) {
+}
+
+void DidChangeFocus(PP_Instance /*instance*/, PP_Bool /*has_focus*/) {
+}
+
+PP_Bool HandleDocumentLoad(PP_Instance /*instance*/, PP_Resource /*loader*/) {
+ return PP_FALSE;
+}
+
+const PPP_Instance instance_interface = {
+ DidCreate,
+ DidDestroy,
+ DidChangeView,
+ DidChangeFocus,
+ HandleDocumentLoad
+};
+
+} // namespace
+
+PP_EXPORT const void* PPP_GetInterface(const char* interface_name) {
+ printf("PPP_GetInterface\n");
+ if (0 == std::strcmp(interface_name, PPP_INSTANCE_INTERFACE)) // Required.
+ return reinterpret_cast<const void*>(&instance_interface);
+ return NULL;
+}
diff --git a/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_ppp_instance_didcreate.cc b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_ppp_instance_didcreate.cc
new file mode 100644
index 0000000..6d30708
--- /dev/null
+++ b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_ppp_instance_didcreate.cc
@@ -0,0 +1,69 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+
+#include "native_client/src/shared/platform/nacl_check.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/pp_instance.h"
+#include "ppapi/c/pp_module.h"
+#include "ppapi/c/pp_var.h"
+
+#include "ppapi/c/ppb.h"
+#include "ppapi/c/ppb_instance.h"
+#include "ppapi/c/ppp_instance.h"
+#include "ppapi/c/ppp.h"
+
+PP_EXPORT int32_t PPP_InitializeModule(PP_Module module_id,
+ PPB_GetInterface get_browser_interface) {
+ printf("PPP_InitializeModule\n");
+ return PP_OK;
+}
+
+PP_EXPORT void PPP_ShutdownModule() {
+ printf("PPP_ShutdownModule\n");
+ fflush(stdout);
+}
+
+namespace {
+
+PP_Bool DidCreate(PP_Instance /*instance*/,
+ uint32_t /*argc*/,
+ const char* /*argn*/[],
+ const char* /*argv*/[]) {
+ return PP_FALSE;
+}
+
+void DidDestroy(PP_Instance /*instance*/) {
+}
+
+void DidChangeView(PP_Instance /*instance*/,
+ PP_Resource /*view*/) {
+}
+
+void DidChangeFocus(PP_Instance /*instance*/, PP_Bool /*has_focus*/) {
+}
+
+PP_Bool HandleDocumentLoad(PP_Instance /*instance*/, PP_Resource /*loader*/) {
+ return PP_FALSE;
+}
+
+const PPP_Instance instance_interface = {
+ DidCreate,
+ DidDestroy,
+ DidChangeView,
+ DidChangeFocus,
+ HandleDocumentLoad
+};
+
+} // namespace
+
+PP_EXPORT const void* PPP_GetInterface(const char* interface_name) {
+ printf("PPP_GetInterface(%s)\n", interface_name);
+ if (0 == std::strcmp(interface_name, PPP_INSTANCE_INTERFACE)) // Required.
+ return reinterpret_cast<const void*>(&instance_interface);
+ return NULL;
+}
diff --git a/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_ppp_instance_didcreate_crash.cc b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_ppp_instance_didcreate_crash.cc
new file mode 100644
index 0000000..0b4b7da
--- /dev/null
+++ b/ppapi/native_client/tests/ppapi_browser/bad/ppapi_bad_ppp_instance_didcreate_crash.cc
@@ -0,0 +1,60 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+
+#include "native_client/src/shared/platform/nacl_check.h"
+
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/pp_instance.h"
+#include "ppapi/c/pp_module.h"
+#include "ppapi/c/pp_var.h"
+#include "ppapi/c/ppb.h"
+#include "ppapi/c/ppb_instance.h"
+#include "ppapi/c/ppp.h"
+#include "ppapi/c/ppp_instance.h"
+
+#include "ppapi/native_client/tests/ppapi_test_lib/test_interface.h"
+
+PP_EXPORT int32_t PPP_InitializeModule(PP_Module module_id,
+ PPB_GetInterface get_browser_interface) {
+ printf("PPP_InitializeModule\n");
+ return PP_OK;
+}
+
+PP_EXPORT void PPP_ShutdownModule() {
+ printf("PPP_ShutdownModule\n");
+ fflush(stdout);
+}
+
+namespace {
+
+PP_Bool DidCreate(PP_Instance /*instance*/,
+ uint32_t /*argc*/,
+ const char* /*argn*/[],
+ const char* /*argv*/[]) {
+ CRASH;
+ return PP_FALSE;
+}
+
+const PPP_Instance instance_interface = {
+ DidCreate,
+ // Normally one is not alowed to register NULLs for functions, but
+ // since DidCreate is going to crash, these will never be called.
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+} // namespace
+
+PP_EXPORT const void* PPP_GetInterface(const char* interface_name) {
+ printf("PPP_GetInterface(%s)\n", interface_name);
+ if (0 == std::strcmp(interface_name, PPP_INSTANCE_INTERFACE)) // Required.
+ return reinterpret_cast<const void*>(&instance_interface);
+ return NULL;
+}