Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
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>
- Loading branch information
Chris Adams
authored and
Qt by Nokia
committed
Aug 2, 2011
1 parent
0db6db0
commit 6f146a5
Showing
7 changed files
with
140 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
tests/auto/declarative/qdeclarativeecmascript/data/declarativeHasOwnProperty.qml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters