aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativeecmascript/data
diff options
context:
space:
mode:
authorChris Adams <christopher.adams@nokia.com>2011-07-12 15:55:01 +1000
committerQt by Nokia <qt-info@nokia.com>2011-08-02 08:50:21 +0200
commit6f146a5d2ea893b13e4cfcd90243e66f7c9a0083 (patch)
tree2e94aef5c7f0a10bf28928dab40a43e5f9483826 /tests/auto/declarative/qdeclarativeecmascript/data
parent0db6db0263defcd6ff84769b7d927d5a51606f6c (diff)
Ensure that the prototype chain is checked in property Get
This commit ensures that the prototype chain is checked during property Get operations on QObjects and other types in QML by returning an empty handle from the property Get interceptor if no valid property with the given name is found. Task-number: QTBUG-20336 Change-Id: I670ee211c74c0fdcb68c3f91b29fcc0ea8b55d6f Reviewed-on: http://codereview.qt.nokia.com/1477 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com> Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
Diffstat (limited to 'tests/auto/declarative/qdeclarativeecmascript/data')
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/declarativeHasOwnProperty.qml72
1 files changed, 72 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/declarativeHasOwnProperty.qml b/tests/auto/declarative/qdeclarativeecmascript/data/declarativeHasOwnProperty.qml
new file mode 100644
index 0000000000..12598b3b9f
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/declarativeHasOwnProperty.qml
@@ -0,0 +1,72 @@
+import QtQuick 2.0
+import Qt.test 1.0
+import Qt.test.qobjectApi 1.0 as QtTestQObjectApi
+
+Item {
+ id: obj
+ objectName: "objName"
+ property int someIntProperty: 10
+ property bool result: false
+
+ function testHasOwnPropertySuccess()
+ {
+ obj.result = obj.hasOwnProperty("someIntProperty");
+ }
+
+ function testHasOwnPropertyFailure()
+ {
+ obj.result = obj.hasOwnProperty("someNonexistentProperty");
+ }
+
+ MyTypeObject {
+ id: typeObj
+ objectName: "typeObj"
+ pointProperty: Qt.point(34, 29)
+ variantProperty: Qt.vector3d(1, 2, 3)
+ stringProperty: "test string"
+ property list<Rectangle> listProperty: [ Rectangle { width: 10; height: 10 } ]
+ property list<Rectangle> emptyListProperty
+
+ property bool valueTypeHasOwnProperty
+ property bool valueTypeHasOwnProperty2
+ property bool variantTypeHasOwnProperty
+ property bool stringTypeHasOwnProperty
+ property bool listTypeHasOwnProperty
+ property bool listAtValidHasOwnProperty
+ property bool emptyListTypeHasOwnProperty
+ property bool enumTypeHasOwnProperty
+ property bool typenameHasOwnProperty
+ property bool typenameHasOwnProperty2
+ property bool moduleApiTypeHasOwnProperty
+ property bool moduleApiPropertyTypeHasOwnProperty
+ function testHasOwnPropertySuccess() {
+ valueTypeHasOwnProperty = !typeObj.pointProperty.hasOwnProperty("nonexistentpropertyname");
+ valueTypeHasOwnProperty2 = typeObj.pointProperty.hasOwnProperty("x"); // should be true
+ variantTypeHasOwnProperty = !typeObj.variantProperty.hasOwnProperty("nonexistentpropertyname");
+ stringTypeHasOwnProperty = !typeObj.stringProperty.hasOwnProperty("nonexistentpropertyname");
+ listTypeHasOwnProperty = !typeObj.listProperty.hasOwnProperty("nonexistentpropertyname");
+ listAtValidHasOwnProperty = !typeObj.listProperty[0].hasOwnProperty("nonexistentpropertyname");
+ emptyListTypeHasOwnProperty = !typeObj.emptyListProperty.hasOwnProperty("nonexistentpropertyname");
+ enumTypeHasOwnProperty = !MyTypeObject.EnumVal1.hasOwnProperty("nonexistentpropertyname");
+ typenameHasOwnProperty = !MyTypeObject.hasOwnProperty("nonexistentpropertyname");
+ typenameHasOwnProperty2 = MyTypeObject.hasOwnProperty("EnumVal1"); // should be true.
+ moduleApiTypeHasOwnProperty = !QtTestQObjectApi.hasOwnProperty("nonexistentpropertyname");
+ moduleApiPropertyTypeHasOwnProperty = !QtTestQObjectApi.qobjectTestProperty.hasOwnProperty("nonexistentpropertyname");
+ }
+
+ property bool enumNonValueHasOwnProperty
+ function testHasOwnPropertyFailureOne() {
+ enumNonValueHasOwnProperty = !MyTypeObject.NonexistentEnumVal.hasOwnProperty("nonexistentpropertyname");
+ }
+
+ property bool moduleApiNonPropertyHasOwnProperty
+ function testHasOwnPropertyFailureTwo() {
+ moduleApiNonPropertyHasOwnProperty = !QtTestQObjectApi.someNonexistentProperty.hasOwnProperty("nonexistentpropertyname");
+ }
+
+ property bool listAtInvalidHasOwnProperty
+ function testHasOwnPropertyFailureThree() {
+ listAtInvalidHasOwnProperty = !typeObj.listProperty[5].hasOwnProperty("nonexistentpropertyname");
+ }
+ }
+}