fix: add microtask runner and fix promise test (#15071)

* fix: Promise resolution and unit test

* Update to use microtask runner

* Address review
This commit is contained in:
Nitish Sakhawalkar 2018-10-15 08:26:47 -07:00 committed by Samuel Attard
parent 89bf71e580
commit 0c711f690e
13 changed files with 90 additions and 18 deletions

View file

@ -21,8 +21,7 @@ v8::Maybe<bool> Promise::RejectWithErrorMessage(const std::string& string) {
v8::Local<v8::String> error_message =
v8::String::NewFromUtf8(isolate(), string.c_str());
v8::Local<v8::Value> error = v8::Exception::Error(error_message);
return GetInner()->Reject(isolate()->GetCurrentContext(),
mate::ConvertToV8(isolate(), error));
return Reject(error);
}
v8::Local<v8::Promise> Promise::GetHandle() const {

View file

@ -32,6 +32,8 @@ class Promise : public base::RefCounted<Promise> {
v8::Undefined(isolate()));
}
// Promise resolution is a microtask
// We use the MicrotasksRunner to trigger the running of pending microtasks
template <typename T>
v8::Maybe<bool> Resolve(const T& value) {
return GetInner()->Resolve(isolate()->GetCurrentContext(),