OLD | NEW |
1 // Copyright 2007-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 12389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12400 v8::Context::Scope context_scope(context.local()); | 12400 v8::Context::Scope context_scope(context.local()); |
12401 | 12401 |
12402 v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New(); | 12402 v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New(); |
12403 tmpl->SetNamedPropertyHandler(Getter, NULL, NULL, NULL, Enumerator); | 12403 tmpl->SetNamedPropertyHandler(Getter, NULL, NULL, NULL, Enumerator); |
12404 context->Global()->Set(v8_str("o"), tmpl->NewInstance()); | 12404 context->Global()->Set(v8_str("o"), tmpl->NewInstance()); |
12405 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( | 12405 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( |
12406 "var result = []; for (var k in o) result.push(k); result")); | 12406 "var result = []; for (var k in o) result.push(k); result")); |
12407 CHECK_EQ(1, result->Length()); | 12407 CHECK_EQ(1, result->Length()); |
12408 CHECK_EQ(v8_str("universalAnswer"), result->Get(0)); | 12408 CHECK_EQ(v8_str("universalAnswer"), result->Get(0)); |
12409 } | 12409 } |
| 12410 |
| 12411 |
| 12412 TEST(DefinePropertyPostDetach) { |
| 12413 v8::HandleScope scope; |
| 12414 LocalContext context; |
| 12415 v8::Handle<v8::Object> proxy = context->Global(); |
| 12416 v8::Handle<v8::Function> define_property = |
| 12417 CompileRun("(function() {" |
| 12418 " Object.defineProperty(" |
| 12419 " this," |
| 12420 " 1," |
| 12421 " { configurable: true, enumerable: true, value: 3 });" |
| 12422 "})").As<Function>(); |
| 12423 context->DetachGlobal(); |
| 12424 define_property->Call(proxy, 0, NULL); |
| 12425 } |
OLD | NEW |