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 21903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21914 ExpectTrue("object[Symbol.isConcatSpreadable]"); | 21914 ExpectTrue("object[Symbol.isConcatSpreadable]"); |
21915 | 21915 |
21916 // If access check fails, the value of @@isConcatSpreadable is ignored | 21916 // If access check fails, the value of @@isConcatSpreadable is ignored |
21917 allowed_access = false; | 21917 allowed_access = false; |
21918 CompileRun("var result = [].concat(object)"); | 21918 CompileRun("var result = [].concat(object)"); |
21919 ExpectTrue("Array.isArray(result)"); | 21919 ExpectTrue("Array.isArray(result)"); |
21920 ExpectTrue("result[0] === object"); | 21920 ExpectTrue("result[0] === object"); |
21921 ExpectTrue("result.length === 1"); | 21921 ExpectTrue("result.length === 1"); |
21922 ExpectTrue("object[Symbol.isConcatSpreadable] === undefined"); | 21922 ExpectTrue("object[Symbol.isConcatSpreadable] === undefined"); |
21923 } | 21923 } |
| 21924 |
| 21925 |
| 21926 TEST(ObjectTemplateIntrinsics) { |
| 21927 v8::Isolate* isolate = CcTest::isolate(); |
| 21928 v8::HandleScope scope(isolate); |
| 21929 LocalContext env; |
| 21930 |
| 21931 Local<ObjectTemplate> object_template = v8::ObjectTemplate::New(isolate); |
| 21932 object_template->SetIntrinsicDataProperty(v8_str("values"), |
| 21933 v8::kArrayProto_values); |
| 21934 Local<Object> object = object_template->NewInstance(); |
| 21935 |
| 21936 env->Global()->Set(v8_str("obj1"), object); |
| 21937 ExpectString("typeof obj1.values", "function"); |
| 21938 |
| 21939 auto values = Local<Function>::Cast(object->Get(v8_str("values"))); |
| 21940 auto fn = v8::Utils::OpenHandle(*values); |
| 21941 auto ctx = v8::Utils::OpenHandle(*env.local()); |
| 21942 CHECK_EQ(fn->GetCreationContext(), *ctx); |
| 21943 |
| 21944 { |
| 21945 LocalContext env2; |
| 21946 Local<Object> object2 = object_template->NewInstance(); |
| 21947 env2->Global()->Set(v8_str("obj2"), object2); |
| 21948 ExpectString("typeof obj2.values", "function"); |
| 21949 CHECK_NE(*object->Get(v8_str("values")), *object2->Get(v8_str("values"))); |
| 21950 |
| 21951 auto values2 = Local<Function>::Cast(object2->Get(v8_str("values"))); |
| 21952 auto fn2 = v8::Utils::OpenHandle(*values2); |
| 21953 auto ctx2 = v8::Utils::OpenHandle(*env2.local()); |
| 21954 CHECK_EQ(fn2->GetCreationContext(), *ctx2); |
| 21955 } |
| 21956 } |
OLD | NEW |