| 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 13203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13214 CHECK(context->Global() | 13214 CHECK(context->Global() |
| 13215 ->Set(context.local(), v8_str("f"), | 13215 ->Set(context.local(), v8_str("f"), |
| 13216 templ->GetFunction(context.local()).ToLocalChecked()) | 13216 templ->GetFunction(context.local()).ToLocalChecked()) |
| 13217 .FromJust()); | 13217 .FromJust()); |
| 13218 Local<Value> value = v8_compile("f()")->Run(context.local()).ToLocalChecked(); | 13218 Local<Value> value = v8_compile("f()")->Run(context.local()).ToLocalChecked(); |
| 13219 CHECK(!value->BooleanValue(context.local()).FromJust()); | 13219 CHECK(!value->BooleanValue(context.local()).FromJust()); |
| 13220 value = v8_compile("new f()")->Run(context.local()).ToLocalChecked(); | 13220 value = v8_compile("new f()")->Run(context.local()).ToLocalChecked(); |
| 13221 CHECK(value->BooleanValue(context.local()).FromJust()); | 13221 CHECK(value->BooleanValue(context.local()).FromJust()); |
| 13222 } | 13222 } |
| 13223 | 13223 |
| 13224 static void NewTargetHandler(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 13225 ApiTestFuzzer::Fuzz(); |
| 13226 args.GetReturnValue().Set(args.NewTarget()); |
| 13227 } |
| 13228 |
| 13229 THREADED_TEST(NewTargetHandler) { |
| 13230 v8::Isolate* isolate = CcTest::isolate(); |
| 13231 v8::HandleScope scope(isolate); |
| 13232 |
| 13233 // Function template with call handler. |
| 13234 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate); |
| 13235 templ->SetCallHandler(NewTargetHandler); |
| 13236 |
| 13237 LocalContext context; |
| 13238 |
| 13239 Local<Function> function = |
| 13240 templ->GetFunction(context.local()).ToLocalChecked(); |
| 13241 CHECK(context->Global() |
| 13242 ->Set(context.local(), v8_str("f"), function) |
| 13243 .FromJust()); |
| 13244 Local<Value> value = CompileRun("f()"); |
| 13245 CHECK(value->IsUndefined()); |
| 13246 value = CompileRun("new f()"); |
| 13247 CHECK(value->IsFunction()); |
| 13248 CHECK(value == function); |
| 13249 Local<Value> subclass = CompileRun("var g = class extends f { }; g"); |
| 13250 CHECK(subclass->IsFunction()); |
| 13251 value = CompileRun("new g()"); |
| 13252 CHECK(value->IsFunction()); |
| 13253 CHECK(value == subclass); |
| 13254 value = CompileRun("Reflect.construct(f, [], Array)"); |
| 13255 CHECK(value->IsFunction()); |
| 13256 CHECK(value == |
| 13257 context->Global() |
| 13258 ->Get(context.local(), v8_str("Array")) |
| 13259 .ToLocalChecked()); |
| 13260 } |
| 13224 | 13261 |
| 13225 THREADED_TEST(ObjectProtoToString) { | 13262 THREADED_TEST(ObjectProtoToString) { |
| 13226 v8::Isolate* isolate = CcTest::isolate(); | 13263 v8::Isolate* isolate = CcTest::isolate(); |
| 13227 v8::HandleScope scope(isolate); | 13264 v8::HandleScope scope(isolate); |
| 13228 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate); | 13265 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate); |
| 13229 templ->SetClassName(v8_str("MyClass")); | 13266 templ->SetClassName(v8_str("MyClass")); |
| 13230 | 13267 |
| 13231 LocalContext context; | 13268 LocalContext context; |
| 13232 | 13269 |
| 13233 Local<String> customized_tostring = v8_str("customized toString"); | 13270 Local<String> customized_tostring = v8_str("customized toString"); |
| (...skipping 11733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 24967 } | 25004 } |
| 24968 | 25005 |
| 24969 TEST(PrivateForApiIsNumber) { | 25006 TEST(PrivateForApiIsNumber) { |
| 24970 LocalContext context; | 25007 LocalContext context; |
| 24971 v8::Isolate* isolate = CcTest::isolate(); | 25008 v8::Isolate* isolate = CcTest::isolate(); |
| 24972 v8::HandleScope scope(isolate); | 25009 v8::HandleScope scope(isolate); |
| 24973 | 25010 |
| 24974 // Shouldn't crash. | 25011 // Shouldn't crash. |
| 24975 v8::Private::ForApi(isolate, v8_str("42")); | 25012 v8::Private::ForApi(isolate, v8_str("42")); |
| 24976 } | 25013 } |
| OLD | NEW |