Commit 3b7f631e authored by kasperl@chromium.org's avatar kasperl@chromium.org

Allow using with and eval in JS extensions in debug mode by

getting rid of bogus assertion error.
Review URL: http://codereview.chromium.org/73072

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1710 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent e9aa2184
...@@ -2092,7 +2092,7 @@ Statement* Parser::ParseWithStatement(ZoneStringList* labels, bool* ok) { ...@@ -2092,7 +2092,7 @@ Statement* Parser::ParseWithStatement(ZoneStringList* labels, bool* ok) {
// code. If 'with' statements were allowed, the simplified setup of // code. If 'with' statements were allowed, the simplified setup of
// the runtime context chain would allow access to properties in the // the runtime context chain would allow access to properties in the
// global object from within a 'with' statement. // global object from within a 'with' statement.
ASSERT(!Bootstrapper::IsActive()); ASSERT(extension_ != NULL || !Bootstrapper::IsActive());
Expect(Token::WITH, CHECK_OK); Expect(Token::WITH, CHECK_OK);
Expect(Token::LPAREN, CHECK_OK); Expect(Token::LPAREN, CHECK_OK);
...@@ -2761,7 +2761,7 @@ Expression* Parser::ParseLeftHandSideExpression(bool* ok) { ...@@ -2761,7 +2761,7 @@ Expression* Parser::ParseLeftHandSideExpression(bool* ok) {
if (var == NULL) { if (var == NULL) {
// We do not allow direct calls to 'eval' in our internal // We do not allow direct calls to 'eval' in our internal
// JS files. Use builtin functions instead. // JS files. Use builtin functions instead.
ASSERT(!Bootstrapper::IsActive()); ASSERT(extension_ != NULL || !Bootstrapper::IsActive());
top_scope_->RecordEvalCall(); top_scope_->RecordEvalCall();
is_potentially_direct_eval = true; is_potentially_direct_eval = true;
} }
......
...@@ -2495,6 +2495,44 @@ THREADED_TEST(SimpleExtensions) { ...@@ -2495,6 +2495,44 @@ THREADED_TEST(SimpleExtensions) {
} }
static const char* kEvalExtensionSource =
"function UseEval() {"
" var x = 42;"
" return eval('x');"
"}";
THREADED_TEST(UseEvalFromExtension) {
v8::HandleScope handle_scope;
v8::RegisterExtension(new Extension("evaltest", kEvalExtensionSource));
const char* extension_names[] = { "evaltest" };
v8::ExtensionConfiguration extensions(1, extension_names);
v8::Handle<Context> context = Context::New(&extensions);
Context::Scope lock(context);
v8::Handle<Value> result = Script::Compile(v8_str("UseEval()"))->Run();
CHECK_EQ(result, v8::Integer::New(42));
}
static const char* kWithExtensionSource =
"function UseWith() {"
" var x = 42;"
" with({x:87}) { return x; }"
"}";
THREADED_TEST(UseWithFromExtension) {
v8::HandleScope handle_scope;
v8::RegisterExtension(new Extension("withtest", kWithExtensionSource));
const char* extension_names[] = { "withtest" };
v8::ExtensionConfiguration extensions(1, extension_names);
v8::Handle<Context> context = Context::New(&extensions);
Context::Scope lock(context);
v8::Handle<Value> result = Script::Compile(v8_str("UseWith()"))->Run();
CHECK_EQ(result, v8::Integer::New(87));
}
THREADED_TEST(AutoExtensions) { THREADED_TEST(AutoExtensions) {
v8::HandleScope handle_scope; v8::HandleScope handle_scope;
Extension* extension = new Extension("autotest", kSimpleExtensionSource); Extension* extension = new Extension("autotest", kSimpleExtensionSource);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment