mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-03 07:01:19 +00:00
Bug 959375 - Add Promise Resolve/Reject overloads accepting a window. r=baku
This commit is contained in:
parent
9cc26cbfd7
commit
e345f14d73
@ -410,10 +410,19 @@ Promise::Resolve(const GlobalObject& aGlobal, JSContext* aCx,
|
||||
}
|
||||
}
|
||||
|
||||
nsRefPtr<Promise> promise = new Promise(window);
|
||||
return Resolve(window, aCx,
|
||||
aValue.WasPassed() ? aValue.Value() : JS::UndefinedHandleValue,
|
||||
aRv);
|
||||
}
|
||||
|
||||
promise->MaybeResolveInternal(aCx,
|
||||
aValue.WasPassed() ? aValue.Value() : JS::UndefinedHandleValue);
|
||||
/* static */ already_AddRefed<Promise>
|
||||
Promise::Resolve(nsPIDOMWindow* aWindow, JSContext* aCx,
|
||||
JS::Handle<JS::Value> aValue, ErrorResult& aRv)
|
||||
{
|
||||
// aWindow may be null.
|
||||
nsRefPtr<Promise> promise = new Promise(aWindow);
|
||||
|
||||
promise->MaybeResolveInternal(aCx, aValue);
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
@ -430,10 +439,19 @@ Promise::Reject(const GlobalObject& aGlobal, JSContext* aCx,
|
||||
}
|
||||
}
|
||||
|
||||
nsRefPtr<Promise> promise = new Promise(window);
|
||||
return Reject(window, aCx,
|
||||
aValue.WasPassed() ? aValue.Value() : JS::UndefinedHandleValue,
|
||||
aRv);
|
||||
}
|
||||
|
||||
promise->MaybeRejectInternal(aCx,
|
||||
aValue.WasPassed() ? aValue.Value() : JS::UndefinedHandleValue);
|
||||
/* static */ already_AddRefed<Promise>
|
||||
Promise::Reject(nsPIDOMWindow* aWindow, JSContext* aCx,
|
||||
JS::Handle<JS::Value> aValue, ErrorResult& aRv)
|
||||
{
|
||||
// aWindow may be null.
|
||||
nsRefPtr<Promise> promise = new Promise(aWindow);
|
||||
|
||||
promise->MaybeRejectInternal(aCx, aValue);
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
|
@ -70,10 +70,18 @@ public:
|
||||
Resolve(const GlobalObject& aGlobal, JSContext* aCx,
|
||||
const Optional<JS::Handle<JS::Value>>& aValue, ErrorResult& aRv);
|
||||
|
||||
static already_AddRefed<Promise>
|
||||
Resolve(nsPIDOMWindow* aWindow, JSContext* aCx,
|
||||
JS::Handle<JS::Value> aValue, ErrorResult& aRv);
|
||||
|
||||
static already_AddRefed<Promise>
|
||||
Reject(const GlobalObject& aGlobal, JSContext* aCx,
|
||||
const Optional<JS::Handle<JS::Value>>& aValue, ErrorResult& aRv);
|
||||
|
||||
static already_AddRefed<Promise>
|
||||
Reject(nsPIDOMWindow* aWindow, JSContext* aCx,
|
||||
JS::Handle<JS::Value> aValue, ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<Promise>
|
||||
Then(const Optional<nsRefPtr<AnyCallback>>& aResolveCallback,
|
||||
const Optional<nsRefPtr<AnyCallback>>& aRejectCallback);
|
||||
|
Loading…
x
Reference in New Issue
Block a user