Fix tst_qqmlecmascript::scope() and behavioural compatibility with v8 based qml
In the V8 based QML the global object would come _before_ the "QML global object", which is the QML context (wrapper). We had a bunch of tests that verify the exact scope chain and with this "compatibility" fix we can re-enable them. Also fix missing prototype setup for the console object. Change-Id: Ib3886f2d86472eb752a6ad1a2d8d89709548c5b4 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
This commit is contained in:
parent
8a273812ce
commit
3b8457712e
|
|
@ -133,14 +133,23 @@ Value QmlContextWrapper::get(Managed *m, String *name, bool *hasProperty)
|
|||
if (!resource)
|
||||
v4->current->throwTypeError();
|
||||
|
||||
// In V8 the JS global object would come _before_ the QML global object,
|
||||
// so simulate that here.
|
||||
bool hasProp;
|
||||
QV4::Value result = v4->globalObject->get(name, &hasProp);
|
||||
if (hasProp) {
|
||||
if (hasProperty)
|
||||
*hasProperty = hasProp;
|
||||
return result;
|
||||
}
|
||||
|
||||
if (resource->isNullWrapper)
|
||||
return Object::get(m, name, hasProperty);
|
||||
|
||||
if (QV4::QmlContextWrapper::callingContext(v4) != resource->context)
|
||||
return Object::get(m, name, hasProperty);
|
||||
|
||||
bool hasProp;
|
||||
Value result = Object::get(m, name, &hasProp);
|
||||
result = Object::get(m, name, &hasProp);
|
||||
if (hasProp) {
|
||||
if (hasProperty)
|
||||
*hasProperty = hasProp;
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@
|
|||
#include <private/qv4stringobject_p.h>
|
||||
#include <private/qv4mm_p.h>
|
||||
#include <private/qv4jsonobject_p.h>
|
||||
#include <private/qv4objectproto_p.h>
|
||||
|
||||
#include <QtCore/qstring.h>
|
||||
#include <QtCore/qdatetime.h>
|
||||
|
|
@ -1308,6 +1309,8 @@ Value QtObject::method_get_inputMethod(SimpleCallContext *ctx)
|
|||
QV4::ConsoleObject::ConsoleObject(ExecutionEngine *v4)
|
||||
: Object(v4)
|
||||
{
|
||||
prototype = v4->objectPrototype;
|
||||
|
||||
defineDefaultProperty(v4, QStringLiteral("debug"), method_log);
|
||||
defineDefaultProperty(v4, QStringLiteral("log"), method_log);
|
||||
defineDefaultProperty(v4, QStringLiteral("info"), method_log);
|
||||
|
|
|
|||
|
|
@ -1284,7 +1284,6 @@ void tst_qqmlecmascript::scope()
|
|||
QVERIFY(object != 0);
|
||||
|
||||
QCOMPARE(object->property("test1").toBool(), true);
|
||||
QEXPECT_FAIL("", "Lookup in the global object vs. the QML context is not 100% correct right now ", Continue);
|
||||
QCOMPARE(object->property("test2").toBool(), true);
|
||||
QCOMPARE(object->property("test3").toBool(), true);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue