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 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 | 573 |
574 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); | 574 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); |
575 obj->SetNamedPropertyHandler( | 575 obj->SetNamedPropertyHandler( |
576 JSONStringifyGetter, NULL, NULL, NULL, JSONStringifyEnumerator); | 576 JSONStringifyGetter, NULL, NULL, NULL, JSONStringifyEnumerator); |
577 env->Global()->Set(v8_str("obj"), obj->NewInstance()); | 577 env->Global()->Set(v8_str("obj"), obj->NewInstance()); |
578 v8::Handle<v8::String> expected = v8_str("{\"regress\":\"crbug-161028\"}"); | 578 v8::Handle<v8::String> expected = v8_str("{\"regress\":\"crbug-161028\"}"); |
579 CHECK(CompileRun("JSON.stringify(obj)")->Equals(expected)); | 579 CHECK(CompileRun("JSON.stringify(obj)")->Equals(expected)); |
580 } | 580 } |
581 | 581 |
582 | 582 |
| 583 static v8::Local<v8::Context> expected_current_context; |
| 584 static v8::Local<v8::Context> expected_calling_context; |
| 585 |
| 586 |
| 587 static void check_contexts(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 588 ApiTestFuzzer::Fuzz(); |
| 589 CHECK(expected_current_context == info.GetIsolate()->GetCurrentContext()); |
| 590 CHECK(expected_calling_context == info.GetIsolate()->GetCallingContext()); |
| 591 } |
| 592 |
| 593 |
583 THREADED_TEST(AccessorPropertyCrossContext) { | 594 THREADED_TEST(AccessorPropertyCrossContext) { |
584 LocalContext env; | 595 LocalContext env; |
585 v8::Isolate* isolate = env->GetIsolate(); | 596 v8::Isolate* isolate = env->GetIsolate(); |
586 v8::HandleScope scope(isolate); | 597 v8::HandleScope scope(isolate); |
587 v8::Handle<v8::Function> fun = v8::Function::New(isolate, handle_property); | 598 v8::Handle<v8::Function> fun = v8::Function::New(isolate, check_contexts); |
588 LocalContext switch_context; | 599 LocalContext switch_context; |
589 switch_context->Global()->Set(v8_str("fun"), fun); | 600 switch_context->Global()->Set(v8_str("fun"), fun); |
590 v8::TryCatch try_catch; | 601 v8::TryCatch try_catch; |
| 602 expected_current_context = env.local(); |
| 603 expected_calling_context = switch_context.local(); |
591 CompileRun( | 604 CompileRun( |
592 "var o = Object.create(null, { n: { get:fun } });" | 605 "var o = Object.create(null, { n: { get:fun } });" |
593 "for (var i = 0; i < 10; i++) o.n;"); | 606 "for (var i = 0; i < 10; i++) o.n;"); |
594 CHECK(!try_catch.HasCaught()); | 607 CHECK(!try_catch.HasCaught()); |
595 } | 608 } |
OLD | NEW |