| 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 3046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3057 } | 3057 } |
| 3058 | 3058 |
| 3059 | 3059 |
| 3060 static v8::Handle<Value> IdentityIndexedPropertyGetter( | 3060 static v8::Handle<Value> IdentityIndexedPropertyGetter( |
| 3061 uint32_t index, | 3061 uint32_t index, |
| 3062 const AccessorInfo& info) { | 3062 const AccessorInfo& info) { |
| 3063 return v8::Integer::New(index); | 3063 return v8::Integer::New(index); |
| 3064 } | 3064 } |
| 3065 | 3065 |
| 3066 | 3066 |
| 3067 THREADED_TEST(IndexedInterceptorWithGetOwnPropertyDescriptor) { |
| 3068 v8::HandleScope scope; |
| 3069 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 3070 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); |
| 3071 |
| 3072 LocalContext context; |
| 3073 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
| 3074 |
| 3075 // Check fast object case. |
| 3076 const char* fast_case_code = |
| 3077 "Object.getOwnPropertyDescriptor(obj, 0).value.toString()"; |
| 3078 ExpectString(fast_case_code, "0"); |
| 3079 |
| 3080 // Check slow case. |
| 3081 const char* slow_case_code = |
| 3082 "obj.x = 1; delete obj.x;" |
| 3083 "Object.getOwnPropertyDescriptor(obj, 1).value.toString()"; |
| 3084 ExpectString(slow_case_code, "1"); |
| 3085 } |
| 3086 |
| 3087 |
| 3067 THREADED_TEST(IndexedInterceptorWithNoSetter) { | 3088 THREADED_TEST(IndexedInterceptorWithNoSetter) { |
| 3068 v8::HandleScope scope; | 3089 v8::HandleScope scope; |
| 3069 Local<ObjectTemplate> templ = ObjectTemplate::New(); | 3090 Local<ObjectTemplate> templ = ObjectTemplate::New(); |
| 3070 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); | 3091 templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter); |
| 3071 | 3092 |
| 3072 LocalContext context; | 3093 LocalContext context; |
| 3073 context->Global()->Set(v8_str("obj"), templ->NewInstance()); | 3094 context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
| 3074 | 3095 |
| 3075 const char* code = | 3096 const char* code = |
| 3076 "try {" | 3097 "try {" |
| (...skipping 8313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11390 | 11411 |
| 11391 { | 11412 { |
| 11392 // Change the Boolean.prototype in the second context and check | 11413 // Change the Boolean.prototype in the second context and check |
| 11393 // that the right function gets called. | 11414 // that the right function gets called. |
| 11394 v8::HandleScope scope; | 11415 v8::HandleScope scope; |
| 11395 LocalContext context2; | 11416 LocalContext context2; |
| 11396 CompileRun("Boolean.prototype.toString = function() { return \"\"; }"); | 11417 CompileRun("Boolean.prototype.toString = function() { return \"\"; }"); |
| 11397 ExpectString(code, ""); | 11418 ExpectString(code, ""); |
| 11398 } | 11419 } |
| 11399 } | 11420 } |
| OLD | NEW |