summaryrefslogtreecommitdiffstats
path: root/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/qt/tests/qwebframe/tst_qwebframe.cpp')
-rw-r--r--WebKit/qt/tests/qwebframe/tst_qwebframe.cpp74
1 files changed, 72 insertions, 2 deletions
diff --git a/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp b/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
index 76fdba3..3d03157 100644
--- a/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
+++ b/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
@@ -37,6 +37,7 @@
#include <qsslerror.h>
#endif
#include "../util.h"
+#include "../WebCoreSupport/DumpRenderTreeSupportQt.h"
struct CustomType {
QString string;
@@ -570,9 +571,11 @@ public slots:
void cleanup();
private slots:
- void getSetStaticProperty();
void getSetDynamicProperty();
+ void getSetDynamicProperty_data();
void getSetChildren();
+ void getSetChildren_data();
+ void getSetStaticProperty();
void callQtInvokable();
void connectAndDisconnect();
void classEnums();
@@ -667,6 +670,10 @@ private:
evalJS("delete retvalue; delete typevalue");
return ret;
}
+ void garbageCollectJS()
+ {
+ DumpRenderTreeSupportQt::garbageCollectorCollect();
+ }
QObject* firstChildByClassName(QObject* parent, const char* className) {
const QObjectList & children = parent->children();
foreach (QObject* child, children) {
@@ -943,6 +950,8 @@ void tst_QWebFrame::getSetStaticProperty()
void tst_QWebFrame::getSetDynamicProperty()
{
+ QFETCH(bool, garbageCollect);
+
// initially the object does not have the property
// In WebKit, RuntimeObjects do not inherit Object, so don't have hasOwnProperty
@@ -954,11 +963,34 @@ void tst_QWebFrame::getSetDynamicProperty()
//QCOMPARE(evalJS("myObject.hasOwnProperty('dynamicProperty')"), sTrue);
QCOMPARE(evalJS("typeof myObject.dynamicProperty != 'undefined'"), sTrue);
QCOMPARE(evalJS("myObject.dynamicProperty == 123"), sTrue);
+ if( garbageCollect ) {
+ garbageCollectJS();
+ QCOMPARE(evalJS("typeof myObject.dynamicProperty != 'undefined'"), sTrue);
+ }
// property change in script should be reflected in C++
QCOMPARE(evalJS("myObject.dynamicProperty = 'foo';"
"myObject.dynamicProperty"), QLatin1String("foo"));
QCOMPARE(m_myObject->property("dynamicProperty").toString(), QLatin1String("foo"));
+ if( garbageCollect ) {
+ garbageCollectJS();
+ QCOMPARE(m_myObject->property("dynamicProperty").toString(), QLatin1String("foo"));
+ }
+
+ // add a dynamic property in C++ to another QObject
+ QObject* propertyObject = new QObject(m_myObject);
+ QCOMPARE(m_myObject->setProperty("dynamicObjectProperty", qVariantFromValue(propertyObject)), false);
+ QCOMPARE(evalJS("typeof myObject.dynamicObjectProperty != 'undefined'"), sTrue);
+ evalJS("myObject.dynamicObjectProperty.jsProperty = 123");
+ QCOMPARE(evalJS("myObject.dynamicObjectProperty.jsProperty == 123"), sTrue);
+ if( garbageCollect ) {
+ garbageCollectJS();
+ QCOMPARE(evalJS("typeof myObject.dynamicObjectProperty != 'undefined'"), sTrue);
+ QCOMPARE(evalJS("myObject.dynamicObjectProperty.jsProperty == 123"), sTrue);
+ }
+ QCOMPARE(m_myObject->setProperty("dynamicObjectProperty", QVariant()), false);
+ delete propertyObject;
+ QCOMPARE(evalJS("typeof myObject.dynamicObjectProperty == 'undefined'"), sTrue);
// delete the property (XFAIL - can't delete properties)
QEXPECT_FAIL("", "can't delete properties", Continue);
@@ -969,10 +1001,21 @@ void tst_QWebFrame::getSetDynamicProperty()
// QCOMPARE(evalJS("myObject.hasOwnProperty('dynamicProperty')"), sFalse);
QCOMPARE(evalJS("typeof myObject.dynamicProperty"), sUndefined);
*/
+
+ evalJS("myObject.dynamicProperty = undefined");
+}
+
+void tst_QWebFrame::getSetDynamicProperty_data()
+{
+ QTest::addColumn<bool>("garbageCollect");
+ QTest::newRow("with garbageCollect") << true;
+ QTest::newRow("without garbageCollect") << false;
}
void tst_QWebFrame::getSetChildren()
{
+ QFETCH(bool, garbageCollect);
+
// initially the object does not have the child
// (again, no hasOwnProperty)
@@ -984,12 +1027,27 @@ void tst_QWebFrame::getSetChildren()
child->setObjectName("child");
// QCOMPARE(evalJS("myObject.hasOwnProperty('child')"), sTrue);
QCOMPARE(evalJS("typeof myObject.child != 'undefined'"), sTrue);
+ evalJS("myObject.child.jsProperty = 123");
+ QCOMPARE(evalJS("myObject.child.jsProperty == 123"), sTrue);
+
+ if( garbageCollect ) {
+ garbageCollectJS();
+ QCOMPARE(evalJS("typeof myObject.child != 'undefined'"), sTrue);
+ QCOMPARE(evalJS("myObject.child.jsProperty == 123"), sTrue);
+ }
// add a grandchild
MyQObject* grandChild = new MyQObject(child);
grandChild->setObjectName("grandChild");
// QCOMPARE(evalJS("myObject.child.hasOwnProperty('grandChild')"), sTrue);
QCOMPARE(evalJS("typeof myObject.child.grandChild != 'undefined'"), sTrue);
+ evalJS("myObject.child.grandChild.jsProperty = 123");
+ evalJS("myObject.child.grandChild.jsProperty = 123");
+ if( garbageCollect ) {
+ garbageCollectJS();
+ QCOMPARE(evalJS("typeof myObject.child.grandChild != 'undefined'"), sTrue);
+ QCOMPARE(evalJS("myObject.child.grandChild.jsProperty == 123"), sTrue);
+ }
// delete grandchild
delete grandChild;
@@ -1000,6 +1058,18 @@ void tst_QWebFrame::getSetChildren()
delete child;
// QCOMPARE(evalJS("myObject.hasOwnProperty('child')"), sFalse);
QCOMPARE(evalJS("typeof myObject.child == 'undefined'"), sTrue);
+ if( garbageCollect ) {
+ garbageCollectJS();
+ QCOMPARE(evalJS("typeof myObject.child == 'undefined'"), sTrue);
+ }
+}
+
+
+void tst_QWebFrame::getSetChildren_data()
+{
+ QTest::addColumn<bool>("garbageCollect");
+ QTest::newRow("with garbageCollect") << true;
+ QTest::newRow("without garbageCollect") << false;
}
Q_DECLARE_METATYPE(QVector<int>)
@@ -1666,7 +1736,7 @@ void tst_QWebFrame::connectAndDisconnect()
m_myObject->emitMySignal();
QCOMPARE(m_myObject->qtFunctionInvoked(), 20);
evalJS("myObject = null");
- evalJS("gc()");
+ garbageCollectJS();
m_myObject->resetQtFunctionInvoked();
m_myObject->emitMySignal();
QCOMPARE(m_myObject->qtFunctionInvoked(), 20);