aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-08-08 14:57:36 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-08 15:35:26 +0200
commit3b8457712e7b98dd6ee88f0290deabdf46695598 (patch)
tree758bbd21cf25294ce35e17109fe761101c3aa2e5 /src
parent8a273812ce2a9055d7cf2196e1b8a288bf0fc142 (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/qml/qml/qqmlcontextwrapper.cpp13
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions.cpp3
2 files changed, 14 insertions, 2 deletions
diff --git a/src/qml/qml/qqmlcontextwrapper.cpp b/src/qml/qml/qqmlcontextwrapper.cpp
index 4a66c7552d..9ba3a51757 100644
--- a/src/qml/qml/qqmlcontextwrapper.cpp
+++ b/src/qml/qml/qqmlcontextwrapper.cpp
@@ -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;
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
index 97736355d4..ed972b64c1 100644
--- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
+++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
@@ -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);