OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 LocalContext switch_context; | 599 LocalContext switch_context; |
600 switch_context->Global()->Set(v8_str("fun"), fun); | 600 switch_context->Global()->Set(v8_str("fun"), fun); |
601 v8::TryCatch try_catch; | 601 v8::TryCatch try_catch; |
602 expected_current_context = env.local(); | 602 expected_current_context = env.local(); |
603 expected_calling_context = switch_context.local(); | 603 expected_calling_context = switch_context.local(); |
604 CompileRun( | 604 CompileRun( |
605 "var o = Object.create(null, { n: { get:fun } });" | 605 "var o = Object.create(null, { n: { get:fun } });" |
606 "for (var i = 0; i < 10; i++) o.n;"); | 606 "for (var i = 0; i < 10; i++) o.n;"); |
607 CHECK(!try_catch.HasCaught()); | 607 CHECK(!try_catch.HasCaught()); |
608 } | 608 } |
| 609 |
| 610 |
| 611 THREADED_TEST(GlobalObjectAccessor) { |
| 612 LocalContext env; |
| 613 v8::Isolate* isolate = env->GetIsolate(); |
| 614 v8::HandleScope scope(isolate); |
| 615 CompileRun( |
| 616 "var set_value = 1;" |
| 617 "Object.defineProperty(this.__proto__, 'x', {" |
| 618 " get : function() { return this; }," |
| 619 " set : function() { set_value = this; }" |
| 620 "});" |
| 621 "function getter() { return x; }" |
| 622 "function setter() { x = 1; }" |
| 623 "for (var i = 0; i < 4; i++) { getter(); setter(); }"); |
| 624 CHECK(v8::Utils::OpenHandle(*CompileRun("getter()"))->IsJSGlobalProxy()); |
| 625 CHECK(v8::Utils::OpenHandle(*CompileRun("set_value"))->IsJSGlobalProxy()); |
| 626 } |
OLD | NEW |