From 36be27265d61c76b25417a25e482030e30ff380f Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Fri, 20 Sep 2019 16:38:30 +0200 Subject: QMLJS: Fix exception handling in promises If an exception is thrown inside a promise's resolve or reject handler, the promise needs to resolve into a rejected state with the exceptions value. The value was previously not set. Fixes: QTBUG-78554 Change-Id: Ic22faa6ef1e519e4cae6732c69bb14f7053d13da Reviewed-by: Ulf Hermann Reviewed-by: Qt CI Bot --- .../auto/qml/qqmlpromise/data/promisehandlerthrows.qml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 tests/auto/qml/qqmlpromise/data/promisehandlerthrows.qml (limited to 'tests/auto/qml/qqmlpromise/data/promisehandlerthrows.qml') diff --git a/tests/auto/qml/qqmlpromise/data/promisehandlerthrows.qml b/tests/auto/qml/qqmlpromise/data/promisehandlerthrows.qml new file mode 100644 index 0000000000..d23ea43e74 --- /dev/null +++ b/tests/auto/qml/qqmlpromise/data/promisehandlerthrows.qml @@ -0,0 +1,17 @@ +import QtQuick 2.12 + +Item { + id: root + property string errorMessage + Component.onCompleted: () => { + let prom = Promise.reject("Some error") + .then( + o => {console.log("Never reached");}, + err => { + console.log("Rethrowing err"); + throw err; + } + ) + .catch(err => root.errorMessage = err) + } +} -- cgit v1.2.3