diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-05-25 04:31:40 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-05-25 04:31:40 (GMT) |
commit | 2b3e7706f4459569520c77b9fb3ff2bc006e60f1 (patch) | |
tree | 44e99c4de3bd9f742e524cc81d91b8e8c67f7691 /tests/auto/declarative | |
parent | 527d7d17d4c4b3ff44c6a0d7eb7f2d024549aac7 (diff) | |
download | Qt-2b3e7706f4459569520c77b9fb3ff2bc006e60f1.zip Qt-2b3e7706f4459569520c77b9fb3ff2bc006e60f1.tar.gz Qt-2b3e7706f4459569520c77b9fb3ff2bc006e60f1.tar.bz2 |
Reading/writing a non-existent property throws an exception
QTBUG-10659
Diffstat (limited to 'tests/auto/declarative')
4 files changed, 14 insertions, 8 deletions
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml b/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml index bc2df98..faa5106 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml @@ -16,7 +16,7 @@ QtObject { test1 = (eval("a") == 7); test2 = (eval("b") == 9); - test3 = (eval("c") == undefined); + try { eval("c") } catch(e) { test3 = true; } test4 = (eval("console") == console); test5 = (eval("Qt") == Qt); } diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/function.qml b/tests/auto/declarative/qdeclarativeecmascript/data/function.qml index b435f58..e524189 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/function.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/function.qml @@ -14,6 +14,7 @@ QtObject { test1 = (func1(4) == 11); test2 = (func2("Hello World!") == Qt.atob("Hello World!")); - test3 = (func3() == undefined); + + try { func3(); } catch(e) { test3 = true; } } } diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/libraryScriptAssert.js b/tests/auto/declarative/qdeclarativeecmascript/data/libraryScriptAssert.js index 3ffdb33..a20fc28 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/libraryScriptAssert.js +++ b/tests/auto/declarative/qdeclarativeecmascript/data/libraryScriptAssert.js @@ -2,5 +2,5 @@ function test(target) { - var a = target.a; + try { var a = target.a; } catch(e) {} } diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index e75abac..217ed11 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -997,11 +997,11 @@ void tst_qdeclarativeecmascript::scriptErrors() QString url = component.url().toString(); QString warning1 = url.left(url.length() - 3) + "js:2: Error: Invalid write to global property \"a\""; - QString warning2 = url + ":5: TypeError: Result of expression 'a' [undefined] is not an object."; + QString warning2 = url + ":5: Error: Cannot access non-existent property \"a\""; QString warning3 = url.left(url.length() - 3) + "js:4: Error: Invalid write to global property \"a\""; - QString warning4 = url + ":10: TypeError: Result of expression 'a' [undefined] is not an object."; - QString warning5 = url + ":8: TypeError: Result of expression 'a' [undefined] is not an object."; - QString warning6 = url + ":7: Unable to assign [undefined] to int x"; + QString warning4 = url + ":10: Error: Cannot access non-existent property \"a\""; + QString warning5 = url + ":8: Error: Cannot access non-existent property \"a\""; + QString warning6 = url + ":7: Error: Cannot access non-existent property \"undefinedObject\""; QString warning7 = url + ":12: Error: Cannot assign to read-only property \"trueProperty\""; QString warning8 = url + ":13: Error: Cannot assign to non-existent property \"fakeProperty\""; @@ -1317,7 +1317,12 @@ void tst_qdeclarativeecmascript::callQtInvokables() QDeclarativeEngine qmlengine; QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(&qmlengine); QScriptEngine *engine = &ep->scriptEngine; - ep->globalClass->explicitSetProperty("object", ep->objectClass->newQObject(&o)); + QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(engine); + scriptContext->pushScope(ep->globalClass->globalObject()); + QScriptValue scope = engine->newObject(); + scope.setProperty("object", ep->objectClass->newQObject(&o)); + scriptContext->setActivationObject(scope); + scriptContext->pushScope(scope); // Non-existent methods o.reset(); |