OLD | NEW |
---|---|
1 // Copyright 2007-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2009 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 3004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3015 } | 3015 } |
3016 | 3016 |
3017 | 3017 |
3018 static v8::Handle<Value> IdentityIndexedPropertyGetter( | 3018 static v8::Handle<Value> IdentityIndexedPropertyGetter( |
3019 uint32_t index, | 3019 uint32_t index, |
3020 const AccessorInfo& info) { | 3020 const AccessorInfo& info) { |
3021 return v8::Integer::New(index); | 3021 return v8::Integer::New(index); |
3022 } | 3022 } |
3023 | 3023 |
3024 | 3024 |
3025 THREADED_TEST(IndexedInterceptorWithGetOwnPropertyDescriptor) { | |
3026 v8::HandleScope scope; | |
3027 Local<ObjectTemplate> templ = ObjectTemplate::New(); | |
3028 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); | |
antonm
2010/09/22 13:26:38
you probably need to extend this test case for cas
| |
3029 | |
3030 LocalContext context; | |
3031 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | |
3032 | |
3033 // Check fast object case. | |
3034 const char* fast_case_code = | |
3035 "Object.getOwnPropertyDescriptor(obj, 0).value.toString()"; | |
3036 ExpectString(fast_case_code, "0"); | |
3037 | |
3038 // Check slow case. | |
3039 const char* slow_case_code = | |
3040 "obj.x = 1; delete obj.x;" | |
3041 "Object.getOwnPropertyDescriptor(obj, 1).value.toString()"; | |
3042 ExpectString(slow_case_code, "1"); | |
3043 } | |
3044 | |
3045 | |
3025 THREADED_TEST(IndexedInterceptorWithNoSetter) { | 3046 THREADED_TEST(IndexedInterceptorWithNoSetter) { |
3026 v8::HandleScope scope; | 3047 v8::HandleScope scope; |
3027 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 3048 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
3028 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); | 3049 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); |
3029 | 3050 |
3030 LocalContext context; | 3051 LocalContext context; |
3031 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 3052 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
3032 | 3053 |
3033 const char* code = | 3054 const char* code = |
3034 "try {" | 3055 "try {" |
(...skipping 8335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11370 | 11391 |
11371 { | 11392 { |
11372 // Change the Boolean.prototype in the second context and check | 11393 // Change the Boolean.prototype in the second context and check |
11373 // that the right function gets called. | 11394 // that the right function gets called. |
11374 v8::HandleScope scope; | 11395 v8::HandleScope scope; |
11375 LocalContext context2; | 11396 LocalContext context2; |
11376 CompileRun("Boolean.prototype.toString = function() { return \"\"; }"); | 11397 CompileRun("Boolean.prototype.toString = function() { return \"\"; }"); |
11377 ExpectString(code, ""); | 11398 ExpectString(code, ""); |
11378 } | 11399 } |
11379 } | 11400 } |
OLD | NEW |