33 namespace i = v8::internal;
36 class HarmonyIsolate {
48 Isolate* GetIsolate()
const {
return isolate_; }
56 TEST(MicrotaskDeliverySimple) {
57 HarmonyIsolate isolate;
63 "function handler(resolve) { resolver.resolve = resolve; }"
65 "var observeOrders = [1, 4];"
66 "function observer() {"
67 "ordering.push(observeOrders.shift());"
70 "var p = new Promise(handler);"
73 "}).then(function() {"
76 "return new Promise(handler);"
77 "}).then(function() {"
79 "}).then(function() {"
82 "Object.observe(obj, observer);"
84 CHECK_EQ(6, CompileRun(
"ordering.length")->Int32Value());
85 CHECK_EQ(1, CompileRun(
"ordering[0]")->Int32Value());
86 CHECK_EQ(2, CompileRun(
"ordering[1]")->Int32Value());
87 CHECK_EQ(3, CompileRun(
"ordering[2]")->Int32Value());
88 CHECK_EQ(4, CompileRun(
"ordering[3]")->Int32Value());
89 CHECK_EQ(5, CompileRun(
"ordering[4]")->Int32Value());
90 CHECK_EQ(6, CompileRun(
"ordering[5]")->Int32Value());
94 TEST(MicrotaskPerIsolateState) {
95 HarmonyIsolate isolate;
100 "var obj = { calls: 0 };");
108 "new Promise(function(resolve) {"
109 "resolver.resolve = resolve;"
110 "}).then(function() {"
114 "resolver.resolve();"
122 "var foo = { id: 1 };"
123 "Object.observe(foo, function() {"
133 CHECK_EQ(2, CompileRun(
"obj.calls")->Int32Value());
#define CHECK_EQ(expected, value)
TEST(MicrotaskDeliverySimple)
static void SetAutorunMicrotasks(Isolate *source, bool autorun)
static void RunMicrotasks(Isolate *isolate)
static Local< String > NewFromUtf8(Isolate *isolate, const char *data, NewStringType type=kNormalString, int length=-1)