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 13282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13293 v8_compile("new Object()")->Run(context.local()).ToLocalChecked(); | 13293 v8_compile("new Object()")->Run(context.local()).ToLocalChecked(); |
13294 value = object.As<v8::Object>() | 13294 value = object.As<v8::Object>() |
13295 ->ObjectProtoToString(context.local()) | 13295 ->ObjectProtoToString(context.local()) |
13296 .ToLocalChecked(); | 13296 .ToLocalChecked(); |
13297 CHECK(value->IsString() && | 13297 CHECK(value->IsString() && |
13298 value->Equals(context.local(), v8_str("[object Object]")).FromJust()); | 13298 value->Equals(context.local(), v8_str("[object Object]")).FromJust()); |
13299 } | 13299 } |
13300 | 13300 |
13301 | 13301 |
13302 TEST(ObjectProtoToStringES6) { | 13302 TEST(ObjectProtoToStringES6) { |
13303 // TODO(dslomov, caitp): merge into ObjectProtoToString test once shipped. | |
13304 i::FLAG_harmony_tostring = true; | |
13305 LocalContext context; | 13303 LocalContext context; |
13306 v8::Isolate* isolate = CcTest::isolate(); | 13304 v8::Isolate* isolate = CcTest::isolate(); |
13307 v8::HandleScope scope(isolate); | 13305 v8::HandleScope scope(isolate); |
13308 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate); | 13306 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate); |
13309 templ->SetClassName(v8_str("MyClass")); | 13307 templ->SetClassName(v8_str("MyClass")); |
13310 | 13308 |
13311 Local<String> customized_tostring = v8_str("customized toString"); | 13309 Local<String> customized_tostring = v8_str("customized toString"); |
13312 | 13310 |
13313 // Replace Object.prototype.toString | 13311 // Replace Object.prototype.toString |
13314 CompileRun( | 13312 CompileRun( |
(...skipping 11437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
24752 allowed_access = false; | 24750 allowed_access = false; |
24753 CompileRun("var result = [].concat(object)"); | 24751 CompileRun("var result = [].concat(object)"); |
24754 ExpectTrue("Array.isArray(result)"); | 24752 ExpectTrue("Array.isArray(result)"); |
24755 ExpectTrue("result[0] === object"); | 24753 ExpectTrue("result[0] === object"); |
24756 ExpectTrue("result.length === 1"); | 24754 ExpectTrue("result.length === 1"); |
24757 ExpectTrue("object[Symbol.isConcatSpreadable] === undefined"); | 24755 ExpectTrue("object[Symbol.isConcatSpreadable] === undefined"); |
24758 } | 24756 } |
24759 | 24757 |
24760 | 24758 |
24761 TEST(AccessCheckedToStringTag) { | 24759 TEST(AccessCheckedToStringTag) { |
24762 i::FLAG_harmony_tostring = true; | |
24763 v8::Isolate* isolate = CcTest::isolate(); | 24760 v8::Isolate* isolate = CcTest::isolate(); |
24764 HandleScope scope(isolate); | 24761 HandleScope scope(isolate); |
24765 LocalContext env; | 24762 LocalContext env; |
24766 | 24763 |
24767 // Object with access check | 24764 // Object with access check |
24768 Local<ObjectTemplate> object_template = v8::ObjectTemplate::New(isolate); | 24765 Local<ObjectTemplate> object_template = v8::ObjectTemplate::New(isolate); |
24769 object_template->SetAccessCheckCallback(AccessBlocker); | 24766 object_template->SetAccessCheckCallback(AccessBlocker); |
24770 Local<Object> object = | 24767 Local<Object> object = |
24771 object_template->NewInstance(env.local()).ToLocalChecked(); | 24768 object_template->NewInstance(env.local()).ToLocalChecked(); |
24772 | 24769 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
24853 CHECK(proxy->GetTarget()->SameValue(target)); | 24850 CHECK(proxy->GetTarget()->SameValue(target)); |
24854 CHECK(proxy->GetHandler()->SameValue(handler)); | 24851 CHECK(proxy->GetHandler()->SameValue(handler)); |
24855 | 24852 |
24856 proxy->Revoke(); | 24853 proxy->Revoke(); |
24857 CHECK(proxy->IsProxy()); | 24854 CHECK(proxy->IsProxy()); |
24858 CHECK(!target->IsProxy()); | 24855 CHECK(!target->IsProxy()); |
24859 CHECK(proxy->IsRevoked()); | 24856 CHECK(proxy->IsRevoked()); |
24860 CHECK(proxy->GetTarget()->SameValue(target)); | 24857 CHECK(proxy->GetTarget()->SameValue(target)); |
24861 CHECK(proxy->GetHandler()->IsNull()); | 24858 CHECK(proxy->GetHandler()->IsNull()); |
24862 } | 24859 } |
OLD | NEW |