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

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

Issue 42508: Fix bug in context stores, where the store was ignored if there was a... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 9 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') | test/mjsunit/getter-in-prototype.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-api.cc
===================================================================
--- test/cctest/test-api.cc (revision 1573)
+++ test/cctest/test-api.cc (working copy)
@@ -6095,3 +6095,26 @@
local_env->Exit();
}
+
+
+// Test that we can set a property on the global object even if there
+// is a read-only property in the prototype chain.
+TEST(ReadOnlyPropertyInGlobalProto) {
+ v8::HandleScope scope;
+ v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New();
+ LocalContext context(0, templ);
+ v8::Handle<v8::Object> global = context->Global();
+ v8::Handle<v8::Object> global_proto =
+ v8::Handle<v8::Object>::Cast(global->Get(v8_str("__proto__")));
+ global_proto->Set(v8_str("x"), v8::Integer::New(0), v8::ReadOnly);
+ global_proto->Set(v8_str("y"), v8::Integer::New(0), v8::ReadOnly);
+ // Check without 'eval' or 'with'.
+ v8::Handle<v8::Value> res =
+ CompileRun("function f() { x = 42; return x; }; f()");
+ // Check with 'eval'.
+ res = CompileRun("function f() { eval('1'); y = 42; return y; }; f()");
+ CHECK_EQ(v8::Integer::New(42), res);
+ // Check with 'with'.
+ res = CompileRun("function f() { with (this) { y = 42 }; return y; }; f()");
+ CHECK_EQ(v8::Integer::New(42), res);
+}
« no previous file with comments | « src/runtime.cc ('k') | test/mjsunit/getter-in-prototype.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698