wasm: Handle exceptions in promise
Fixes: QTBUG-136962 Change-Id: I2d33b0132a83945b476f0f47fa4697ddaa2374b3 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
parent
c3c51dd5d1
commit
ac710784af
@ -487,10 +487,15 @@ void Promise::adoptPromise(emscripten::val promise, PromiseCallbacks callbacks)
|
|||||||
|
|
||||||
// Set handlers on the promise
|
// Set handlers on the promise
|
||||||
if (thenIndex)
|
if (thenIndex)
|
||||||
promise.call<emscripten::val>("then", suspendResume->jsEventHandlerAt(*thenIndex));
|
promise =
|
||||||
|
promise.call<emscripten::val>("then", suspendResume->jsEventHandlerAt(*thenIndex));
|
||||||
|
|
||||||
if (catchIndex)
|
if (catchIndex)
|
||||||
promise.call<emscripten::val>("catch", suspendResume->jsEventHandlerAt(*catchIndex));
|
promise = promise.call<emscripten::val>("catch",
|
||||||
promise.call<emscripten::val>("finally", suspendResume->jsEventHandlerAt(*finallyIndex));
|
suspendResume->jsEventHandlerAt(*catchIndex));
|
||||||
|
|
||||||
|
promise = promise.call<emscripten::val>("finally",
|
||||||
|
suspendResume->jsEventHandlerAt(*finallyIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Promise::all(std::vector<emscripten::val> promises, PromiseCallbacks callbacks)
|
void Promise::all(std::vector<emscripten::val> promises, PromiseCallbacks callbacks)
|
||||||
|
@ -54,6 +54,7 @@ private slots:
|
|||||||
void multipleResolve();
|
void multipleResolve();
|
||||||
void simpleReject();
|
void simpleReject();
|
||||||
void multipleReject();
|
void multipleReject();
|
||||||
|
void throwInThen();
|
||||||
void bareFinally();
|
void bareFinally();
|
||||||
void finallyWithThen();
|
void finallyWithThen();
|
||||||
void finallyWithThrow();
|
void finallyWithThrow();
|
||||||
@ -188,6 +189,28 @@ void WasmPromiseTest::multipleReject()
|
|||||||
}, promiseCount);
|
}, promiseCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WasmPromiseTest::throwInThen()
|
||||||
|
{
|
||||||
|
init();
|
||||||
|
|
||||||
|
qstdweb::Promise::make(m_testSupport, "makeTestPromise", {
|
||||||
|
.thenFunc = [](val result) {
|
||||||
|
Q_UNUSED(result);
|
||||||
|
EM_ASM({
|
||||||
|
throw "Expected error";
|
||||||
|
});
|
||||||
|
},
|
||||||
|
.catchFunc = [](val error) {
|
||||||
|
QWASMCOMPARE("Expected error", error.as<std::string>());
|
||||||
|
QWASMSUCCESS();
|
||||||
|
}
|
||||||
|
}, std::string("throwInThen"));
|
||||||
|
|
||||||
|
EM_ASM({
|
||||||
|
testSupport.resolve["throwInThen"]();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void WasmPromiseTest::bareFinally()
|
void WasmPromiseTest::bareFinally()
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user