| 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 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); | 528 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate); |
| 529 obj->SetHandler(v8::NamedPropertyHandlerConfiguration( | 529 obj->SetHandler(v8::NamedPropertyHandlerConfiguration( |
| 530 JSONStringifyGetter, NULL, NULL, NULL, JSONStringifyEnumerator)); | 530 JSONStringifyGetter, NULL, NULL, NULL, JSONStringifyEnumerator)); |
| 531 env->Global()->Set(v8_str("obj"), obj->NewInstance()); | 531 env->Global()->Set(v8_str("obj"), obj->NewInstance()); |
| 532 v8::Handle<v8::String> expected = v8_str("{\"regress\":\"crbug-161028\"}"); | 532 v8::Handle<v8::String> expected = v8_str("{\"regress\":\"crbug-161028\"}"); |
| 533 CHECK(CompileRun("JSON.stringify(obj)")->Equals(expected)); | 533 CHECK(CompileRun("JSON.stringify(obj)")->Equals(expected)); |
| 534 } | 534 } |
| 535 | 535 |
| 536 | 536 |
| 537 static v8::Local<v8::Context> expected_current_context; | 537 static v8::Local<v8::Context> expected_current_context; |
| 538 static v8::Local<v8::Context> expected_calling_context; | |
| 539 | 538 |
| 540 | 539 |
| 541 static void check_contexts(const v8::FunctionCallbackInfo<v8::Value>& info) { | 540 static void check_contexts(const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 542 ApiTestFuzzer::Fuzz(); | 541 ApiTestFuzzer::Fuzz(); |
| 543 CHECK(expected_current_context == info.GetIsolate()->GetCurrentContext()); | 542 CHECK(expected_current_context == info.GetIsolate()->GetCurrentContext()); |
| 544 CHECK(expected_calling_context == info.GetIsolate()->GetCallingContext()); | |
| 545 } | 543 } |
| 546 | 544 |
| 547 | 545 |
| 548 THREADED_TEST(AccessorPropertyCrossContext) { | 546 THREADED_TEST(AccessorPropertyCrossContext) { |
| 549 LocalContext env; | 547 LocalContext env; |
| 550 v8::Isolate* isolate = env->GetIsolate(); | 548 v8::Isolate* isolate = env->GetIsolate(); |
| 551 v8::HandleScope scope(isolate); | 549 v8::HandleScope scope(isolate); |
| 552 v8::Handle<v8::Function> fun = v8::Function::New(isolate, check_contexts); | 550 v8::Handle<v8::Function> fun = v8::Function::New(isolate, check_contexts); |
| 553 LocalContext switch_context; | 551 LocalContext switch_context; |
| 554 switch_context->Global()->Set(v8_str("fun"), fun); | 552 switch_context->Global()->Set(v8_str("fun"), fun); |
| 555 v8::TryCatch try_catch(isolate); | 553 v8::TryCatch try_catch(isolate); |
| 556 expected_current_context = env.local(); | 554 expected_current_context = env.local(); |
| 557 expected_calling_context = switch_context.local(); | |
| 558 CompileRun( | 555 CompileRun( |
| 559 "var o = Object.create(null, { n: { get:fun } });" | 556 "var o = Object.create(null, { n: { get:fun } });" |
| 560 "for (var i = 0; i < 10; i++) o.n;"); | 557 "for (var i = 0; i < 10; i++) o.n;"); |
| 561 CHECK(!try_catch.HasCaught()); | 558 CHECK(!try_catch.HasCaught()); |
| 562 } | 559 } |
| 563 | 560 |
| 564 | 561 |
| 565 THREADED_TEST(GlobalObjectAccessor) { | 562 THREADED_TEST(GlobalObjectAccessor) { |
| 566 LocalContext env; | 563 LocalContext env; |
| 567 v8::Isolate* isolate = env->GetIsolate(); | 564 v8::Isolate* isolate = env->GetIsolate(); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 | 678 |
| 682 security_check_value = true; | 679 security_check_value = true; |
| 683 ExpectInt32("f()", 907); | 680 ExpectInt32("f()", 907); |
| 684 security_check_value = false; | 681 security_check_value = false; |
| 685 { | 682 { |
| 686 v8::TryCatch try_catch(isolate); | 683 v8::TryCatch try_catch(isolate); |
| 687 CompileRun("f();"); | 684 CompileRun("f();"); |
| 688 CHECK(try_catch.HasCaught()); | 685 CHECK(try_catch.HasCaught()); |
| 689 } | 686 } |
| 690 } | 687 } |
| OLD | NEW |