]> git.kaiwu.me - njs.git/commit
Fixed type confusion bug while resolving promises.
authorDmitry Volyntsev <xeioex@nginx.com>
Wed, 19 Jan 2022 13:12:09 +0000 (13:12 +0000)
committerDmitry Volyntsev <xeioex@nginx.com>
Wed, 19 Jan 2022 13:12:09 +0000 (13:12 +0000)
commit6a40a85ff239497c6458c7dbef18f6a2736fe992
tree3ab16657908b4c96681fd0aef66863ed8de97fad
parent1406f64bcbe4ae9a09699ee9daa2f95c12512f41
Fixed type confusion bug while resolving promises.

Previously, the internal function njs_promise_perform_then() which
implements PerformPromiseThen() expects its first argument to always be
a promise instance.  This assertion might be invalid because the
functions corresponding to Promise.prototype.then() and
Promise.resolve() incorrectly verified their arguments.

Specifically, the functions recognized their first argument as promise
if it was an object which was an Promise or had Promise object in its
prototype chain.  The later condition is not correct because internal
slots are not inherited according to the spec.

This closes #447 issue in Github.
src/njs_promise.c
src/njs_vmcode.c
test/js/promise_prototype_reject_type_confusion.t.js [new file with mode: 0644]
test/js/promise_prototype_then_type_confusion.t.js [new file with mode: 0644]