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 17970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17981 // Global object, the prototype of proxy_object. No security checks. | 17981 // Global object, the prototype of proxy_object. No security checks. |
17982 Local<Object> global_object = proxy_object->GetPrototype()->ToObject(isolate); | 17982 Local<Object> global_object = proxy_object->GetPrototype()->ToObject(isolate); |
17983 | 17983 |
17984 // Hidden prototype without security check. | 17984 // Hidden prototype without security check. |
17985 Local<Object> hidden_prototype = | 17985 Local<Object> hidden_prototype = |
17986 hidden_proto_template->GetFunction()->NewInstance(); | 17986 hidden_proto_template->GetFunction()->NewInstance(); |
17987 Local<Object> object_with_hidden = | 17987 Local<Object> object_with_hidden = |
17988 Object::New(isolate); | 17988 Object::New(isolate); |
17989 object_with_hidden->SetPrototype(hidden_prototype); | 17989 object_with_hidden->SetPrototype(hidden_prototype); |
17990 | 17990 |
17991 // Hidden prototype with security check on the hidden prototype. | |
17992 Local<Object> protected_hidden_prototype = | |
17993 protected_hidden_proto_template->GetFunction()->NewInstance(); | |
17994 Local<Object> object_with_protected_hidden = | |
17995 Object::New(isolate); | |
17996 object_with_protected_hidden->SetPrototype(protected_hidden_prototype); | |
17997 | |
17998 context->Exit(); | 17991 context->Exit(); |
17999 | 17992 |
18000 // Template for object for second context. Values to test are put on it as | 17993 // Template for object for second context. Values to test are put on it as |
18001 // properties. | 17994 // properties. |
18002 Local<ObjectTemplate> global_template = ObjectTemplate::New(isolate); | 17995 Local<ObjectTemplate> global_template = ObjectTemplate::New(isolate); |
18003 global_template->Set(v8_str("simple"), simple_object); | 17996 global_template->Set(v8_str("simple"), simple_object); |
18004 global_template->Set(v8_str("protected"), protected_object); | 17997 global_template->Set(v8_str("protected"), protected_object); |
18005 global_template->Set(v8_str("global"), global_object); | 17998 global_template->Set(v8_str("global"), global_object); |
18006 global_template->Set(v8_str("proxy"), proxy_object); | 17999 global_template->Set(v8_str("proxy"), proxy_object); |
18007 global_template->Set(v8_str("hidden"), object_with_hidden); | 18000 global_template->Set(v8_str("hidden"), object_with_hidden); |
18008 global_template->Set(v8_str("phidden"), object_with_protected_hidden); | |
18009 | 18001 |
18010 LocalContext context2(NULL, global_template); | 18002 LocalContext context2(NULL, global_template); |
18011 | 18003 |
18012 Local<Value> result1 = CompileRun("Object.getPrototypeOf(simple)"); | 18004 Local<Value> result1 = CompileRun("Object.getPrototypeOf(simple)"); |
18013 CHECK(result1->Equals(simple_object->GetPrototype())); | 18005 CHECK(result1->Equals(simple_object->GetPrototype())); |
18014 | 18006 |
18015 Local<Value> result2 = CompileRun("Object.getPrototypeOf(protected)"); | 18007 Local<Value> result2 = CompileRun("Object.getPrototypeOf(protected)"); |
18016 CHECK(result2->IsNull()); | 18008 CHECK(result2->IsNull()); |
18017 | 18009 |
18018 Local<Value> result3 = CompileRun("Object.getPrototypeOf(global)"); | 18010 Local<Value> result3 = CompileRun("Object.getPrototypeOf(global)"); |
18019 CHECK(result3->Equals(global_object->GetPrototype())); | 18011 CHECK(result3->Equals(global_object->GetPrototype())); |
18020 | 18012 |
18021 Local<Value> result4 = CompileRun("Object.getPrototypeOf(proxy)"); | 18013 Local<Value> result4 = CompileRun("Object.getPrototypeOf(proxy)"); |
18022 CHECK(result4->IsNull()); | 18014 CHECK(result4->IsNull()); |
18023 | 18015 |
18024 Local<Value> result5 = CompileRun("Object.getPrototypeOf(hidden)"); | 18016 Local<Value> result5 = CompileRun("Object.getPrototypeOf(hidden)"); |
18025 CHECK(result5->Equals( | 18017 CHECK(result5->Equals( |
18026 object_with_hidden->GetPrototype()->ToObject(isolate)->GetPrototype())); | 18018 object_with_hidden->GetPrototype()->ToObject(isolate)->GetPrototype())); |
18027 | |
18028 Local<Value> result6 = CompileRun("Object.getPrototypeOf(phidden)"); | |
18029 CHECK(result6->IsNull()); | |
18030 } | 18019 } |
18031 | 18020 |
18032 | 18021 |
18033 static void TestReceiver(Local<Value> expected_result, | 18022 static void TestReceiver(Local<Value> expected_result, |
18034 Local<Value> expected_receiver, | 18023 Local<Value> expected_receiver, |
18035 const char* code) { | 18024 const char* code) { |
18036 Local<Value> result = CompileRun(code); | 18025 Local<Value> result = CompileRun(code); |
18037 CHECK(result->IsObject()); | 18026 CHECK(result->IsObject()); |
18038 CHECK(expected_receiver->Equals(result.As<v8::Object>()->Get(1))); | 18027 CHECK(expected_receiver->Equals(result.As<v8::Object>()->Get(1))); |
18039 CHECK(expected_result->Equals(result.As<v8::Object>()->Get(0))); | 18028 CHECK(expected_result->Equals(result.As<v8::Object>()->Get(0))); |
(...skipping 3899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21939 LocalContext env; | 21928 LocalContext env; |
21940 | 21929 |
21941 env->Global()->Set(v8_str("keys"), v8::Array::GetKeysIterator(isolate)); | 21930 env->Global()->Set(v8_str("keys"), v8::Array::GetKeysIterator(isolate)); |
21942 env->Global()->Set(v8_str("values"), v8::Array::GetValuesIterator(isolate)); | 21931 env->Global()->Set(v8_str("values"), v8::Array::GetValuesIterator(isolate)); |
21943 env->Global()->Set(v8_str("entries"), v8::Array::GetEntriesIterator(isolate)); | 21932 env->Global()->Set(v8_str("entries"), v8::Array::GetEntriesIterator(isolate)); |
21944 | 21933 |
21945 ExpectString("typeof keys", "function"); | 21934 ExpectString("typeof keys", "function"); |
21946 ExpectString("typeof values", "function"); | 21935 ExpectString("typeof values", "function"); |
21947 ExpectString("typeof entries", "function"); | 21936 ExpectString("typeof entries", "function"); |
21948 } | 21937 } |
OLD | NEW |