| 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 13052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13063 | 13063 |
| 13064 | 13064 |
| 13065 THREADED_TEST(ObjectProtoToString) { | 13065 THREADED_TEST(ObjectProtoToString) { |
| 13066 v8::Isolate* isolate = CcTest::isolate(); | 13066 v8::Isolate* isolate = CcTest::isolate(); |
| 13067 v8::HandleScope scope(isolate); | 13067 v8::HandleScope scope(isolate); |
| 13068 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate); | 13068 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate); |
| 13069 templ->SetClassName(v8_str("MyClass")); | 13069 templ->SetClassName(v8_str("MyClass")); |
| 13070 | 13070 |
| 13071 LocalContext context; | 13071 LocalContext context; |
| 13072 | 13072 |
| 13073 CHECK_EQ(v8_str("MyClass"), templ->GetClassName()); |
| 13074 |
| 13073 Local<String> customized_tostring = v8_str("customized toString"); | 13075 Local<String> customized_tostring = v8_str("customized toString"); |
| 13074 | 13076 |
| 13075 // Replace Object.prototype.toString | 13077 // Replace Object.prototype.toString |
| 13076 v8_compile("Object.prototype.toString = function() {" | 13078 v8_compile("Object.prototype.toString = function() {" |
| 13077 " return 'customized toString';" | 13079 " return 'customized toString';" |
| 13078 "}")->Run(); | 13080 "}")->Run(); |
| 13079 | 13081 |
| 13080 // Normal ToString call should call replaced Object.prototype.toString | 13082 // Normal ToString call should call replaced Object.prototype.toString |
| 13081 Local<v8::Object> instance = templ->GetFunction()->NewInstance(); | 13083 Local<v8::Object> instance = templ->GetFunction()->NewInstance(); |
| 13082 Local<String> value = instance->ToString(); | 13084 Local<String> value = instance->ToString(); |
| (...skipping 9806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 22889 desc = x->GetOwnPropertyDescriptor(v8_str("p1")); | 22891 desc = x->GetOwnPropertyDescriptor(v8_str("p1")); |
| 22890 Local<Function> set = | 22892 Local<Function> set = |
| 22891 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("set"))); | 22893 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("set"))); |
| 22892 Local<Function> get = | 22894 Local<Function> get = |
| 22893 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("get"))); | 22895 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("get"))); |
| 22894 CHECK_EQ(v8_num(13), get->Call(x, 0, NULL)); | 22896 CHECK_EQ(v8_num(13), get->Call(x, 0, NULL)); |
| 22895 Handle<Value> args[] = { v8_num(14) }; | 22897 Handle<Value> args[] = { v8_num(14) }; |
| 22896 set->Call(x, 1, args); | 22898 set->Call(x, 1, args); |
| 22897 CHECK_EQ(v8_num(14), get->Call(x, 0, NULL)); | 22899 CHECK_EQ(v8_num(14), get->Call(x, 0, NULL)); |
| 22898 } | 22900 } |
| OLD | NEW |