зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1314392 - Throw error instead of crashing when getting passed unexpected parameters in getWaitForAllPromise testing function. r=arai
MozReview-Commit-ID: GSUlXTPhszK
This commit is contained in:
Родитель
7668404498
Коммит
91f8b86a70
|
@ -1476,8 +1476,14 @@ GetWaitForAllPromise(JSContext* cx, unsigned argc, Value* vp)
|
|||
if (!promises.resize(count))
|
||||
return false;
|
||||
|
||||
for (uint32_t i = 0; i < count; i++)
|
||||
promises[i].set(&list->getDenseElement(i).toObject());
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
RootedValue elem(cx, list->getDenseElement(i));
|
||||
if (!elem.isObject() || !elem.toObject().is<PromiseObject>()) {
|
||||
JS_ReportErrorASCII(cx, "Each entry in the passed-in Array must be a Promise");
|
||||
return false;
|
||||
}
|
||||
promises[i].set(&elem.toObject());
|
||||
}
|
||||
|
||||
RootedObject resultPromise(cx, JS::GetWaitForAllPromise(cx, promises));
|
||||
if (!resultPromise)
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
load(libdir + "asserts.js");
|
||||
|
||||
assertThrowsInstanceOf(_=>getWaitForAllPromise(42), Error);
|
||||
assertThrowsInstanceOf(_=>getWaitForAllPromise([42]), Error);
|
||||
assertThrowsInstanceOf(_=>getWaitForAllPromise([{}]), Error);
|
||||
|
||||
// Shouldn't throw.
|
||||
getWaitForAllPromise([Promise.resolve()]);
|
|
@ -1,6 +1,7 @@
|
|||
global = newGlobal();
|
||||
OtherPromise = global.Promise;
|
||||
const global = newGlobal();
|
||||
const OtherPromise = global.Promise;
|
||||
class SubPromise extends OtherPromise {}
|
||||
|
||||
assertEq(true, new SubPromise(()=>{}) instanceof OtherPromise);
|
||||
assertEq(true, SubPromise.resolve({}) instanceof OtherPromise);
|
||||
assertEq(true, SubPromise.reject({}) instanceof OtherPromise);
|
||||
|
|
Загрузка…
Ссылка в новой задаче