summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2011-02-02 07:11:32 (GMT)
committerKent Hansen <kent.hansen@nokia.com>2011-02-03 09:52:21 (GMT)
commit48f8d0cf20f8bcdb35bfc49057ad1fa768e66825 (patch)
treee6dc0445b73c4c42214a6eee725bc003c07418d7
parenta97a36aac550c175a2e2045ead55ad4d263a24ed (diff)
downloadQt-48f8d0cf20f8bcdb35bfc49057ad1fa768e66825.zip
Qt-48f8d0cf20f8bcdb35bfc49057ad1fa768e66825.tar.gz
Qt-48f8d0cf20f8bcdb35bfc49057ad1fa768e66825.tar.bz2
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
-rw-r--r--src/script/bridge/qscriptclassobject.cpp5
-rw-r--r--tests/auto/qscriptclass/tst_qscriptclass.cpp4
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();