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 5017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5028 value = CompileRun("Object.getOwnPropertyNames(object).length == 0"); | 5028 value = CompileRun("Object.getOwnPropertyNames(object).length == 0"); |
5029 CHECK(value->IsTrue()); | 5029 CHECK(value->IsTrue()); |
5030 | 5030 |
5031 context1->Exit(); | 5031 context1->Exit(); |
5032 context0->Exit(); | 5032 context0->Exit(); |
5033 context1.Dispose(); | 5033 context1.Dispose(); |
5034 context0.Dispose(); | 5034 context0.Dispose(); |
5035 } | 5035 } |
5036 | 5036 |
5037 | 5037 |
| 5038 static v8::Handle<v8::Array> NamedPropertyEnumerator(const AccessorInfo& info) { |
| 5039 v8::Handle<v8::Array> result = v8::Array::New(1); |
| 5040 result->Set(0, v8_str("x")); |
| 5041 return result; |
| 5042 } |
| 5043 |
| 5044 |
| 5045 THREADED_TEST(GetOwnPropertyNamesWithInterceptor) { |
| 5046 v8::HandleScope handle_scope; |
| 5047 v8::Handle<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New(); |
| 5048 |
| 5049 obj_template->Set(v8_str("x"), v8::Integer::New(42)); |
| 5050 obj_template->SetNamedPropertyHandler(NULL, NULL, NULL, NULL, |
| 5051 NamedPropertyEnumerator); |
| 5052 |
| 5053 LocalContext context; |
| 5054 v8::Handle<v8::Object> global = context->Global(); |
| 5055 global->Set(v8_str("object"), obj_template->NewInstance()); |
| 5056 |
| 5057 v8::Handle<Value> value = |
| 5058 CompileRun("Object.getOwnPropertyNames(object).join(',')"); |
| 5059 CHECK_EQ(v8_str("x"), value); |
| 5060 } |
| 5061 |
| 5062 |
5038 static v8::Handle<Value> ConstTenGetter(Local<String> name, | 5063 static v8::Handle<Value> ConstTenGetter(Local<String> name, |
5039 const AccessorInfo& info) { | 5064 const AccessorInfo& info) { |
5040 return v8_num(10); | 5065 return v8_num(10); |
5041 } | 5066 } |
5042 | 5067 |
5043 | 5068 |
5044 THREADED_TEST(CrossDomainAccessors) { | 5069 THREADED_TEST(CrossDomainAccessors) { |
5045 v8::HandleScope handle_scope; | 5070 v8::HandleScope handle_scope; |
5046 | 5071 |
5047 v8::Handle<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(); | 5072 v8::Handle<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(); |
(...skipping 5874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10922 const char* code = | 10947 const char* code = |
10923 "(function() {" | 10948 "(function() {" |
10924 " for (var i = 0; i < 2*16; i++) {" | 10949 " for (var i = 0; i < 2*16; i++) {" |
10925 " %_GetFromCache(0, 'a' + i);" | 10950 " %_GetFromCache(0, 'a' + i);" |
10926 " };" | 10951 " };" |
10927 " return 'PASSED';" | 10952 " return 'PASSED';" |
10928 "})()"; | 10953 "})()"; |
10929 v8::internal::Heap::ClearJSFunctionResultCaches(); | 10954 v8::internal::Heap::ClearJSFunctionResultCaches(); |
10930 ExpectString(code, "PASSED"); | 10955 ExpectString(code, "PASSED"); |
10931 } | 10956 } |
OLD | NEW |