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 21706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
21717 | 21717 |
21718 // Create an ObjectTemplate for global objects and install access | 21718 // Create an ObjectTemplate for global objects and install access |
21719 // check callbacks that will block access. | 21719 // check callbacks that will block access. |
21720 v8::Handle<v8::ObjectTemplate> global_template = | 21720 v8::Handle<v8::ObjectTemplate> global_template = |
21721 v8::ObjectTemplate::New(isolate); | 21721 v8::ObjectTemplate::New(isolate); |
21722 global_template->SetAccessCheckCallbacks(NamedAccessAlwaysBlocked, | 21722 global_template->SetAccessCheckCallbacks(NamedAccessAlwaysBlocked, |
21723 IndexAccessAlwaysBlocked); | 21723 IndexAccessAlwaysBlocked); |
21724 | 21724 |
21725 // Create a context and set an x property on it's global object. | 21725 // Create a context and set an x property on it's global object. |
21726 LocalContext context0(NULL, global_template); | 21726 LocalContext context0(NULL, global_template); |
21727 context0->Global()->Set(v8_str("x"), v8_num(42)); | |
Yang
2014/08/21 06:08:20
Is this intentional? Why?
Toon Verwaest
2014/08/21 07:02:55
Because below it's calling into %AddNamedProperty,
Yang
2014/08/21 07:37:26
Acknowledged.
| |
21728 v8::Handle<v8::Object> global0 = context0->Global(); | 21727 v8::Handle<v8::Object> global0 = context0->Global(); |
21729 | 21728 |
21730 // Create a context with a different security token so that the | 21729 // Create a context with a different security token so that the |
21731 // failed access check callback will be called on each access. | 21730 // failed access check callback will be called on each access. |
21732 LocalContext context1(NULL, global_template); | 21731 LocalContext context1(NULL, global_template); |
21733 context1->Global()->Set(v8_str("other"), global0); | 21732 context1->Global()->Set(v8_str("other"), global0); |
21734 | 21733 |
21735 v8::Handle<v8::FunctionTemplate> catcher_fun = | 21734 v8::Handle<v8::FunctionTemplate> catcher_fun = |
21736 v8::FunctionTemplate::New(isolate, CatcherCallback); | 21735 v8::FunctionTemplate::New(isolate, CatcherCallback); |
21737 context1->Global()->Set(v8_str("catcher"), catcher_fun->GetFunction()); | 21736 context1->Global()->Set(v8_str("catcher"), catcher_fun->GetFunction()); |
(...skipping 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
22898 desc = x->GetOwnPropertyDescriptor(v8_str("p1")); | 22897 desc = x->GetOwnPropertyDescriptor(v8_str("p1")); |
22899 Local<Function> set = | 22898 Local<Function> set = |
22900 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("set"))); | 22899 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("set"))); |
22901 Local<Function> get = | 22900 Local<Function> get = |
22902 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("get"))); | 22901 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("get"))); |
22903 CHECK_EQ(v8_num(13), get->Call(x, 0, NULL)); | 22902 CHECK_EQ(v8_num(13), get->Call(x, 0, NULL)); |
22904 Handle<Value> args[] = { v8_num(14) }; | 22903 Handle<Value> args[] = { v8_num(14) }; |
22905 set->Call(x, 1, args); | 22904 set->Call(x, 1, args); |
22906 CHECK_EQ(v8_num(14), get->Call(x, 0, NULL)); | 22905 CHECK_EQ(v8_num(14), get->Call(x, 0, NULL)); |
22907 } | 22906 } |
OLD | NEW |