Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(794)

Unified Diff: test/cctest/test-api.cc

Issue 1343113003: Implement V8 extras utils object (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove call/apply helpers Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/promise.js ('k') | test/cctest/test-extra.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index df502cb177e6d8ee103668a80c57c6c689f01bd3..747aca58af3e8ee7e15cbe03680c6da07fb9c5fe 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -21678,6 +21678,45 @@ TEST(ExperimentalExtras) {
}
+TEST(ExtrasUtilsObject) {
+ LocalContext context;
+ v8::Isolate* isolate = context->GetIsolate();
+ v8::HandleScope handle_scope(isolate);
+
+ LocalContext env;
+ v8::Local<v8::Object> binding = env->GetExtrasBindingObject();
+
+ auto func = binding->Get(v8_str("testExtraCanUseUtils")).As<v8::Function>();
+ auto undefined = v8::Undefined(isolate);
+ auto result = func->Call(undefined, 0, {}).As<v8::Object>();
+
+ auto private_symbol = result->Get(v8_str("privateSymbol")).As<v8::Symbol>();
+ i::Handle<i::Symbol> ips = v8::Utils::OpenHandle(*private_symbol);
+ CHECK_EQ(true, ips->IsPrivate());
+
+ CompileRun("var result = 0; function store(x) { result = x; }");
+ auto store = CompileRun("store").As<v8::Function>();
+
+ auto fulfilled_promise =
+ result->Get(v8_str("fulfilledPromise")).As<v8::Promise>();
+ fulfilled_promise->Then(store);
+ isolate->RunMicrotasks();
+ CHECK_EQ(1, CompileRun("result")->Int32Value());
+
+ auto fulfilled_promise_2 =
+ result->Get(v8_str("fulfilledPromise2")).As<v8::Promise>();
+ fulfilled_promise_2->Then(store);
+ isolate->RunMicrotasks();
+ CHECK_EQ(2, CompileRun("result")->Int32Value());
+
+ auto rejected_promise =
+ result->Get(v8_str("rejectedPromise")).As<v8::Promise>();
+ rejected_promise->Catch(store);
+ isolate->RunMicrotasks();
+ CHECK_EQ(3, CompileRun("result")->Int32Value());
+}
+
+
TEST(Map) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope handle_scope(isolate);
« no previous file with comments | « src/promise.js ('k') | test/cctest/test-extra.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698