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 11032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11043 | 11043 |
11044 // Failing access check to function call results in exception. | 11044 // Failing access check to function call results in exception. |
11045 CHECK(g1->Call(global, 0, NULL).IsEmpty()); | 11045 CHECK(g1->Call(global, 0, NULL).IsEmpty()); |
11046 CHECK(g2->Call(global, 0, NULL).IsEmpty()); | 11046 CHECK(g2->Call(global, 0, NULL).IsEmpty()); |
11047 | 11047 |
11048 // No failing access check when just returning a constant. | 11048 // No failing access check when just returning a constant. |
11049 CHECK(h->Call(global, 0, NULL)->Equals(v8_num(1))); | 11049 CHECK(h->Call(global, 0, NULL)->Equals(v8_num(1))); |
11050 } | 11050 } |
11051 | 11051 |
11052 | 11052 |
11053 v8::Handle<v8::String> a; | 11053 const char* a = "a"; |
Vyacheslav Egorov (Chromium)
2012/02/20 14:28:13
static const char* kPropertyA
fschneider
2012/02/22 11:27:50
Done.
| |
11054 v8::Handle<v8::String> h; | 11054 const char* h = "h"; |
Vyacheslav Egorov (Chromium)
2012/02/20 14:28:13
static const char* kPropertyB
fschneider
2012/02/22 11:27:50
Done.
| |
11055 | 11055 |
11056 static bool NamedGetAccessBlockAandH(Local<v8::Object> obj, | 11056 static bool NamedGetAccessBlockAandH(Local<v8::Object> obj, |
11057 Local<Value> name, | 11057 Local<Value> name, |
11058 v8::AccessType type, | 11058 v8::AccessType type, |
11059 Local<Value> data) { | 11059 Local<Value> data) { |
11060 return !(name->Equals(a) || name->Equals(h)); | 11060 if (!name->IsString()) return false; |
11061 char buf[10]; | |
11062 Local<String>::Cast(name)->WriteAscii(buf, 0, 9); | |
11063 return !(strcmp(a, buf) == 0 || strcmp(h, buf) == 0); | |
Vyacheslav Egorov (Chromium)
2012/02/20 14:28:13
->IsEqualTo(CStrVector(kPropertyA))
?
fschneider
2012/02/22 11:27:50
Done.
| |
11061 } | 11064 } |
11062 | 11065 |
11063 | 11066 |
11064 // TODO(1952): Enable this test for threading test once the underlying bug is | 11067 THREADED_TEST(TurnOnAccessCheckAndRecompile) { |
11065 // fixed. | |
11066 TEST(TurnOnAccessCheckAndRecompile) { | |
11067 v8::HandleScope handle_scope; | 11068 v8::HandleScope handle_scope; |
11068 | 11069 |
11069 // Create an environment with access check to the global object disabled by | 11070 // Create an environment with access check to the global object disabled by |
11070 // default. When the registered access checker will block access to properties | 11071 // default. When the registered access checker will block access to properties |
11071 // a and h | 11072 // a and h. |
11072 a = v8_str("a"); | |
11073 h = v8_str("h"); | |
11074 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); | 11073 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); |
11075 global_template->SetAccessCheckCallbacks(NamedGetAccessBlockAandH, | 11074 global_template->SetAccessCheckCallbacks(NamedGetAccessBlockAandH, |
11076 IndexedGetAccessBlocker, | 11075 IndexedGetAccessBlocker, |
11077 v8::Handle<v8::Value>(), | 11076 v8::Handle<v8::Value>(), |
11078 false); | 11077 false); |
11079 v8::Persistent<Context> context = Context::New(NULL, global_template); | 11078 v8::Persistent<Context> context = Context::New(NULL, global_template); |
11080 Context::Scope context_scope(context); | 11079 Context::Scope context_scope(context); |
11081 | 11080 |
11082 // Set up a property and a number of functions. | 11081 // Set up a property and a number of functions. |
11083 context->Global()->Set(v8_str("a"), v8_num(1)); | 11082 context->Global()->Set(v8_str("a"), v8_num(1)); |
(...skipping 5008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
16092 CompileRun("throw 'exception';"); | 16091 CompileRun("throw 'exception';"); |
16093 } | 16092 } |
16094 | 16093 |
16095 | 16094 |
16096 TEST(CallCompletedCallbackTwoExceptions) { | 16095 TEST(CallCompletedCallbackTwoExceptions) { |
16097 v8::HandleScope scope; | 16096 v8::HandleScope scope; |
16098 LocalContext env; | 16097 LocalContext env; |
16099 v8::V8::AddCallCompletedCallback(CallCompletedCallbackException); | 16098 v8::V8::AddCallCompletedCallback(CallCompletedCallbackException); |
16100 CompileRun("throw 'first exception';"); | 16099 CompileRun("throw 'first exception';"); |
16101 } | 16100 } |
OLD | NEW |