From 48f8d0cf20f8bcdb35bfc49057ad1fa768e66825 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Wed, 2 Feb 2011 08:11:32 +0100 Subject: Bring back "classic" iteration order of QScriptClass properties In the old back-end, normal JS properties were iterated before QScriptClass properties. There wasn't any good reason to change that. Now we can get rid of that left-over XFAIL as well. Task-number: QTBUG-16746 Reviewed-by: Jedrzej Nowacki --- src/script/bridge/qscriptclassobject.cpp | 5 ++++- tests/auto/qscriptclass/tst_qscriptclass.cpp | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/script/bridge/qscriptclassobject.cpp b/src/script/bridge/qscriptclassobject.cpp index 9285883..2085756 100644 --- a/src/script/bridge/qscriptclassobject.cpp +++ b/src/script/bridge/qscriptclassobject.cpp @@ -183,6 +183,10 @@ void ClassObjectDelegate::getOwnPropertyNames(QScriptObject* object, JSC::ExecSt JSC::PropertyNameArray &propertyNames, JSC::EnumerationMode mode) { + // For compatibility with the old back-end, normal JS properties + // are added first. + QScriptObjectDelegate::getOwnPropertyNames(object, exec, propertyNames, mode); + QScriptEnginePrivate *engine = scriptEngineFromExec(exec); QScript::SaveFrameHelper saveFrame(engine, exec); QScriptValue scriptObject = engine->scriptValueFromJSCValue(object); @@ -195,7 +199,6 @@ void ClassObjectDelegate::getOwnPropertyNames(QScriptObject* object, JSC::ExecSt } delete it; } - QScriptObjectDelegate::getOwnPropertyNames(object, exec, propertyNames, mode); } JSC::CallType ClassObjectDelegate::getCallData(QScriptObject*, JSC::CallData &callData) diff --git a/tests/auto/qscriptclass/tst_qscriptclass.cpp b/tests/auto/qscriptclass/tst_qscriptclass.cpp index 2d6daec..00fdd35 100644 --- a/tests/auto/qscriptclass/tst_qscriptclass.cpp +++ b/tests/auto/qscriptclass/tst_qscriptclass.cpp @@ -823,10 +823,12 @@ void tst_QScriptClass::enumerate() cls.setIterationEnabled(true); QScriptValueIterator it(obj); + // This test relies on the order in which properties are enumerated, + // which we don't guarantee. However, for compatibility's sake we prefer + // that normal JS properties come before QScriptClass properties. for (int x = 0; x < 2; ++x) { QVERIFY(it.hasNext()); it.next(); - QEXPECT_FAIL("", "", Abort); QVERIFY(it.scriptName() == foo); QVERIFY(it.hasNext()); it.next(); -- cgit v0.12