summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjvoung@chromium.org <jvoung@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-13 01:55:19 +0000
committerjvoung@chromium.org <jvoung@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-13 01:55:19 +0000
commit69d9b811fe005f12541e72d651ad863b919c50ec (patch)
tree807e71b9c80c3154c84026dd89375fbe05670b14
parentd5367c738b60d1c2924653057bae7174c9bd9540 (diff)
downloadchromium_src-69d9b811fe005f12541e72d651ad863b919c50ec.zip
chromium_src-69d9b811fe005f12541e72d651ad863b919c50ec.tar.gz
chromium_src-69d9b811fe005f12541e72d651ad863b919c50ec.tar.bz2
Make PNaCl load error message w/ wrong mimetype more helpful.
Actually say that the manifest looks pnacl-like, but you have a NaCl mimetype instead of a PNaCl mimetype. The SDK guys have been running into this a lot. "PNaCl-like NMF with application/x-nacl mimetype instead of x-pnacl mimetype (has pnacl-translate)." Also test what happens when you have a PNaCl manifest without "pnacl-translate". BUG=253715 TEST=*Pnacl.PnaclErrorHandling Review URL: https://chromiumcodereview.appspot.com/22908002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@217162 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/test/data/nacl/nacl_test_data.gyp1
-rw-r--r--chrome/test/data/nacl/pnacl_error_handling/pnacl_error_handling.html21
-rw-r--r--chrome/test/data/nacl/pnacl_error_handling/pnacl_illformed_manifest.nmf5
-rw-r--r--ppapi/native_client/src/trusted/plugin/json_manifest.cc19
4 files changed, 36 insertions, 10 deletions
diff --git a/chrome/test/data/nacl/nacl_test_data.gyp b/chrome/test/data/nacl/nacl_test_data.gyp
index 4d8e4ec..52f4fca 100644
--- a/chrome/test/data/nacl/nacl_test_data.gyp
+++ b/chrome/test/data/nacl/nacl_test_data.gyp
@@ -146,6 +146,7 @@
'pnacl_error_handling/bad.pexe',
'pnacl_error_handling/pnacl_bad_pexe.nmf',
'pnacl_error_handling/pnacl_bad_doesnotexist.nmf',
+ 'pnacl_error_handling/pnacl_illformed_manifest.nmf',
],
},
'dependencies': [
diff --git a/chrome/test/data/nacl/pnacl_error_handling/pnacl_error_handling.html b/chrome/test/data/nacl/pnacl_error_handling/pnacl_error_handling.html
index 610d111..05815c8 100644
--- a/chrome/test/data/nacl/pnacl_error_handling/pnacl_error_handling.html
+++ b/chrome/test/data/nacl/pnacl_error_handling/pnacl_error_handling.html
@@ -39,6 +39,27 @@ function declareTests(tester) {
'NaCl module load failed: PnaclCoordinator: ' +
'pexe load failed (pp_error=-2).');
+ // 'illformed_manifest' loads a manifest that isn't quite right for pexes
+ // (looks like the format for NaCl portable data files).
+ badLoadTest(
+ tester,
+ 'illformed_manifest',
+ 'pnacl_illformed_manifest.nmf',
+ 'application/x-pnacl',
+ 'NaCl module load failed: manifest: program property \'portable\' does ' +
+ 'not have required key: \'pnacl-translate\'.');
+
+ // 'wrong_mimetype' loads an okay manifest, but with the wrong mimetype
+ // (the NaCl mimetype instead of PNaCl mimetype).
+ badLoadTest(
+ tester,
+ 'wrong_mimetype',
+ 'pnacl_bad_pexe.nmf',
+ 'application/x-nacl',
+ 'NaCl module load failed: manifest: PNaCl-like NMF with ' +
+ 'application/x-nacl mimetype instead of x-pnacl mimetype ' +
+ '(has pnacl-translate).');
+
tester.addAsyncTest('Test clean directory',
// All that should be left after all tests run is empty directories.
// This means we will need to update this test with a whitelist,
diff --git a/chrome/test/data/nacl/pnacl_error_handling/pnacl_illformed_manifest.nmf b/chrome/test/data/nacl/pnacl_error_handling/pnacl_illformed_manifest.nmf
new file mode 100644
index 0000000..cf7280f
--- /dev/null
+++ b/chrome/test/data/nacl/pnacl_error_handling/pnacl_illformed_manifest.nmf
@@ -0,0 +1,5 @@
+{
+ "program": {
+ "portable": {"url": "bad.pexe"}
+ }
+}
diff --git a/ppapi/native_client/src/trusted/plugin/json_manifest.cc b/ppapi/native_client/src/trusted/plugin/json_manifest.cc
index 12d3c10..0928c05 100644
--- a/ppapi/native_client/src/trusted/plugin/json_manifest.cc
+++ b/ppapi/native_client/src/trusted/plugin/json_manifest.cc
@@ -173,6 +173,15 @@ bool IsValidUrlSpec(const Json::Value& url_spec,
urlSpecPlusOptional = kPnaclUrlSpecPlusOptional;
urlSpecPlusOptionalLength = NACL_ARRAY_SIZE(kPnaclUrlSpecPlusOptional);
} else {
+ // URL specifications must not contain "pnacl-translate" keys.
+ // This prohibits NaCl clients from invoking PNaCl.
+ if (url_spec.isMember(kPnaclTranslateKey)) {
+ nacl::stringstream error_stream;
+ error_stream << "PNaCl-like NMF with application/x-nacl mimetype instead "
+ << "of x-pnacl mimetype (has " << kPnaclTranslateKey << ").";
+ *error_string = error_stream.str();
+ return false;
+ }
urlSpecPlusOptional = kManifestUrlSpecRequired;
urlSpecPlusOptionalLength = NACL_ARRAY_SIZE(kManifestUrlSpecRequired);
}
@@ -184,16 +193,6 @@ bool IsValidUrlSpec(const Json::Value& url_spec,
error_string)) {
return false;
}
- // URL specifications must not contain "pnacl-translate" keys.
- // This prohibits NaCl clients from invoking PNaCl.
- Json::Value translate = url_spec[kPnaclTranslateKey];
- if (!translate.empty()) {
- nacl::stringstream error_stream;
- error_stream << parent_key << " property '" << container_key <<
- "' has '" << kPnaclTranslateKey << "' inside URL spec.";
- *error_string = error_stream.str();
- return false;
- }
// Verify the correct types of the fields if they exist.
Json::Value url = url_spec[kUrlKey];
if (!url.isString()) {