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

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

Side-by-side diff isn't available for this file because of its large size.
Issue 2578173004: [promisehook] Fire init hook for promise subclass (Closed)
Patch Set: extend test Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
Download patch
« no previous file with comments | « no previous file | no next file » | 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 ca2c8dea063c4fca55ad398b7e1c8897f15900b6..2273651d0824fc84079aa6301bd9e43bd509739a 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -18421,7 +18421,33 @@ TEST(PromiseHook) {
v8_str(promise_hook_data->promise_hook_value.c_str()))
.FromJust());
+ promise_hook_data->Reset();
+ promise_hook_data->promise_hook_value = "subclass";
+ source =
+ "var resolve, value = '';\n"
+ "class MyPromise extends Promise {};\n"
+ "var p = new MyPromise(r => resolve = r);\n"
+ "var p1 = p.then(() => value = 'subclass');\n";
+
+ CompileRun(source);
+ // No init hook for subclasses
Dan Ehrenberg 2016/12/20 16:29:38 Is this behavior intentional? Maybe the Promise co
+ CHECK_EQ(0, promise_hook_data->promise_hook_count);
+
+ CompileRun("resolve();\n");
+ resolve_promise = global->Get(context, v8_str("resolve")).ToLocalChecked();
+ before_promise = global->Get(context, v8_str("before")).ToLocalChecked();
+ after_promise = global->Get(context, v8_str("after")).ToLocalChecked();
+ CHECK(GetPromise("p")->Equals(env.local(), before_promise).FromJust());
+ CHECK(GetPromise("p")->Equals(env.local(), after_promise).FromJust());
+ CHECK(GetPromise("p1")->Equals(env.local(), resolve_promise).FromJust());
+ // 1) resolve hook (p)
+ // 2) before hook (p)
+ // 3) after hook (p)
+ // 4) resolve hook (p1)
+ CHECK_EQ(4, promise_hook_data->promise_hook_count);
+
delete promise_hook_data;
+ isolate->SetPromiseHook(nullptr);
}
void AnalyzeStackOfDynamicScriptWithSourceURL(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698