#include <qsslerror.h>
#endif
#include "../util.h"
-#include "../WebCoreSupport/DumpRenderTreeSupportQt.h"
struct CustomType {
QString string;
void cleanup();
private slots:
+ void getSetStaticProperty();
void getSetDynamicProperty();
- void getSetDynamicProperty_data();
void getSetChildren();
- void getSetChildren_data();
- void getSetStaticProperty();
void callQtInvokable();
void connectAndDisconnect();
void classEnums();
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
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) {
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
//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);
// 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)
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;
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>)
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"));
}
{
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);
{
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;
}
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;
" </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
// 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
view.resize(400, 100);
view.show();
QTest::qWaitForWindowShown(&view);
+ view.activateWindow();
view.setFocus();
QTRY_VERIFY(view.hasFocus());
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';");