* In QQmlContextWrapper::get we must check the calling context before
allowing the get, just like in the Getter() in qv8contextwrapper.cpp
* When trying to call a method on undefined/null, throw a readable error message,
as expected by the test.
Change-Id: Ie39e8ae82a108deef264e4044e12e7b15959caf9
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
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);
if (hasProp) {
Value thisObject = thatObject;
Managed *baseObject = thisObject.asManaged();
if (!baseObject) {
+ if (thisObject.isNull() || thisObject.isUndefined()) {
+ QString message = QStringLiteral("Cannot call method '%1' of %2").arg(name->toQString()).arg(thisObject.toQString());
+ context->throwTypeError(message);
+ }
+
baseObject = __qmljs_convert_to_object(context, thisObject);
thisObject = Value::fromObject(static_cast<Object *>(baseObject));
}