Bug 959375 - Add Promise Resolve/Reject overloads accepting a window. r=baku

This commit is contained in:
Nikhil Marathe 2014-01-13 14:36:03 -08:00
Родитель 9cc26cbfd7
Коммит e345f14d73
2 изменённых файлов: 32 добавлений и 6 удалений

Просмотреть файл

@ -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, /* static */ already_AddRefed<Promise>
aValue.WasPassed() ? aValue.Value() : JS::UndefinedHandleValue); 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(); 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, /* static */ already_AddRefed<Promise>
aValue.WasPassed() ? aValue.Value() : JS::UndefinedHandleValue); 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(); return promise.forget();
} }

Просмотреть файл

@ -70,10 +70,18 @@ public:
Resolve(const GlobalObject& aGlobal, JSContext* aCx, Resolve(const GlobalObject& aGlobal, JSContext* aCx,
const Optional<JS::Handle<JS::Value>>& aValue, ErrorResult& aRv); 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> static already_AddRefed<Promise>
Reject(const GlobalObject& aGlobal, JSContext* aCx, Reject(const GlobalObject& aGlobal, JSContext* aCx,
const Optional<JS::Handle<JS::Value>>& aValue, ErrorResult& aRv); 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> already_AddRefed<Promise>
Then(const Optional<nsRefPtr<AnyCallback>>& aResolveCallback, Then(const Optional<nsRefPtr<AnyCallback>>& aResolveCallback,
const Optional<nsRefPtr<AnyCallback>>& aRejectCallback); const Optional<nsRefPtr<AnyCallback>>& aRejectCallback);