From 4c31f59d45130eae8f140e6d0177a4b227454187 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Fri, 14 Aug 2009 14:20:56 +0200 Subject: make sure QScriptContext::scopeChain() returns the right object Follow-up to commit e0a86dc604b87921652b844a5f85889bb6291ed9. Just like in the activationObject() function, we need to check if the activation object is actually a proxy to another object, and return that other object if that's the case (the proxy object should not be exposed to the public). --- src/script/api/qscriptcontext.cpp | 11 +++++++++-- tests/auto/qscriptcontext/tst_qscriptcontext.cpp | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/script/api/qscriptcontext.cpp b/src/script/api/qscriptcontext.cpp index 4a78f7c..01ccb6d 100644 --- a/src/script/api/qscriptcontext.cpp +++ b/src/script/api/qscriptcontext.cpp @@ -671,8 +671,15 @@ QScriptValueList QScriptContext::scopeChain() const JSC::ScopeChainNode *node = frame->scopeChain(); JSC::ScopeChainIterator it(node); for (it = node->begin(); it != node->end(); ++it) { - if (*it) - result.append(engine->scriptValueFromJSCValue(*it)); + JSC::JSObject *object = *it; + if (!object) + continue; + if (object->isObject(&QScript::QScriptActivationObject::info) + && (static_cast(object)->delegate() != 0)) { + // Return the object that property access is being delegated to + object = static_cast(object)->delegate(); + } + result.append(engine->scriptValueFromJSCValue(object)); } return result; } diff --git a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp index 6401f62..36c680d 100644 --- a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp +++ b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp @@ -719,6 +719,8 @@ void tst_QScriptContext::getSetActivationObject() QScriptValue obj = eng.newObject(); ctx->setActivationObject(obj); QVERIFY(ctx->activationObject().equals(obj)); + QCOMPARE(ctx->scopeChain().size(), 1); + QVERIFY(ctx->scopeChain().at(0).equals(obj)); { QScriptEngine eng2; -- cgit v0.12