From 7f04bc3a46d4dd5203b9776c102b487b283a6282 Mon Sep 17 00:00:00 2001 From: Ariya Hidayat Date: Wed, 15 Jul 2009 15:34:29 +0200 Subject: Fix the return value of a constructor that throws an error. --- src/script/api/qscriptvalue.cpp | 4 +++- tests/auto/qscriptvalue/tst_qscriptvalue.cpp | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp index 2084ddb..c3c7c18 100644 --- a/src/script/api/qscriptvalue.cpp +++ b/src/script/api/qscriptvalue.cpp @@ -2131,8 +2131,10 @@ QScriptValue QScriptValue::construct(const QScriptValueList &args) JSC::ConstructData constructData; JSC::ConstructType constructType = callee.getConstructData(constructData); JSC::JSObject *result = JSC::construct(exec, callee, constructType, constructData, jscArgs); - if (exec->hadException()) + if (exec->hadException()) { eng_p->uncaughtException = exec->exception(); + result = JSC::asObject(exec->exception()); + } return eng_p->scriptValueFromJSCValue(result); } diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp index 2551e6c..2eff71a 100644 --- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp +++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp @@ -2593,10 +2593,8 @@ void tst_QScriptValue::construct() QScriptValue fun = eng.evaluate("(function() { throw new Error('foo'); })"); QCOMPARE(fun.isFunction(), true); QScriptValue ret = fun.construct(); - QEXPECT_FAIL("", "Returns null if a constructor throws an error", Continue); QCOMPARE(ret.isError(), true); QCOMPARE(eng.hasUncaughtException(), true); - QEXPECT_FAIL("", "Returns null if a constructor throws an error", Continue); QVERIFY(ret.strictlyEquals(eng.uncaughtException())); } -- cgit v0.12