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 21660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21671 v8::Handle<v8::FunctionTemplate> runtimeFunction = | 21671 v8::Handle<v8::FunctionTemplate> runtimeFunction = |
21672 v8::FunctionTemplate::New(isolate, ExtrasBindingTestRuntimeFunction); | 21672 v8::FunctionTemplate::New(isolate, ExtrasBindingTestRuntimeFunction); |
21673 binding->Set(v8_str("runtime"), runtimeFunction->GetFunction()); | 21673 binding->Set(v8_str("runtime"), runtimeFunction->GetFunction()); |
21674 func = binding->Get(v8_str("testExperimentalExtraShouldCallToRuntime")) | 21674 func = binding->Get(v8_str("testExperimentalExtraShouldCallToRuntime")) |
21675 .As<v8::Function>(); | 21675 .As<v8::Function>(); |
21676 result = func->Call(undefined, 0, {}).As<v8::Number>(); | 21676 result = func->Call(undefined, 0, {}).As<v8::Number>(); |
21677 CHECK_EQ(7, result->Int32Value()); | 21677 CHECK_EQ(7, result->Int32Value()); |
21678 } | 21678 } |
21679 | 21679 |
21680 | 21680 |
| 21681 TEST(ExtrasUtilsObject) { |
| 21682 LocalContext context; |
| 21683 v8::Isolate* isolate = context->GetIsolate(); |
| 21684 v8::HandleScope handle_scope(isolate); |
| 21685 |
| 21686 LocalContext env; |
| 21687 v8::Local<v8::Object> binding = env->GetExtrasBindingObject(); |
| 21688 |
| 21689 auto func = binding->Get(v8_str("testExtraCanUseUtils")).As<v8::Function>(); |
| 21690 auto undefined = v8::Undefined(isolate); |
| 21691 auto result = func->Call(undefined, 0, {}).As<v8::Object>(); |
| 21692 |
| 21693 auto private_symbol = result->Get(v8_str("privateSymbol")).As<v8::Symbol>(); |
| 21694 i::Handle<i::Symbol> ips = v8::Utils::OpenHandle(*private_symbol); |
| 21695 CHECK_EQ(true, ips->IsPrivate()); |
| 21696 |
| 21697 CompileRun("var result = 0; function store(x) { result = x; }"); |
| 21698 auto store = CompileRun("store").As<v8::Function>(); |
| 21699 |
| 21700 auto fulfilled_promise = |
| 21701 result->Get(v8_str("fulfilledPromise")).As<v8::Promise>(); |
| 21702 fulfilled_promise->Then(store); |
| 21703 isolate->RunMicrotasks(); |
| 21704 CHECK_EQ(1, CompileRun("result")->Int32Value()); |
| 21705 |
| 21706 auto fulfilled_promise_2 = |
| 21707 result->Get(v8_str("fulfilledPromise2")).As<v8::Promise>(); |
| 21708 fulfilled_promise_2->Then(store); |
| 21709 isolate->RunMicrotasks(); |
| 21710 CHECK_EQ(2, CompileRun("result")->Int32Value()); |
| 21711 |
| 21712 auto rejected_promise = |
| 21713 result->Get(v8_str("rejectedPromise")).As<v8::Promise>(); |
| 21714 rejected_promise->Catch(store); |
| 21715 isolate->RunMicrotasks(); |
| 21716 CHECK_EQ(3, CompileRun("result")->Int32Value()); |
| 21717 } |
| 21718 |
| 21719 |
21681 TEST(Map) { | 21720 TEST(Map) { |
21682 v8::Isolate* isolate = CcTest::isolate(); | 21721 v8::Isolate* isolate = CcTest::isolate(); |
21683 v8::HandleScope handle_scope(isolate); | 21722 v8::HandleScope handle_scope(isolate); |
21684 LocalContext env; | 21723 LocalContext env; |
21685 | 21724 |
21686 v8::Local<v8::Map> map = v8::Map::New(isolate); | 21725 v8::Local<v8::Map> map = v8::Map::New(isolate); |
21687 CHECK(map->IsObject()); | 21726 CHECK(map->IsObject()); |
21688 CHECK(map->IsMap()); | 21727 CHECK(map->IsMap()); |
21689 CHECK(map->GetPrototype()->StrictEquals(CompileRun("Map.prototype"))); | 21728 CHECK(map->GetPrototype()->StrictEquals(CompileRun("Map.prototype"))); |
21690 CHECK_EQ(0U, map->Size()); | 21729 CHECK_EQ(0U, map->Size()); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21850 timeout_thread.Join(); | 21889 timeout_thread.Join(); |
21851 } | 21890 } |
21852 | 21891 |
21853 | 21892 |
21854 TEST(EstimatedContextSize) { | 21893 TEST(EstimatedContextSize) { |
21855 v8::Isolate* isolate = CcTest::isolate(); | 21894 v8::Isolate* isolate = CcTest::isolate(); |
21856 v8::HandleScope scope(isolate); | 21895 v8::HandleScope scope(isolate); |
21857 LocalContext env; | 21896 LocalContext env; |
21858 CHECK(50000 < env->EstimatedSize()); | 21897 CHECK(50000 < env->EstimatedSize()); |
21859 } | 21898 } |
OLD | NEW |