Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1619)

Unified Diff: test/cctest/test-api.cc

Issue 10837358: Throw a more descriptive exception when blocking 'eval' via CSP. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add SetErrorMessageForCodeGenerationFromStrings API function. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 689286f904c7a5a9c8f7d6e2d938d7e337d7b921..15cc7d12c890a33e1bd747209339be6434ee5467 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -16454,6 +16454,24 @@ THREADED_TEST(AllowCodeGenFromStrings) {
}
+TEST(SetErrorMessageForCodeGenFromStrings) {
+ v8::HandleScope scope;
+ LocalContext context;
+ TryCatch try_catch;
+
+ Handle<String> message = v8_str("Message") ;
+ Handle<String> expected_message = v8_str("Uncaught EvalError: Message");
+ V8::SetAllowCodeGenerationFromStringsCallback(&CodeGenerationDisallowed);
+ context->AllowCodeGenerationFromStrings(false);
+ context->SetErrorMessageForCodeGenerationFromStrings(message);
+ Handle<Value> result = CompileRun("eval('42')");
+ CHECK(result.IsEmpty());
+ CHECK(try_catch.HasCaught());
+ Handle<String> actual_message = try_catch.Message()->Get();
+ CHECK(expected_message->Equals(actual_message));
+}
+
+
static v8::Handle<Value> NonObjectThis(const v8::Arguments& args) {
return v8::Undefined();
}
« no previous file with comments | « src/runtime.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698