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 22395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22406 | 22406 |
22407 TEST(AllowJavascriptExecutionScope) { | 22407 TEST(AllowJavascriptExecutionScope) { |
22408 LocalContext context; | 22408 LocalContext context; |
22409 v8::Isolate* isolate = context->GetIsolate(); | 22409 v8::Isolate* isolate = context->GetIsolate(); |
22410 v8::HandleScope scope(isolate); | 22410 v8::HandleScope scope(isolate); |
22411 v8::Isolate::DisallowJavascriptExecutionScope no_js(isolate); | 22411 v8::Isolate::DisallowJavascriptExecutionScope no_js(isolate); |
22412 { v8::Isolate::AllowJavascriptExecutionScope yes_js(isolate); | 22412 { v8::Isolate::AllowJavascriptExecutionScope yes_js(isolate); |
22413 CompileRun("1+1"); | 22413 CompileRun("1+1"); |
22414 } | 22414 } |
22415 } | 22415 } |
| 22416 |
| 22417 |
| 22418 TEST(Regress354123) { |
| 22419 LocalContext current; |
| 22420 v8::Isolate* isolate = current->GetIsolate(); |
| 22421 v8::HandleScope scope(isolate); |
| 22422 |
| 22423 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate); |
| 22424 templ->SetAccessCheckCallbacks(NamedAccessCounter, IndexedAccessCounter); |
| 22425 current->Global()->Set(v8_str("friend"), templ->NewInstance()); |
| 22426 |
| 22427 // Test access using __proto__ from the prototype chain. |
| 22428 named_access_count = 0; |
| 22429 CompileRun("friend.__proto__ = {};"); |
| 22430 CHECK_EQ(2, named_access_count); |
| 22431 CompileRun("friend.__proto__;"); |
| 22432 CHECK_EQ(4, named_access_count); |
| 22433 |
| 22434 // Test access using __proto__ as a hijacked function (A). |
| 22435 named_access_count = 0; |
| 22436 CompileRun("var p = Object.prototype;" |
| 22437 "var f = Object.getOwnPropertyDescriptor(p, '__proto__').set;" |
| 22438 "f.call(friend, {});"); |
| 22439 CHECK_EQ(1, named_access_count); |
| 22440 CompileRun("var p = Object.prototype;" |
| 22441 "var f = Object.getOwnPropertyDescriptor(p, '__proto__').get;" |
| 22442 "f.call(friend);"); |
| 22443 CHECK_EQ(2, named_access_count); |
| 22444 |
| 22445 // Test access using __proto__ as a hijacked function (B). |
| 22446 named_access_count = 0; |
| 22447 CompileRun("var f = Object.prototype.__lookupSetter__('__proto__');" |
| 22448 "f.call(friend, {});"); |
| 22449 CHECK_EQ(1, named_access_count); |
| 22450 CompileRun("var f = Object.prototype.__lookupGetter__('__proto__');" |
| 22451 "f.call(friend);"); |
| 22452 CHECK_EQ(2, named_access_count); |
| 22453 |
| 22454 // Test access using Object.setPrototypeOf reflective method. |
| 22455 named_access_count = 0; |
| 22456 CompileRun("Object.setPrototypeOf(friend, {});"); |
| 22457 CHECK_EQ(1, named_access_count); |
| 22458 CompileRun("Object.getPrototypeOf(friend);"); |
| 22459 CHECK_EQ(2, named_access_count); |
| 22460 } |
OLD | NEW |