| 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 17971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17982 // Global object, the prototype of proxy_object. No security checks. | 17982 // Global object, the prototype of proxy_object. No security checks. |
| 17983 Local<Object> global_object = proxy_object->GetPrototype()->ToObject(isolate); | 17983 Local<Object> global_object = proxy_object->GetPrototype()->ToObject(isolate); |
| 17984 | 17984 |
| 17985 // Hidden prototype without security check. | 17985 // Hidden prototype without security check. |
| 17986 Local<Object> hidden_prototype = | 17986 Local<Object> hidden_prototype = |
| 17987 hidden_proto_template->GetFunction()->NewInstance(); | 17987 hidden_proto_template->GetFunction()->NewInstance(); |
| 17988 Local<Object> object_with_hidden = | 17988 Local<Object> object_with_hidden = |
| 17989 Object::New(isolate); | 17989 Object::New(isolate); |
| 17990 object_with_hidden->SetPrototype(hidden_prototype); | 17990 object_with_hidden->SetPrototype(hidden_prototype); |
| 17991 | 17991 |
| 17992 // Hidden prototype with security check on the hidden prototype. | |
| 17993 Local<Object> protected_hidden_prototype = | |
| 17994 protected_hidden_proto_template->GetFunction()->NewInstance(); | |
| 17995 Local<Object> object_with_protected_hidden = | |
| 17996 Object::New(isolate); | |
| 17997 object_with_protected_hidden->SetPrototype(protected_hidden_prototype); | |
| 17998 | |
| 17999 context->Exit(); | 17992 context->Exit(); |
| 18000 | 17993 |
| 18001 // Template for object for second context. Values to test are put on it as | 17994 // Template for object for second context. Values to test are put on it as |
| 18002 // properties. | 17995 // properties. |
| 18003 Local<ObjectTemplate> global_template = ObjectTemplate::New(isolate); | 17996 Local<ObjectTemplate> global_template = ObjectTemplate::New(isolate); |
| 18004 global_template->Set(v8_str("simple"), simple_object); | 17997 global_template->Set(v8_str("simple"), simple_object); |
| 18005 global_template->Set(v8_str("protected"), protected_object); | 17998 global_template->Set(v8_str("protected"), protected_object); |
| 18006 global_template->Set(v8_str("global"), global_object); | 17999 global_template->Set(v8_str("global"), global_object); |
| 18007 global_template->Set(v8_str("proxy"), proxy_object); | 18000 global_template->Set(v8_str("proxy"), proxy_object); |
| 18008 global_template->Set(v8_str("hidden"), object_with_hidden); | 18001 global_template->Set(v8_str("hidden"), object_with_hidden); |
| 18009 global_template->Set(v8_str("phidden"), object_with_protected_hidden); | |
| 18010 | 18002 |
| 18011 LocalContext context2(NULL, global_template); | 18003 LocalContext context2(NULL, global_template); |
| 18012 | 18004 |
| 18013 Local<Value> result1 = CompileRun("Object.getPrototypeOf(simple)"); | 18005 Local<Value> result1 = CompileRun("Object.getPrototypeOf(simple)"); |
| 18014 CHECK(result1->Equals(simple_object->GetPrototype())); | 18006 CHECK(result1->Equals(simple_object->GetPrototype())); |
| 18015 | 18007 |
| 18016 Local<Value> result2 = CompileRun("Object.getPrototypeOf(protected)"); | 18008 Local<Value> result2 = CompileRun("Object.getPrototypeOf(protected)"); |
| 18017 CHECK(result2->IsNull()); | 18009 CHECK(result2->IsNull()); |
| 18018 | 18010 |
| 18019 Local<Value> result3 = CompileRun("Object.getPrototypeOf(global)"); | 18011 Local<Value> result3 = CompileRun("Object.getPrototypeOf(global)"); |
| 18020 CHECK(result3->Equals(global_object->GetPrototype())); | 18012 CHECK(result3->Equals(global_object->GetPrototype())); |
| 18021 | 18013 |
| 18022 Local<Value> result4 = CompileRun("Object.getPrototypeOf(proxy)"); | 18014 Local<Value> result4 = CompileRun("Object.getPrototypeOf(proxy)"); |
| 18023 CHECK(result4->IsNull()); | 18015 CHECK(result4->IsNull()); |
| 18024 | 18016 |
| 18025 Local<Value> result5 = CompileRun("Object.getPrototypeOf(hidden)"); | 18017 Local<Value> result5 = CompileRun("Object.getPrototypeOf(hidden)"); |
| 18026 CHECK(result5->Equals( | 18018 CHECK(result5->Equals( |
| 18027 object_with_hidden->GetPrototype()->ToObject(isolate)->GetPrototype())); | 18019 object_with_hidden->GetPrototype()->ToObject(isolate)->GetPrototype())); |
| 18028 | |
| 18029 Local<Value> result6 = CompileRun("Object.getPrototypeOf(phidden)"); | |
| 18030 CHECK(result6->IsNull()); | |
| 18031 } | 18020 } |
| 18032 | 18021 |
| 18033 | 18022 |
| 18034 static void TestReceiver(Local<Value> expected_result, | 18023 static void TestReceiver(Local<Value> expected_result, |
| 18035 Local<Value> expected_receiver, | 18024 Local<Value> expected_receiver, |
| 18036 const char* code) { | 18025 const char* code) { |
| 18037 Local<Value> result = CompileRun(code); | 18026 Local<Value> result = CompileRun(code); |
| 18038 CHECK(result->IsObject()); | 18027 CHECK(result->IsObject()); |
| 18039 CHECK(expected_receiver->Equals(result.As<v8::Object>()->Get(1))); | 18028 CHECK(expected_receiver->Equals(result.As<v8::Object>()->Get(1))); |
| 18040 CHECK(expected_result->Equals(result.As<v8::Object>()->Get(0))); | 18029 CHECK(expected_result->Equals(result.As<v8::Object>()->Get(0))); |
| (...skipping 3884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 21925 ExpectTrue("object[Symbol.isConcatSpreadable]"); | 21914 ExpectTrue("object[Symbol.isConcatSpreadable]"); |
| 21926 | 21915 |
| 21927 // If access check fails, the value of @@isConcatSpreadable is ignored | 21916 // If access check fails, the value of @@isConcatSpreadable is ignored |
| 21928 allowed_access = false; | 21917 allowed_access = false; |
| 21929 CompileRun("var result = [].concat(object)"); | 21918 CompileRun("var result = [].concat(object)"); |
| 21930 ExpectTrue("Array.isArray(result)"); | 21919 ExpectTrue("Array.isArray(result)"); |
| 21931 ExpectTrue("result[0] === object"); | 21920 ExpectTrue("result[0] === object"); |
| 21932 ExpectTrue("result.length === 1"); | 21921 ExpectTrue("result.length === 1"); |
| 21933 ExpectTrue("object[Symbol.isConcatSpreadable] === undefined"); | 21922 ExpectTrue("object[Symbol.isConcatSpreadable] === undefined"); |
| 21934 } | 21923 } |
| OLD | NEW |