зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1381275 - Report proper object in NewPromiseCapability TypeError. r=fitzgen
This commit is contained in:
Родитель
21aede7436
Коммит
d06b0ed712
|
@ -692,7 +692,7 @@ NewPromiseCapability(JSContext* cx, HandleObject C, MutableHandleObject promise,
|
|||
|
||||
// Steps 1-2.
|
||||
if (!IsConstructor(C)) {
|
||||
ReportValueError(cx, JSMSG_NOT_CONSTRUCTOR, -1, cVal, nullptr);
|
||||
ReportValueError(cx, JSMSG_NOT_CONSTRUCTOR, JSDVG_SEARCH_STACK, cVal, nullptr);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
load(libdir + "asserts.js");
|
||||
|
||||
let foo = {};
|
||||
for (let method of ["resolve", "reject", "race"]) {
|
||||
assertErrorMessage(
|
||||
() => Promise[method].call(foo),
|
||||
TypeError,
|
||||
"foo is not a constructor"
|
||||
);
|
||||
assertErrorMessage(
|
||||
() => Promise[method].call(foo, []),
|
||||
TypeError,
|
||||
"foo is not a constructor"
|
||||
);
|
||||
assertErrorMessage(
|
||||
() => Promise[method].call({}, [], foo),
|
||||
TypeError,
|
||||
"({}) is not a constructor"
|
||||
);
|
||||
}
|
Загрузка…
Ссылка в новой задаче