OSDN Git Service

Merge WebKit at r73109: Initial merge by git.
[android-x86/external-webkit.git] / WebKit / qt / tests / qwebframe / tst_qwebframe.cpp
index 98ce663..eb3ae0a 100644 (file)
@@ -38,7 +38,6 @@
 #include <qsslerror.h>
 #endif
 #include "../util.h"
-#include "../WebCoreSupport/DumpRenderTreeSupportQt.h"
 
 struct CustomType {
     QString string;
@@ -572,11 +571,9 @@ 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();
@@ -605,8 +602,8 @@ private slots:
     void setHtmlWithJSAlert();
     void ipv6HostEncoding();
     void metaData();
-#if !defined(Q_WS_MAEMO_5)
-    // as maemo 5 does not use QComboBoxes to implement the popups
+#if !defined(Q_WS_MAEMO_5) && !defined(Q_OS_SYMBIAN)
+    // as maemo 5 && symbian do not use QComboBoxes to implement the popups
     // this test does not make sense for it.
     void popupFocus();
 #endif
@@ -674,10 +671,6 @@ 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) {
@@ -954,8 +947,6 @@ 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
 
@@ -967,34 +958,11 @@ 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);
@@ -1005,21 +973,10 @@ 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)
 
@@ -1031,27 +988,12 @@ 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;
@@ -1062,18 +1004,6 @@ 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>)
@@ -1636,26 +1566,26 @@ void tst_QWebFrame::connectAndDisconnect()
         QString type;
         QString ret = evalJS("(function() { }).connect()", type);
         QCOMPARE(type, sError);
-        QCOMPARE(ret, QLatin1String("TypeError: Result of expression '(function() { }).connect' [undefined] is not a function."));
+        QCOMPARE(ret, QLatin1String("TypeError: 'undefined' is not a function"));
     }
     {
         QString type;
         QString ret = evalJS("var o = { }; o.connect = Function.prototype.connect;  o.connect()", type);
         QCOMPARE(type, sError);
-        QCOMPARE(ret, QLatin1String("TypeError: Result of expression 'o.connect' [undefined] is not a function."));
+        QCOMPARE(ret, QLatin1String("TypeError: 'undefined' is not a function"));
     }
 
     {
         QString type;
         QString ret = evalJS("(function() { }).connect(123)", type);
         QCOMPARE(type, sError);
-        QCOMPARE(ret, QLatin1String("TypeError: Result of expression '(function() { }).connect' [undefined] is not a function."));
+        QCOMPARE(ret, QLatin1String("TypeError: 'undefined' is not a function"));
     }
     {
         QString type;
         QString ret = evalJS("var o = { }; o.connect = Function.prototype.connect;  o.connect(123)", type);
         QCOMPARE(type, sError);
-        QCOMPARE(ret, QLatin1String("TypeError: Result of expression 'o.connect' [undefined] is not a function."));
+        QCOMPARE(ret, QLatin1String("TypeError: 'undefined' is not a function"));
     }
 
     {
@@ -1740,7 +1670,7 @@ void tst_QWebFrame::connectAndDisconnect()
     m_myObject->emitMySignal();
     QCOMPARE(m_myObject->qtFunctionInvoked(), 20);
     evalJS("myObject = null");
-    garbageCollectJS();
+    evalJS("gc()");
     m_myObject->resetQtFunctionInvoked();
     m_myObject->emitMySignal();
     QCOMPARE(m_myObject->qtFunctionInvoked(), 20);
@@ -2459,7 +2389,9 @@ void tst_QWebFrame::javaScriptWindowObjectCleared_data()
 {
     QTest::addColumn<QString>("html");
     QTest::addColumn<int>("signalCount");
-    QTest::newRow("with <script>") << "<html><body><script></script><p>hello world</p></body></html>" << 1;
+    QTest::newRow("with <script>") << "<html><body><script>i=0</script><p>hello world</p></body></html>" << 1;
+    // NOTE: Empty scripts no longer cause this signal to be emitted.
+    QTest::newRow("with empty <script>") << "<html><body><script></script><p>hello world</p></body></html>" << 0;
     QTest::newRow("without <script>") << "<html><body><p>hello world</p></body></html>" << 0;
 }
 
@@ -2655,7 +2587,7 @@ void tst_QWebFrame::metaData()
     QCOMPARE(metaData.value("nonexistant"), QString());
 }
 
-#if !defined(Q_WS_MAEMO_5)
+#if !defined(Q_WS_MAEMO_5) && !defined(Q_OS_SYMBIAN)
 void tst_QWebFrame::popupFocus()
 {
     QWebView view;
@@ -2673,8 +2605,11 @@ void tst_QWebFrame::popupFocus()
                  "    </body>"
                  "</html>");
     view.resize(400, 100);
-    view.show();
+    // Call setFocus before show to work around http://bugreports.qt.nokia.com/browse/QTBUG-14762
     view.setFocus();
+    view.show();
+    QTest::qWaitForWindowShown(&view);
+    view.activateWindow();
     QTRY_VERIFY(view.hasFocus());
 
     // open the popup by clicking. check if focus is on the popup
@@ -2687,7 +2622,7 @@ void tst_QWebFrame::popupFocus()
 
     // hide the popup and check if focus is on the page
     combo->hidePopup();
-    QTRY_VERIFY(view.hasFocus() && !combo->view()->hasFocus()); // Focus should be back on the WebView
+    QTRY_VERIFY(view.hasFocus()); // Focus should be back on the WebView
 }
 #endif
 
@@ -2698,6 +2633,7 @@ void tst_QWebFrame::inputFieldFocus()
     view.resize(400, 100);
     view.show();
     QTest::qWaitForWindowShown(&view);
+    view.activateWindow();
     view.setFocus();
     QTRY_VERIFY(view.hasFocus());
 
@@ -3016,12 +2952,7 @@ void tst_QWebFrame::evaluateWillCauseRepaint()
     view.setHtml(html);
     view.show();
 
-#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
     QTest::qWaitForWindowShown(&view);
-#else
-    QTest::qWait(2000);
-#endif
-
     view.page()->mainFrame()->evaluateJavaScript(
         "document.getElementById('junk').style.display = 'none';");