aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/v8
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2012-03-14 13:39:31 +0100
committerQt by Nokia <qt-info@nokia.com>2012-03-14 19:49:35 +0100
commita27fd584df0ec3d1d072501d8fefe576a97a2e53 (patch)
tree1db602032bc1d018eb6d76ef326e0cbdb57f5e00 /src/qml/qml/v8
parent8f077f28c51c24e71d95c4e99d322734578d9c9c (diff)
Let V8 throw the exception when QML property lookup fails
Only V8 knows whether a failed property lookup should actually cause a ReferenceError to be thrown. When evaluating a "typeof" expression, for example, a ReferenceError should not be thrown even if the expression involves global variables that don't exist, according to the ECMA-262 specification. QML should try to match the standard JavaScript behavior. This is achieved by simply returning an empty value handle (to signify the absence of the property), and leaving it to V8 to throw an exception as appropriate. Task-number: QTBUG-21864 Task-number: QTBUG-24448 Change-Id: I9945adcab98fc3b801371163367473d6af0ab31a Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
Diffstat (limited to 'src/qml/qml/v8')
-rw-r--r--src/qml/qml/v8/qv8contextwrapper.cpp18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/qml/qml/v8/qv8contextwrapper.cpp b/src/qml/qml/v8/qv8contextwrapper.cpp
index e7c26fde9e..39392b8984 100644
--- a/src/qml/qml/v8/qv8contextwrapper.cpp
+++ b/src/qml/qml/v8/qv8contextwrapper.cpp
@@ -238,16 +238,11 @@ QQmlContextData *QV8ContextWrapper::context(v8::Handle<v8::Value> value)
return r?r->getContext():0;
}
-v8::Handle<v8::Value> QV8ContextWrapper::NullGetter(v8::Local<v8::String> property,
- const v8::AccessorInfo &info)
+v8::Handle<v8::Value> QV8ContextWrapper::NullGetter(v8::Local<v8::String>,
+ const v8::AccessorInfo &)
{
- QV8ContextResource *resource = v8_resource_check<QV8ContextResource>(info.This());
-
- QV8Engine *engine = resource->engine;
-
- QString error = engine->toString(property) + QLatin1String(" is not defined");
- v8::ThrowException(v8::Exception::ReferenceError(engine->toString(error)));
- return v8::Undefined();
+ // V8 will throw a ReferenceError if appropriate ("typeof" should not throw)
+ return v8::Handle<v8::Value>();
}
v8::Handle<v8::Value> QV8ContextWrapper::Getter(v8::Local<v8::String> property,
@@ -365,9 +360,8 @@ v8::Handle<v8::Value> QV8ContextWrapper::Getter(v8::Local<v8::String> property,
expressionContext->unresolvedNames = true;
- QString error = engine->toString(property) + QLatin1String(" is not defined");
- v8::ThrowException(v8::Exception::ReferenceError(engine->toString(error)));
- return v8::Undefined();
+ // V8 will throw a ReferenceError if appropriate ("typeof" should not throw)
+ return v8::Handle<v8::Value>();
}
v8::Handle<v8::Value> QV8ContextWrapper::NullSetter(v8::Local<v8::String> property,