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 22000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22011 // If access check fails, the value of @@isConcatSpreadable is ignored | 22011 // If access check fails, the value of @@isConcatSpreadable is ignored |
22012 allowed_access = false; | 22012 allowed_access = false; |
22013 CompileRun("var result = [].concat(object)"); | 22013 CompileRun("var result = [].concat(object)"); |
22014 ExpectTrue("Array.isArray(result)"); | 22014 ExpectTrue("Array.isArray(result)"); |
22015 ExpectTrue("result[0] === object"); | 22015 ExpectTrue("result[0] === object"); |
22016 ExpectTrue("result.length === 1"); | 22016 ExpectTrue("result.length === 1"); |
22017 ExpectTrue("object[Symbol.isConcatSpreadable] === undefined"); | 22017 ExpectTrue("object[Symbol.isConcatSpreadable] === undefined"); |
22018 } | 22018 } |
22019 | 22019 |
22020 | 22020 |
| 22021 TEST(AccessCheckedToStringTag) { |
| 22022 i::FLAG_harmony_tostring = true; |
| 22023 v8::Isolate* isolate = CcTest::isolate(); |
| 22024 HandleScope scope(isolate); |
| 22025 LocalContext env; |
| 22026 |
| 22027 // Object with access check |
| 22028 Local<ObjectTemplate> object_template = v8::ObjectTemplate::New(isolate); |
| 22029 object_template->SetAccessCheckCallback(AccessBlocker); |
| 22030 Local<Object> object = object_template->NewInstance(); |
| 22031 |
| 22032 allowed_access = true; |
| 22033 env->Global()->Set(v8_str("object"), object); |
| 22034 object->Set(v8::Symbol::GetToStringTag(isolate), v8_str("hello")); |
| 22035 |
| 22036 // Access check is allowed, and the toStringTag is read |
| 22037 CompileRun("var result = Object.prototype.toString.call(object)"); |
| 22038 ExpectString("result", "[object hello]"); |
| 22039 ExpectString("object[Symbol.toStringTag]", "hello"); |
| 22040 |
| 22041 // If access check fails, the value of @@toStringTag is ignored |
| 22042 allowed_access = false; |
| 22043 CompileRun("var result = Object.prototype.toString.call(object)"); |
| 22044 ExpectString("result", "[object Object]"); |
| 22045 ExpectTrue("object[Symbol.toStringTag] === undefined"); |
| 22046 } |
| 22047 |
| 22048 |
22021 TEST(ObjectTemplateIntrinsics) { | 22049 TEST(ObjectTemplateIntrinsics) { |
22022 v8::Isolate* isolate = CcTest::isolate(); | 22050 v8::Isolate* isolate = CcTest::isolate(); |
22023 v8::HandleScope scope(isolate); | 22051 v8::HandleScope scope(isolate); |
22024 LocalContext env; | 22052 LocalContext env; |
22025 | 22053 |
22026 Local<ObjectTemplate> object_template = v8::ObjectTemplate::New(isolate); | 22054 Local<ObjectTemplate> object_template = v8::ObjectTemplate::New(isolate); |
22027 object_template->SetIntrinsicDataProperty(v8_str("values"), | 22055 object_template->SetIntrinsicDataProperty(v8_str("values"), |
22028 v8::kArrayProto_values); | 22056 v8::kArrayProto_values); |
22029 Local<Object> object = object_template->NewInstance(); | 22057 Local<Object> object = object_template->NewInstance(); |
22030 | 22058 |
(...skipping 11 matching lines...) Expand all Loading... |
22042 env2->Global()->Set(v8_str("obj2"), object2); | 22070 env2->Global()->Set(v8_str("obj2"), object2); |
22043 ExpectString("typeof obj2.values", "function"); | 22071 ExpectString("typeof obj2.values", "function"); |
22044 CHECK_NE(*object->Get(v8_str("values")), *object2->Get(v8_str("values"))); | 22072 CHECK_NE(*object->Get(v8_str("values")), *object2->Get(v8_str("values"))); |
22045 | 22073 |
22046 auto values2 = Local<Function>::Cast(object2->Get(v8_str("values"))); | 22074 auto values2 = Local<Function>::Cast(object2->Get(v8_str("values"))); |
22047 auto fn2 = i::Handle<i::JSFunction>::cast(v8::Utils::OpenHandle(*values2)); | 22075 auto fn2 = i::Handle<i::JSFunction>::cast(v8::Utils::OpenHandle(*values2)); |
22048 auto ctx2 = v8::Utils::OpenHandle(*env2.local()); | 22076 auto ctx2 = v8::Utils::OpenHandle(*env2.local()); |
22049 CHECK_EQ(fn2->GetCreationContext(), *ctx2); | 22077 CHECK_EQ(fn2->GetCreationContext(), *ctx2); |
22050 } | 22078 } |
22051 } | 22079 } |
OLD | NEW |