OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 6824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6835 Local<Value> proto1 = o1->GetPrototype(); | 6835 Local<Value> proto1 = o1->GetPrototype(); |
6836 CHECK(proto1->IsObject()); | 6836 CHECK(proto1->IsObject()); |
6837 CHECK_EQ(proto1.As<v8::Object>(), o2); | 6837 CHECK_EQ(proto1.As<v8::Object>(), o2); |
6838 | 6838 |
6839 Local<Value> proto2 = o2->GetPrototype(); | 6839 Local<Value> proto2 = o2->GetPrototype(); |
6840 CHECK(proto2->IsObject()); | 6840 CHECK(proto2->IsObject()); |
6841 CHECK_EQ(proto2.As<v8::Object>(), o3); | 6841 CHECK_EQ(proto2.As<v8::Object>(), o3); |
6842 } | 6842 } |
6843 | 6843 |
6844 | 6844 |
| 6845 THREADED_TEST(SetPrototypeProperties) { |
| 6846 v8::HandleScope handle_scope; |
| 6847 LocalContext context; |
| 6848 |
| 6849 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(); |
| 6850 t1->SetPrototypeAttributes(v8::DontDelete); |
| 6851 context->Global()->Set(v8_str("func1"), t1->GetFunction()); |
| 6852 CHECK(CompileRun( |
| 6853 "(function() {" |
| 6854 " descriptor = Object.getOwnPropertyDescriptor(func1, 'prototype');" |
| 6855 " return (descriptor['writable'] == true) &&" |
| 6856 " (descriptor['enumerable'] == true) &&" |
| 6857 " (descriptor['configurable'] == false);" |
| 6858 "})()")->BooleanValue()); |
| 6859 |
| 6860 Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(); |
| 6861 t2->SetPrototypeAttributes(v8::DontEnum); |
| 6862 context->Global()->Set(v8_str("func2"), t2->GetFunction()); |
| 6863 CHECK(CompileRun( |
| 6864 "(function() {" |
| 6865 " descriptor = Object.getOwnPropertyDescriptor(func2, 'prototype');" |
| 6866 " return (descriptor['writable'] == true) &&" |
| 6867 " (descriptor['enumerable'] == false) &&" |
| 6868 " (descriptor['configurable'] == true);" |
| 6869 "})()")->BooleanValue()); |
| 6870 |
| 6871 Local<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(); |
| 6872 t3->SetPrototypeAttributes(v8::ReadOnly); |
| 6873 context->Global()->Set(v8_str("func3"), t3->GetFunction()); |
| 6874 CHECK(CompileRun( |
| 6875 "(function() {" |
| 6876 " descriptor = Object.getOwnPropertyDescriptor(func3, 'prototype');" |
| 6877 " return (descriptor['writable'] == false) &&" |
| 6878 " (descriptor['enumerable'] == true) &&" |
| 6879 " (descriptor['configurable'] == true);" |
| 6880 "})()")->BooleanValue()); |
| 6881 |
| 6882 Local<v8::FunctionTemplate> t4 = v8::FunctionTemplate::New(); |
| 6883 t4->SetPrototypeAttributes(v8::ReadOnly | v8::DontEnum | v8::DontDelete); |
| 6884 context->Global()->Set(v8_str("func4"), t4->GetFunction()); |
| 6885 CHECK(CompileRun( |
| 6886 "(function() {" |
| 6887 " descriptor = Object.getOwnPropertyDescriptor(func4, 'prototype');" |
| 6888 " return (descriptor['writable'] == false) &&" |
| 6889 " (descriptor['enumerable'] == false) &&" |
| 6890 " (descriptor['configurable'] == false);" |
| 6891 "})()")->BooleanValue()); |
| 6892 } |
| 6893 |
| 6894 |
6845 THREADED_TEST(SetPrototypeThrows) { | 6895 THREADED_TEST(SetPrototypeThrows) { |
6846 v8::HandleScope handle_scope; | 6896 v8::HandleScope handle_scope; |
6847 LocalContext context; | 6897 LocalContext context; |
6848 | 6898 |
6849 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(); | 6899 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(); |
6850 | 6900 |
6851 Local<v8::Object> o0 = t->GetFunction()->NewInstance(); | 6901 Local<v8::Object> o0 = t->GetFunction()->NewInstance(); |
6852 Local<v8::Object> o1 = t->GetFunction()->NewInstance(); | 6902 Local<v8::Object> o1 = t->GetFunction()->NewInstance(); |
6853 | 6903 |
6854 CHECK(o0->SetPrototype(o1)); | 6904 CHECK(o0->SetPrototype(o1)); |
(...skipping 7704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14559 CHECK_EQ(v8_str("DONT_CHANGE"), obj->Get(v8_str("1"))); | 14609 CHECK_EQ(v8_str("DONT_CHANGE"), obj->Get(v8_str("1"))); |
14560 obj->Set(v8_num(2), v8_str("DONT_CHANGE"), v8::ReadOnly); | 14610 obj->Set(v8_num(2), v8_str("DONT_CHANGE"), v8::ReadOnly); |
14561 obj->Set(v8_num(2), v8_str("foobar")); | 14611 obj->Set(v8_num(2), v8_str("foobar")); |
14562 CHECK_EQ(v8_str("DONT_CHANGE"), obj->Get(v8_num(2))); | 14612 CHECK_EQ(v8_str("DONT_CHANGE"), obj->Get(v8_num(2))); |
14563 | 14613 |
14564 // Test non-smi case. | 14614 // Test non-smi case. |
14565 obj->Set(v8_str("2000000000"), v8_str("DONT_CHANGE"), v8::ReadOnly); | 14615 obj->Set(v8_str("2000000000"), v8_str("DONT_CHANGE"), v8::ReadOnly); |
14566 obj->Set(v8_str("2000000000"), v8_str("foobar")); | 14616 obj->Set(v8_str("2000000000"), v8_str("foobar")); |
14567 CHECK_EQ(v8_str("DONT_CHANGE"), obj->Get(v8_str("2000000000"))); | 14617 CHECK_EQ(v8_str("DONT_CHANGE"), obj->Get(v8_str("2000000000"))); |
14568 } | 14618 } |
OLD | NEW |