summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/webkit/WebKit/qt/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/webkit/WebKit/qt/tests')
-rw-r--r--src/3rdparty/webkit/WebKit/qt/tests/benchmarks/loading/tst_loading.pro5
-rw-r--r--src/3rdparty/webkit/WebKit/qt/tests/benchmarks/painting/tst_painting.pro5
-rw-r--r--src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/qgraphicswebview.pro4
-rw-r--r--src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp82
-rw-r--r--src/3rdparty/webkit/WebKit/qt/tests/qwebelement/image.pngbin0 -> 14743 bytes
-rw-r--r--src/3rdparty/webkit/WebKit/qt/tests/qwebelement/qwebelement.pro5
-rw-r--r--src/3rdparty/webkit/WebKit/qt/tests/qwebelement/qwebelement.qrc1
-rw-r--r--src/3rdparty/webkit/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp220
-rw-r--r--src/3rdparty/webkit/WebKit/qt/tests/qwebframe/qwebframe.pro6
-rw-r--r--src/3rdparty/webkit/WebKit/qt/tests/qwebframe/resources/image2.pngbin0 -> 14743 bytes
-rw-r--r--src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp80
-rw-r--r--src/3rdparty/webkit/WebKit/qt/tests/qwebhistory/qwebhistory.pro5
-rw-r--r--src/3rdparty/webkit/WebKit/qt/tests/qwebhistory/tst_qwebhistory.cpp80
-rw-r--r--src/3rdparty/webkit/WebKit/qt/tests/qwebhistoryinterface/qwebhistoryinterface.pro5
-rw-r--r--src/3rdparty/webkit/WebKit/qt/tests/qwebpage/qwebpage.pro6
-rw-r--r--src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp436
-rw-r--r--src/3rdparty/webkit/WebKit/qt/tests/qwebplugindatabase/qwebplugindatabase.pro5
-rw-r--r--src/3rdparty/webkit/WebKit/qt/tests/qwebview/data/frame_a.html2
-rw-r--r--src/3rdparty/webkit/WebKit/qt/tests/qwebview/data/index.html4
-rw-r--r--src/3rdparty/webkit/WebKit/qt/tests/qwebview/qwebview.pro7
-rw-r--r--src/3rdparty/webkit/WebKit/qt/tests/qwebview/tst_qwebview.cpp140
-rw-r--r--src/3rdparty/webkit/WebKit/qt/tests/qwebview/tst_qwebview.qrc7
-rw-r--r--src/3rdparty/webkit/WebKit/qt/tests/resources/test.swfbin0 -> 10085 bytes
-rw-r--r--src/3rdparty/webkit/WebKit/qt/tests/tests.pro2
24 files changed, 912 insertions, 195 deletions
diff --git a/src/3rdparty/webkit/WebKit/qt/tests/benchmarks/loading/tst_loading.pro b/src/3rdparty/webkit/WebKit/qt/tests/benchmarks/loading/tst_loading.pro
index 80717c24c4..bc5e75f208 100644
--- a/src/3rdparty/webkit/WebKit/qt/tests/benchmarks/loading/tst_loading.pro
+++ b/src/3rdparty/webkit/WebKit/qt/tests/benchmarks/loading/tst_loading.pro
@@ -5,4 +5,7 @@ SOURCES += tst_loading.cpp
QT += testlib network
QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR
-symbian:TARGET.UID3 = 0xA000E541
+symbian {
+ TARGET.UID3 = 0xA000E541
+ TARGET.CAPABILITY = ReadUserData WriteUserData NetworkServices
+}
diff --git a/src/3rdparty/webkit/WebKit/qt/tests/benchmarks/painting/tst_painting.pro b/src/3rdparty/webkit/WebKit/qt/tests/benchmarks/painting/tst_painting.pro
index f45d80429e..48c7072279 100644
--- a/src/3rdparty/webkit/WebKit/qt/tests/benchmarks/painting/tst_painting.pro
+++ b/src/3rdparty/webkit/WebKit/qt/tests/benchmarks/painting/tst_painting.pro
@@ -5,4 +5,7 @@ SOURCES += tst_painting.cpp
QT += testlib network
QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR
-symbian:TARGET.UID3 = 0xA000E542
+symbian {
+ TARGET.UID3 = 0xA000E542
+ TARGET.CAPABILITY = ReadUserData WriteUserData NetworkServices
+}
diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/qgraphicswebview.pro b/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/qgraphicswebview.pro
index cba6f11fab..57b44375ff 100644
--- a/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/qgraphicswebview.pro
+++ b/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/qgraphicswebview.pro
@@ -4,3 +4,7 @@ include(../../../../WebKit.pri)
SOURCES += tst_qgraphicswebview.cpp
QT += testlib network
QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR
+
+symbian {
+ TARGET.CAPABILITY = ReadUserData WriteUserData NetworkServices
+}
diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp
index 1a572860fe..a52e167c2e 100644
--- a/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp
@@ -19,7 +19,33 @@
#include <QtTest/QtTest>
+#include <QGraphicsView>
#include <qgraphicswebview.h>
+#include <qwebpage.h>
+#include <qwebframe.h>
+
+/**
+ * Starts an event loop that runs until the given signal is received.
+ * Optionally the event loop
+ * can return earlier on a timeout.
+ *
+ * \return \p true if the requested signal was received
+ * \p false on timeout
+ */
+static bool waitForSignal(QObject* obj, const char* signal, int timeout = 10000)
+{
+ QEventLoop loop;
+ QObject::connect(obj, signal, &loop, SLOT(quit()));
+ QTimer timer;
+ QSignalSpy timeoutSpy(&timer, SIGNAL(timeout()));
+ if (timeout > 0) {
+ QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
+ timer.setSingleShot(true);
+ timer.start(timeout);
+ }
+ loop.exec();
+ return timeoutSpy.isEmpty();
+}
class tst_QGraphicsWebView : public QObject
{
@@ -27,6 +53,7 @@ class tst_QGraphicsWebView : public QObject
private slots:
void qgraphicswebview();
+ void crashOnViewlessWebPages();
};
void tst_QGraphicsWebView::qgraphicswebview()
@@ -36,21 +63,66 @@ void tst_QGraphicsWebView::qgraphicswebview()
item.title();
item.icon();
item.zoomFactor();
- item.isInteractive();
- item.progress();
- item.toHtml();
item.history();
item.settings();
- item.status();
item.page();
item.setPage(0);
item.page();
item.setUrl(QUrl());
item.setZoomFactor(0);
- item.setInteractive(true);
item.load(QUrl());
item.setHtml(QString());
item.setContent(QByteArray());
+ item.isModified();
+}
+
+class WebPage : public QWebPage
+{
+ Q_OBJECT
+
+public:
+ WebPage(QObject* parent = 0): QWebPage(parent)
+ {
+ }
+
+ QGraphicsWebView* webView;
+
+private slots:
+ // Force a webview deletion during the load.
+ // It should not cause WebPage to crash due to
+ // it accessing invalid pageClient pointer.
+ void aborting()
+ {
+ delete webView;
+ }
+};
+
+void tst_QGraphicsWebView::crashOnViewlessWebPages()
+{
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+
+ QGraphicsWebView* webView = new QGraphicsWebView;
+ WebPage* page = new WebPage;
+ webView->setPage(page);
+ page->webView = webView;
+ connect(page->mainFrame(), SIGNAL(initialLayoutCompleted()), page, SLOT(aborting()));
+
+ scene.addItem(webView);
+
+ view.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ view.resize(600, 480);
+ webView->resize(view.geometry().size());
+ QTest::qWait(200);
+ view.show();
+
+ page->mainFrame()->setHtml(QString("data:text/html,"
+ "<frameset cols=\"25%,75%\">"
+ "<frame src=\"data:text/html,foo \">"
+ "<frame src=\"data:text/html,bar\">"
+ "</frameset>"));
+
+ QVERIFY(::waitForSignal(page, SIGNAL(loadFinished(bool))));
}
QTEST_MAIN(tst_QGraphicsWebView)
diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebelement/image.png b/src/3rdparty/webkit/WebKit/qt/tests/qwebelement/image.png
new file mode 100644
index 0000000000..8d703640c1
--- /dev/null
+++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebelement/image.png
Binary files differ
diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebelement/qwebelement.pro b/src/3rdparty/webkit/WebKit/qt/tests/qwebelement/qwebelement.pro
index 0a140ad63c..c45a9ac5a1 100644
--- a/src/3rdparty/webkit/WebKit/qt/tests/qwebelement/qwebelement.pro
+++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebelement/qwebelement.pro
@@ -6,4 +6,7 @@ RESOURCES += qwebelement.qrc
QT += testlib network
QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR
-symbian:TARGET.UID3 = 0xA000E53A
+symbian {
+ TARGET.UID3 = 0xA000E53A
+ TARGET.CAPABILITY = ReadUserData WriteUserData NetworkServices
+}
diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebelement/qwebelement.qrc b/src/3rdparty/webkit/WebKit/qt/tests/qwebelement/qwebelement.qrc
index ed014407a2..28b9d7b3a1 100644
--- a/src/3rdparty/webkit/WebKit/qt/tests/qwebelement/qwebelement.qrc
+++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebelement/qwebelement.qrc
@@ -2,5 +2,6 @@
<qresource prefix="/">
<file>style.css</file>
<file>style2.css</file>
+<file>image.png</file>
</qresource>
</RCC>
diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp
index 00783d12e6..a04e66110a 100644
--- a/src/3rdparty/webkit/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp
@@ -68,9 +68,15 @@ private slots:
void simpleCollection();
void attributes();
void attributesNS();
+ void listAttributes();
void classes();
void namespaceURI();
+ void iteration();
+ void nonConstIterator();
+ void constIterator();
void foreachManipulation();
+ void emptyCollection();
+ void appendCollection();
void evaluateJavaScript();
void documentElement();
void frame();
@@ -87,6 +93,7 @@ private slots:
void firstChildNextSibling();
void lastChildPreviousSibling();
void hasSetFocus();
+ void render();
private:
QWebView* m_view;
@@ -133,7 +140,7 @@ void tst_QWebElement::simpleCollection()
m_mainFrame->setHtml(html);
QWebElement body = m_mainFrame->documentElement();
- QList<QWebElement> list = body.findAll("p");
+ QWebElementCollection list = body.findAll("p");
QCOMPARE(list.count(), 2);
QCOMPARE(list.at(0).toPlainText(), QString("first para"));
QCOMPARE(list.at(1).toPlainText(), QString("second para"));
@@ -181,6 +188,29 @@ void tst_QWebElement::attributesNS()
QCOMPARE(svg.attributeNS("http://www.w3.org/2000/svg", "foobar", "defaultblah"), QString("true"));
}
+void tst_QWebElement::listAttributes()
+{
+ QString content = "<html xmlns=\"http://www.w3.org/1999/xhtml\" "
+ "xmlns:svg=\"http://www.w3.org/2000/svg\">"
+ "<body><svg:svg foo=\"\" svg:bar=\"\">"
+ "</svg:svg></body></html>";
+
+ m_mainFrame->setContent(content.toUtf8(), "application/xhtml+xml");
+
+ QWebElement svg = m_mainFrame->findFirstElement("svg");
+ QVERIFY(!svg.isNull());
+
+ QVERIFY(svg.attributeNames().contains("foo"));
+ QVERIFY(svg.attributeNames("http://www.w3.org/2000/svg").contains("bar"));
+
+ svg.setAttributeNS("http://www.w3.org/2000/svg", "svg:foobar", "true");
+ QVERIFY(svg.attributeNames().contains("foo"));
+ QStringList attributes = svg.attributeNames("http://www.w3.org/2000/svg");
+ QCOMPARE(attributes.size(), 2);
+ QVERIFY(attributes.contains("bar"));
+ QVERIFY(attributes.contains("foobar"));
+}
+
void tst_QWebElement::classes()
{
m_mainFrame->setHtml("<body><p class=\"a b c d a c\">Test");
@@ -266,6 +296,72 @@ void tst_QWebElement::namespaceURI()
}
+void tst_QWebElement::iteration()
+{
+ QString html = "<body><p>first para</p><p>second para</p></body>";
+ m_mainFrame->setHtml(html);
+ QWebElement body = m_mainFrame->documentElement();
+
+ QWebElementCollection paras = body.findAll("p");
+ QList<QWebElement> referenceList = paras.toList();
+
+ QList<QWebElement> foreachList;
+ foreach(QWebElement p, paras) {
+ foreachList.append(p);
+ }
+ QVERIFY(foreachList.count() == 2);
+ QCOMPARE(foreachList.count(), referenceList.count());
+ QCOMPARE(foreachList.at(0), referenceList.at(0));
+ QCOMPARE(foreachList.at(1), referenceList.at(1));
+
+ QList<QWebElement> forLoopList;
+ for (int i = 0; i < paras.count(); ++i) {
+ forLoopList.append(paras.at(i));
+ }
+ QVERIFY(foreachList.count() == 2);
+ QCOMPARE(foreachList.count(), referenceList.count());
+ QCOMPARE(foreachList.at(0), referenceList.at(0));
+ QCOMPARE(foreachList.at(1), referenceList.at(1));
+
+ for (int i = 0; i < paras.count(); ++i) {
+ QCOMPARE(paras.at(i), paras[i]);
+ }
+
+ QCOMPARE(paras.at(0), paras.first());
+ QCOMPARE(paras.at(1), paras.last());
+}
+
+void tst_QWebElement::nonConstIterator()
+{
+ QString html = "<body><p>first para</p><p>second para</p></body>";
+ m_mainFrame->setHtml(html);
+ QWebElement body = m_mainFrame->documentElement();
+ QWebElementCollection paras = body.findAll("p");
+
+ QWebElementCollection::iterator it = paras.begin();
+ QCOMPARE(*it, paras.at(0));
+ ++it;
+ (*it).encloseWith("<div>");
+ QCOMPARE(*it, paras.at(1));
+ ++it;
+ QCOMPARE(it, paras.end());
+}
+
+void tst_QWebElement::constIterator()
+{
+ QString html = "<body><p>first para</p><p>second para</p></body>";
+ m_mainFrame->setHtml(html);
+ QWebElement body = m_mainFrame->documentElement();
+ const QWebElementCollection paras = body.findAll("p");
+
+ QWebElementCollection::const_iterator it = paras.begin();
+ QCOMPARE(*it, paras.at(0));
+ ++it;
+ QCOMPARE(*it, paras.at(1));
+ ++it;
+ QCOMPARE(it, paras.end());
+}
+
void tst_QWebElement::foreachManipulation()
{
QString html = "<body><p>first para</p><p>second para</p></body>";
@@ -279,6 +375,43 @@ void tst_QWebElement::foreachManipulation()
QCOMPARE(body.findAll("div").count(), 4);
}
+void tst_QWebElement::emptyCollection()
+{
+ QWebElementCollection emptyCollection;
+ QCOMPARE(emptyCollection.count(), 0);
+}
+
+void tst_QWebElement::appendCollection()
+{
+ QString html = "<body><span class='a'>aaa</span><p>first para</p><div>foo</div>"
+ "<span class='b'>bbb</span><p>second para</p><div>bar</div></body>";
+ m_mainFrame->setHtml(html);
+ QWebElement body = m_mainFrame->documentElement();
+
+ QWebElementCollection collection = body.findAll("p");
+ QCOMPARE(collection.count(), 2);
+
+ collection.append(body.findAll("div"));
+ QCOMPARE(collection.count(), 4);
+
+ collection += body.findAll("span.a");
+ QCOMPARE(collection.count(), 5);
+
+ QWebElementCollection all = collection + body.findAll("span.b");
+ QCOMPARE(all.count(), 6);
+ QCOMPARE(collection.count(), 5);
+
+ all += collection;
+ QCOMPARE(all.count(), 11);
+
+ QCOMPARE(collection.count(), 5);
+ QWebElementCollection test;
+ test.append(collection);
+ QCOMPARE(test.count(), 5);
+ test.append(QWebElementCollection());
+ QCOMPARE(test.count(), 5);
+}
+
void tst_QWebElement::evaluateJavaScript()
{
QVariant result;
@@ -628,7 +761,7 @@ void tst_QWebElement::clear()
QCOMPARE(body.findAll("div").count(), 1);
QCOMPARE(body.findAll("p").count(), 3);
- body.findFirst("div").removeChildren();
+ body.findFirst("div").removeAllChildren();
QCOMPARE(body.findAll("div").count(), 1);
QCOMPARE(body.findAll("p").count(), 2);
}
@@ -772,7 +905,7 @@ void tst_QWebElement::nullSelect()
{
m_mainFrame->setHtml("<body><p>Test");
- QList<QWebElement> collection = m_mainFrame->findAllElements("invalid{syn(tax;;%#$f223e>>");
+ QWebElementCollection collection = m_mainFrame->findAllElements("invalid{syn(tax;;%#$f223e>>");
QVERIFY(collection.count() == 0);
}
@@ -814,7 +947,7 @@ void tst_QWebElement::hasSetFocus()
"<input type='text' id='input2'/>" \
"</body></html>");
- QList<QWebElement> inputs = m_mainFrame->documentElement().findAll("input");
+ QWebElementCollection inputs = m_mainFrame->documentElement().findAll("input");
QWebElement input1 = inputs.at(0);
input1.setFocus();
QVERIFY(input1.hasFocus());
@@ -825,5 +958,84 @@ void tst_QWebElement::hasSetFocus()
QVERIFY(input2.hasFocus());
}
+void tst_QWebElement::render()
+{
+ QString html( "<html>"
+ "<head><style>"
+ "body, iframe { margin: 0px; border: none; }"
+ "</style></head>"
+ "<body><table width='300px' height='300px' border='1'>"
+ "<tr>"
+ "<td>test"
+ "</td>"
+ "<td><img src='qrc:///image.png'>"
+ "</td>"
+ "</tr>"
+ "</table>"
+ "</body>"
+ "</html>"
+ );
+
+ QWebPage page;
+ QSignalSpy loadSpy(&page, SIGNAL(loadFinished(bool)));
+ page.mainFrame()->setHtml(html);
+
+ waitForSignal(&page, SIGNAL(loadFinished(bool)));
+ QCOMPARE(loadSpy.count(), 1);
+
+ QSize size = page.mainFrame()->contentsSize();
+ page.setViewportSize(size);
+
+ QWebElementCollection imgs = page.mainFrame()->findAllElements("img");
+ QCOMPARE(imgs.count(), 1);
+
+ QImage resource(":/image.png");
+ QRect imageRect(0, 0, resource.width(), resource.height());
+
+ QImage testImage(resource.width(), resource.height(), QImage::Format_ARGB32);
+ QPainter painter0(&testImage);
+ painter0.fillRect(imageRect, Qt::white);
+ //render() uses pixmaps internally, and pixmaps might have bit depths
+ // other than 32, giving different pixel values due to rounding.
+ QPixmap pix = QPixmap::fromImage(resource);
+ painter0.drawPixmap(0, 0, pix);
+ painter0.end();
+
+ QImage image1(resource.width(), resource.height(), QImage::Format_ARGB32);
+ QPainter painter1(&image1);
+ painter1.fillRect(imageRect, Qt::white);
+ imgs[0].render(&painter1);
+ painter1.end();
+
+ QVERIFY(image1 == testImage);
+
+ // render image 2nd time to make sure that cached rendering works fine
+ QImage image2(resource.width(), resource.height(), QImage::Format_ARGB32);
+ QPainter painter2(&image2);
+ painter2.fillRect(imageRect, Qt::white);
+ imgs[0].render(&painter2);
+ painter2.end();
+
+ QVERIFY(image2 == testImage);
+
+ // compare table rendered through QWebElement::render to whole page table rendering
+ QRect tableRect(0, 0, 300, 300);
+ QWebElementCollection tables = page.mainFrame()->findAllElements("table");
+ QCOMPARE(tables.count(), 1);
+
+ QImage image3(300, 300, QImage::Format_ARGB32);
+ QPainter painter3(&image3);
+ painter3.fillRect(tableRect, Qt::white);
+ tables[0].render(&painter3);
+ painter3.end();
+
+ QImage image4(300, 300, QImage::Format_ARGB32);
+ QPainter painter4(&image4);
+ page.mainFrame()->render(&painter4, tableRect);
+ painter4.end();
+
+ QVERIFY(image3 == image4);
+}
+
QTEST_MAIN(tst_QWebElement)
#include "tst_qwebelement.moc"
diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/qwebframe.pro b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/qwebframe.pro
index 81037c30ec..b8734cd751 100644
--- a/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/qwebframe.pro
+++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/qwebframe.pro
@@ -5,5 +5,9 @@ SOURCES += tst_qwebframe.cpp
RESOURCES += qwebframe.qrc
QT += testlib network
QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR
+!symbian:DEFINES += SRCDIR=\\\"$$PWD/resources\\\"
-symbian:TARGET.UID3 = 0xA000E53D
+symbian {
+ TARGET.UID3 = 0xA000E53D
+ TARGET.CAPABILITY = ReadUserData WriteUserData NetworkServices
+}
diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/resources/image2.png b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/resources/image2.png
new file mode 100644
index 0000000000..8d703640c1
--- /dev/null
+++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/resources/image2.png
Binary files differ
diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
index 797446b988..b00cf0930b 100644
--- a/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
@@ -38,6 +38,10 @@
#endif
#include "../util.h"
+#if defined(Q_OS_SYMBIAN)
+# define SRCDIR ""
+#endif
+
//TESTED_CLASS=
//TESTED_FILES=
@@ -586,6 +590,8 @@ private slots:
void javaScriptWindowObjectClearedOnEvaluate();
void setHtml();
void setHtmlWithResource();
+ void setHtmlWithBaseURL();
+ void setHtmlWithJSAlert();
void ipv6HostEncoding();
void metaData();
void popupFocus();
@@ -699,6 +705,7 @@ void tst_QWebFrame::init()
m_page = m_view->page();
m_myObject = new MyQObject();
m_page->mainFrame()->addToJavaScriptWindowObject("myObject", m_myObject);
+ QDir::setCurrent(SRCDIR);
}
void tst_QWebFrame::cleanup()
@@ -2370,6 +2377,55 @@ void tst_QWebFrame::setHtmlWithResource()
QCOMPARE(p.styleProperty("color", QWebElement::CascadedStyle), QLatin1String("red"));
}
+void tst_QWebFrame::setHtmlWithBaseURL()
+{
+ QString html("<html><body><p>hello world</p><img src='resources/image2.png'/></body></html>");
+
+ QWebPage page;
+ QWebFrame* frame = page.mainFrame();
+
+ // in few seconds, the image should be completey loaded
+ QSignalSpy spy(&page, SIGNAL(loadFinished(bool)));
+
+ frame->setHtml(html, QUrl::fromLocalFile(QDir::currentPath()));
+ QTest::qWait(200);
+ QCOMPARE(spy.count(), 1);
+
+ QCOMPARE(frame->evaluateJavaScript("document.images.length").toInt(), 1);
+ QCOMPARE(frame->evaluateJavaScript("document.images[0].width").toInt(), 128);
+ QCOMPARE(frame->evaluateJavaScript("document.images[0].height").toInt(), 128);
+
+ // no history item has to be added.
+ QCOMPARE(m_view->page()->history()->count(), 0);
+}
+
+class MyPage : public QWebPage
+{
+public:
+ MyPage() : QWebPage(), alerts(0) {}
+ int alerts;
+
+protected:
+ virtual void javaScriptAlert(QWebFrame*, const QString& msg)
+ {
+ alerts++;
+ QCOMPARE(msg, QString("foo"));
+ // Should not be enough to trigger deferred loading, since we've upped the HTML
+ // tokenizer delay in the Qt frameloader. See HTMLTokenizer::continueProcessing()
+ QTest::qWait(1000);
+ }
+};
+
+void tst_QWebFrame::setHtmlWithJSAlert()
+{
+ QString html("<html><head></head><body><script>alert('foo');</script><p>hello world</p></body></html>");
+ MyPage page;
+ m_view->setPage(&page);
+ page.mainFrame()->setHtml(html);
+ QCOMPARE(page.alerts, 1);
+ QCOMPARE(m_view->page()->mainFrame()->toHtml(), html);
+}
+
class TestNetworkManager : public QNetworkAccessManager
{
public:
@@ -2667,26 +2723,24 @@ void tst_QWebFrame::render()
QPicture picture;
- // render clipping to Viewport
- frame->setClipRenderToViewport(true);
+ QSize size = page.mainFrame()->contentsSize();
+ page.setViewportSize(size);
+
+ // render contents layer only (the iframe is smaller than the image, so it will have scrollbars)
QPainter painter1(&picture);
- frame->render(&painter1);
+ frame->render(&painter1, QWebFrame::ContentsLayer);
painter1.end();
- QSize size = page.mainFrame()->contentsSize();
- page.setViewportSize(size);
- QCOMPARE(size.width(), picture.boundingRect().width()); // 100px
- QCOMPARE(size.height(), picture.boundingRect().height()); // 100px
+ QCOMPARE(size.width(), picture.boundingRect().width() + frame->scrollBarGeometry(Qt::Vertical).width());
+ QCOMPARE(size.height(), picture.boundingRect().height() + frame->scrollBarGeometry(Qt::Horizontal).height());
- // render without clipping to Viewport
- frame->setClipRenderToViewport(false);
+ // render everything, should be the size of the iframe
QPainter painter2(&picture);
- frame->render(&painter2);
+ frame->render(&painter2, QWebFrame::AllLayers);
painter2.end();
- QImage resource(":/image.png");
- QCOMPARE(resource.width(), picture.boundingRect().width()); // resource width: 128px
- QCOMPARE(resource.height(), picture.boundingRect().height()); // resource height: 128px
+ QCOMPARE(size.width(), picture.boundingRect().width()); // width: 100px
+ QCOMPARE(size.height(), picture.boundingRect().height()); // height: 100px
}
void tst_QWebFrame::scrollPosition()
diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebhistory/qwebhistory.pro b/src/3rdparty/webkit/WebKit/qt/tests/qwebhistory/qwebhistory.pro
index 8ee63cc6ac..7445e3bac8 100644
--- a/src/3rdparty/webkit/WebKit/qt/tests/qwebhistory/qwebhistory.pro
+++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebhistory/qwebhistory.pro
@@ -6,4 +6,7 @@ RESOURCES += tst_qwebhistory.qrc
QT += testlib network
QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR
-symbian:TARGET.UID3 = 0xA000E53B
+symbian {
+ TARGET.UID3 = 0xA000E53B
+ TARGET.CAPABILITY = ReadUserData WriteUserData NetworkServices
+}
diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebhistory/tst_qwebhistory.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebhistory/tst_qwebhistory.cpp
index 4f4d3c4836..ec2d497b0c 100644
--- a/src/3rdparty/webkit/WebKit/qt/tests/qwebhistory/tst_qwebhistory.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebhistory/tst_qwebhistory.cpp
@@ -56,9 +56,6 @@ private slots:
void serialize_1(); //QWebHistory countity
void serialize_2(); //QWebHistory index
void serialize_3(); //QWebHistoryItem
- void saveAndRestore_1(); //simple checks saveState and restoreState
- void saveAndRestore_2(); //bad parameters saveState and restoreState
- void saveAndRestore_3(); //try use different version
void saveAndRestore_crash_1();
void saveAndRestore_crash_2();
void saveAndRestore_crash_3();
@@ -294,67 +291,40 @@ void tst_QWebHistory::serialize_3()
QVERIFY(load.atEnd());
}
-/** Simple checks should be a bit redundant to streaming operators */
-void tst_QWebHistory::saveAndRestore_1()
+static void saveHistory(QWebHistory* history, QByteArray* in)
{
- QAction* actionBack = page->action(QWebPage::Back);
- hist->back();
- waitForLoadFinished.exec();
- QVERIFY(actionBack->isEnabled());
- QByteArray buffer(hist->saveState());
- hist->clear();
- QVERIFY(!actionBack->isEnabled());
- QVERIFY(hist->count() == 1);
- hist->restoreState(buffer);
-
- //check only few values, do not make full test
- //because most of the code is shared with streaming operators
- //and these are checked before
- QCOMPARE(hist->count(), histsize);
- QCOMPARE(hist->currentItemIndex(), histsize - 2);
- QCOMPARE(hist->itemAt(0).title(), QString("page1"));
- QCOMPARE(hist->itemAt(histsize - 1).title(), QString("page") + QString::number(histsize));
- QVERIFY(actionBack->isEnabled());
+ in->clear();
+ QDataStream save(in, QIODevice::WriteOnly);
+ save << *history;
}
-/** Check returns value if there are bad parameters. Actually, result
- * is no so importent. The test shouldn't crash :-) */
-void tst_QWebHistory::saveAndRestore_2()
+static void restoreHistory(QWebHistory* history, QByteArray* out)
{
- QByteArray buffer;
- hist->restoreState(buffer);
- QVERIFY(hist->count() == 1);
- QVERIFY(hist->itemAt(0).isValid());
-}
-
-/** Try to use bad version value */
-void tst_QWebHistory::saveAndRestore_3()
-{
- QByteArray tmp = hist->saveState((QWebHistory::HistoryStateVersion)29999);
- QVERIFY(hist->saveState((QWebHistory::HistoryStateVersion)29999).isEmpty());
- QVERIFY(hist->count() == histsize);
- QVERIFY(hist->itemAt(3).isValid());
+ QDataStream load(out, QIODevice::ReadOnly);
+ load >> *history;
}
/** The test shouldn't crash */
void tst_QWebHistory::saveAndRestore_crash_1()
{
- QByteArray tmp = hist->saveState();
- for (unsigned i = 0; i < 5; i++){
- hist->restoreState(tmp);
- hist->saveState();
+ QByteArray buffer;
+ saveHistory(hist, &buffer);
+ for (unsigned i = 0; i < 5; i++) {
+ restoreHistory(hist, &buffer);
+ saveHistory(hist, &buffer);
}
}
/** The test shouldn't crash */
void tst_QWebHistory::saveAndRestore_crash_2()
{
- QByteArray tmp = hist->saveState();
+ QByteArray buffer;
+ saveHistory(hist, &buffer);
QWebPage* page2 = new QWebPage(this);
QWebHistory* hist2 = page2->history();
- for (unsigned i = 0; i < 5; i++){
- hist2->restoreState(tmp);
- hist2->saveState();
+ for (unsigned i = 0; i < 5; i++) {
+ restoreHistory(hist2, &buffer);
+ saveHistory(hist2, &buffer);
}
delete page2;
}
@@ -362,17 +332,18 @@ void tst_QWebHistory::saveAndRestore_crash_2()
/** The test shouldn't crash */
void tst_QWebHistory::saveAndRestore_crash_3()
{
- QByteArray tmp = hist->saveState();
+ QByteArray buffer;
+ saveHistory(hist, &buffer);
QWebPage* page2 = new QWebPage(this);
QWebHistory* hist1 = hist;
QWebHistory* hist2 = page2->history();
- for (unsigned i = 0; i < 5; i++){
- hist1->restoreState(tmp);
- hist2->restoreState(tmp);
+ for (unsigned i = 0; i < 5; i++) {
+ restoreHistory(hist1, &buffer);
+ restoreHistory(hist2, &buffer);
QVERIFY(hist1->count() == hist2->count());
QVERIFY(hist1->count() == histsize);
hist2->back();
- tmp = hist2->saveState();
+ saveHistory(hist2, &buffer);
hist2->clear();
}
delete page2;
@@ -381,15 +352,16 @@ void tst_QWebHistory::saveAndRestore_crash_3()
/** ::clear */
void tst_QWebHistory::clear()
{
+ QByteArray buffer;
+
QAction* actionBack = page->action(QWebPage::Back);
QVERIFY(actionBack->isEnabled());
- hist->saveState();
+ saveHistory(hist, &buffer);
QVERIFY(hist->count() > 1);
hist->clear();
QVERIFY(hist->count() == 1); // Leave current item.
QVERIFY(!actionBack->isEnabled());
-
QWebPage* page2 = new QWebPage(this);
QWebHistory* hist2 = page2->history();
QVERIFY(hist2->count() == 0);
diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebhistoryinterface/qwebhistoryinterface.pro b/src/3rdparty/webkit/WebKit/qt/tests/qwebhistoryinterface/qwebhistoryinterface.pro
index 53e1afe5d4..764f806df1 100644
--- a/src/3rdparty/webkit/WebKit/qt/tests/qwebhistoryinterface/qwebhistoryinterface.pro
+++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebhistoryinterface/qwebhistoryinterface.pro
@@ -5,4 +5,7 @@ SOURCES += tst_qwebhistoryinterface.cpp
QT += testlib network
QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR
-symbian:TARGET.UID3 = 0xA000E53C
+symbian {
+ TARGET.UID3 = 0xA000E53C
+ TARGET.CAPABILITY = ReadUserData WriteUserData NetworkServices
+}
diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/qwebpage.pro b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/qwebpage.pro
index 82ffac68d6..7853b28767 100644
--- a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/qwebpage.pro
+++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/qwebpage.pro
@@ -5,5 +5,9 @@ SOURCES += tst_qwebpage.cpp
RESOURCES += tst_qwebpage.qrc
QT += testlib network
QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR
+!symbian:DEFINES += SRCDIR=\\\"$$PWD/\\\"
-symbian:TARGET.UID3 = 0xA000E53E
+symbian {
+ TARGET.UID3 = 0xA000E53E
+ TARGET.CAPABILITY = ReadUserData WriteUserData NetworkServices
+}
diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
index bdcc27ff83..7fc364028f 100644
--- a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
@@ -1,5 +1,6 @@
/*
Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
+ Copyright (C) 2009 Girish Ramakrishnan <girish@forwardbias.in>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -20,9 +21,13 @@
#include <QtTest/QtTest>
+#include <qgraphicsscene.h>
+#include <qgraphicsview.h>
+#include <qgraphicswebview.h>
#include <qwebelement.h>
#include <qwebpage.h>
#include <qwidget.h>
+#include <QGraphicsWidget>
#include <qwebview.h>
#include <qwebframe.h>
#include <qwebhistory.h>
@@ -33,6 +38,11 @@
#include <qwebsecurityorigin.h>
#include <qwebdatabase.h>
#include <QPushButton>
+#include <QDir>
+
+#if defined(Q_OS_SYMBIAN)
+# define SRCDIR ""
+#endif
// Will try to wait for the condition while allowing event processing
#define QTRY_COMPARE(__expr, __expected) \
@@ -75,6 +85,22 @@ static bool waitForSignal(QObject* obj, const char* signal, int timeout = 10000)
return timeoutSpy.isEmpty();
}
+class EventSpy : public QObject, public QList<QEvent::Type>
+{
+ Q_OBJECT
+public:
+ EventSpy(QObject* objectToSpy)
+ {
+ objectToSpy->installEventFilter(this);
+ }
+
+ virtual bool eventFilter(QObject* receiver, QEvent* event)
+ {
+ append(event->type());
+ return false;
+ }
+};
+
class tst_QWebPage : public QObject
{
Q_OBJECT
@@ -101,7 +127,9 @@ private slots:
void contextMenuCrash();
void database();
void createPlugin();
+ void destroyPlugin_data();
void destroyPlugin();
+ void createViewlessPlugin_data();
void createViewlessPlugin();
void multiplePageGroupsAndLocalStorage();
void cursorMovements();
@@ -115,10 +143,18 @@ private slots:
void testOptionalJSObjects();
void testEnablePersistentStorage();
void consoleOutput();
+ void inputMethods_data();
void inputMethods();
+ void defaultTextEncoding();
+ void errorPageExtension();
void crashTests_LazyInitializationOfMainFrame();
+ void screenshot_data();
+ void screenshot();
+
+ void originatingObjectInNetworkRequests();
+
private:
QWebView* m_view;
QWebPage* m_page;
@@ -222,6 +258,8 @@ void tst_QWebPage::infiniteLoopJS()
void tst_QWebPage::loadFinished()
{
+ qRegisterMetaType<QWebFrame*>("QWebFrame*");
+ qRegisterMetaType<QNetworkRequest*>("QNetworkRequest*");
QSignalSpy spyLoadStarted(m_view, SIGNAL(loadStarted()));
QSignalSpy spyLoadFinished(m_view, SIGNAL(loadFinished(bool)));
@@ -332,9 +370,11 @@ public:
TestNetworkManager(QObject* parent) : QNetworkAccessManager(parent) {}
QList<QUrl> requestedUrls;
+ QList<QNetworkRequest> requests;
protected:
virtual QNetworkReply* createRequest(Operation op, const QNetworkRequest &request, QIODevice* outgoingData) {
+ requests.append(request);
requestedUrls.append(request.url());
return QNetworkAccessManager::createRequest(op, request, outgoingData);
}
@@ -436,7 +476,6 @@ void tst_QWebPage::database()
QVERIFY(QWebSettings::offlineStorageDefaultQuota() == 1024 * 1024);
m_page->settings()->setAttribute(QWebSettings::LocalStorageEnabled, true);
- m_page->settings()->setAttribute(QWebSettings::SessionStorageEnabled, true);
m_page->settings()->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true);
QString dbFileName = path + "Databases.db";
@@ -617,50 +656,116 @@ void tst_QWebPage::createPlugin()
QCOMPARE(newPage->calls.count(), 0);
}
-class PluginTrackedPage : public QWebPage
-{
+
+// Standard base class for template PluginTracerPage. In tests it is used as interface.
+class PluginCounterPage : public QWebPage {
public:
+ int m_count;
+ QPointer<QObject> m_widget;
+ QObject* m_pluginParent;
+ PluginCounterPage(QObject* parent = 0)
+ : QWebPage(parent)
+ , m_count(0)
+ , m_widget(0)
+ , m_pluginParent(0)
+ {
+ settings()->setAttribute(QWebSettings::PluginsEnabled, true);
+ }
+ ~PluginCounterPage()
+ {
+ if (m_pluginParent)
+ m_pluginParent->deleteLater();
+ }
+};
- int count;
- QPointer<QWidget> widget;
+template<class T>
+class PluginTracerPage : public PluginCounterPage {
+public:
+ PluginTracerPage(QObject* parent = 0)
+ : PluginCounterPage(parent)
+ {
+ // this is a dummy parent object for the created plugin
+ m_pluginParent = new T;
+ }
+ virtual QObject* createPlugin(const QString&, const QUrl&, const QStringList&, const QStringList&)
+ {
+ m_count++;
+ m_widget = new T;
+ // need a cast to the specific type, as QObject::setParent cannot be called,
+ // because it is not virtual. Instead it is necesary to call QWidget::setParent,
+ // which also takes a QWidget* instead of a QObject*. Therefore we need to
+ // upcast to T*, which is a QWidget.
+ static_cast<T*>(m_widget.data())->setParent(static_cast<T*>(m_pluginParent));
+ return m_widget;
+ }
+};
- PluginTrackedPage(QWidget *parent = 0) : QWebPage(parent), count(0) {
- settings()->setAttribute(QWebSettings::PluginsEnabled, true);
+class PluginFactory {
+public:
+ enum FactoredType {QWidgetType, QGraphicsWidgetType};
+ static PluginCounterPage* create(FactoredType type, QObject* parent = 0)
+ {
+ PluginCounterPage* result = 0;
+ switch (type) {
+ case QWidgetType:
+ result = new PluginTracerPage<QWidget>(parent);
+ break;
+ case QGraphicsWidgetType:
+ result = new PluginTracerPage<QGraphicsWidget>(parent);
+ break;
+ default: {/*Oops*/};
+ }
+ return result;
}
- virtual QObject* createPlugin(const QString&, const QUrl&, const QStringList&, const QStringList&) {
- count++;
- QWidget *w = new QWidget;
- widget = w;
- return w;
+ static void prepareTestData()
+ {
+ QTest::addColumn<int>("type");
+ QTest::newRow("QWidget") << (int)PluginFactory::QWidgetType;
+ QTest::newRow("QGraphicsWidget") << (int)PluginFactory::QGraphicsWidgetType;
}
};
+void tst_QWebPage::destroyPlugin_data()
+{
+ PluginFactory::prepareTestData();
+}
+
void tst_QWebPage::destroyPlugin()
{
- PluginTrackedPage* page = new PluginTrackedPage(m_view);
+ QFETCH(int, type);
+ PluginCounterPage* page = PluginFactory::create((PluginFactory::FactoredType)type, m_view);
m_view->setPage(page);
// we create the plugin, so the widget should be constructed
QString content("<html><body><object type=\"application/x-qt-plugin\" classid=\"QProgressBar\"></object></body></html>");
m_view->setHtml(content);
- QVERIFY(page->widget != 0);
- QCOMPARE(page->count, 1);
+ QVERIFY(page->m_widget);
+ QCOMPARE(page->m_count, 1);
// navigate away, the plugin widget should be destructed
m_view->setHtml("<html><body>Hi</body></html>");
QTestEventLoop::instance().enterLoop(1);
- QVERIFY(page->widget == 0);
+ QVERIFY(!page->m_widget);
+}
+
+void tst_QWebPage::createViewlessPlugin_data()
+{
+ PluginFactory::prepareTestData();
}
void tst_QWebPage::createViewlessPlugin()
{
- PluginTrackedPage* page = new PluginTrackedPage;
+ QFETCH(int, type);
+ PluginCounterPage* page = PluginFactory::create((PluginFactory::FactoredType)type);
QString content("<html><body><object type=\"application/x-qt-plugin\" classid=\"QProgressBar\"></object></body></html>");
page->mainFrame()->setHtml(content);
- QCOMPARE(page->count, 1);
- QVERIFY(page->widget != 0);
+ QCOMPARE(page->m_count, 1);
+ QVERIFY(page->m_widget);
+ QVERIFY(page->m_pluginParent);
+ QVERIFY(page->m_widget->parent() == page->m_pluginParent);
delete page;
+
}
// import private API
@@ -1205,75 +1310,148 @@ void tst_QWebPage::frameAt()
frameAtHelper(webPage, webPage->mainFrame(), webPage->mainFrame()->pos());
}
+void tst_QWebPage::inputMethods_data()
+{
+ QTest::addColumn<QString>("viewType");
+ QTest::newRow("QWebView") << "QWebView";
+#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
+ QTest::newRow("QGraphicsWebView") << "QGraphicsWebView";
+#endif
+}
+
+#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
+static Qt::InputMethodHints inputMethodHints(QObject* object)
+{
+ if (QGraphicsObject* o = qobject_cast<QGraphicsObject*>(object))
+ return o->inputMethodHints();
+ if (QWidget* w = qobject_cast<QWidget*>(object))
+ return w->inputMethodHints();
+ return Qt::InputMethodHints();
+}
+#endif
+
+static bool inputMethodEnabled(QObject* object)
+{
+#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
+ if (QGraphicsObject* o = qobject_cast<QGraphicsObject*>(object))
+ return o->flags() & QGraphicsItem::ItemAcceptsInputMethod;
+#endif
+ if (QWidget* w = qobject_cast<QWidget*>(object))
+ return w->testAttribute(Qt::WA_InputMethodEnabled);
+ return false;
+}
+
void tst_QWebPage::inputMethods()
{
- m_view->page()->mainFrame()->setHtml("<html><body>" \
+ QFETCH(QString, viewType);
+ QWebPage* page = new QWebPage;
+ QObject* view = 0;
+ QObject* container = 0;
+ if (viewType == "QWebView") {
+ QWebView* wv = new QWebView;
+ wv->setPage(page);
+ view = wv;
+ container = view;
+ }
+#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
+ else if (viewType == "QGraphicsWebView") {
+ QGraphicsWebView* wv = new QGraphicsWebView;
+ wv->setPage(page);
+ view = wv;
+
+ QGraphicsView* gv = new QGraphicsView;
+ QGraphicsScene* scene = new QGraphicsScene(gv);
+ gv->setScene(scene);
+ scene->addItem(wv);
+ wv->setGeometry(QRect(0, 0, 500, 500));
+
+ container = gv;
+ }
+#endif
+ else
+ QVERIFY2(false, "Unknown view type");
+
+ page->mainFrame()->setHtml("<html><body>" \
"<input type='text' id='input1' style='font-family: serif' value='' maxlength='20'/><br>" \
"<input type='password'/>" \
"</body></html>");
- m_view->page()->mainFrame()->setFocus();
+ page->mainFrame()->setFocus();
+
+ EventSpy viewEventSpy(container);
- QList<QWebElement> inputs = m_view->page()->mainFrame()->documentElement().findAll("input");
+ QWebElementCollection inputs = page->mainFrame()->documentElement().findAll("input");
QMouseEvent evpres(QEvent::MouseButtonPress, inputs.at(0).geometry().center(), Qt::LeftButton, Qt::NoButton, Qt::NoModifier);
- m_view->page()->event(&evpres);
+ page->event(&evpres);
QMouseEvent evrel(QEvent::MouseButtonRelease, inputs.at(0).geometry().center(), Qt::LeftButton, Qt::NoButton, Qt::NoModifier);
- m_view->page()->event(&evrel);
+ page->event(&evrel);
+
+#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
+ QVERIFY(!viewEventSpy.contains(QEvent::RequestSoftwareInputPanel));
+#endif
+ viewEventSpy.clear();
+
+ page->event(&evpres);
+ page->event(&evrel);
+
+#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
+ QVERIFY(viewEventSpy.contains(QEvent::RequestSoftwareInputPanel));
+#endif
//ImMicroFocus
- QVariant variant = m_view->page()->inputMethodQuery(Qt::ImMicroFocus);
+ QVariant variant = page->inputMethodQuery(Qt::ImMicroFocus);
QRect focusRect = variant.toRect();
QVERIFY(inputs.at(0).geometry().contains(variant.toRect().topLeft()));
//ImFont
- variant = m_view->page()->inputMethodQuery(Qt::ImFont);
- QFont font = variant.value<QFont>();
- QCOMPARE(QString("-webkit-serif"), font.family());
+ //variant = page->inputMethodQuery(Qt::ImFont);
+ //QFont font = variant.value<QFont>();
+ //QCOMPARE(QString("-webkit-serif"), font.family());
QList<QInputMethodEvent::Attribute> inputAttributes;
//Insert text.
{
QInputMethodEvent eventText("QtWebKit", inputAttributes);
- QSignalSpy signalSpy(m_view->page(), SIGNAL(microFocusChanged()));
- m_view->page()->event(&eventText);
+ QSignalSpy signalSpy(page, SIGNAL(microFocusChanged()));
+ page->event(&eventText);
QCOMPARE(signalSpy.count(), 0);
}
{
QInputMethodEvent eventText("", inputAttributes);
eventText.setCommitString(QString("QtWebKit"), 0, 0);
- m_view->page()->event(&eventText);
+ page->event(&eventText);
}
#if QT_VERSION >= 0x040600
//ImMaximumTextLength
- variant = m_view->page()->inputMethodQuery(Qt::ImMaximumTextLength);
+ variant = page->inputMethodQuery(Qt::ImMaximumTextLength);
QCOMPARE(20, variant.toInt());
//Set selection
inputAttributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 3, 2, QVariant());
QInputMethodEvent eventSelection("",inputAttributes);
- m_view->page()->event(&eventSelection);
+ page->event(&eventSelection);
//ImAnchorPosition
- variant = m_view->page()->inputMethodQuery(Qt::ImAnchorPosition);
+ variant = page->inputMethodQuery(Qt::ImAnchorPosition);
int anchorPosition = variant.toInt();
QCOMPARE(anchorPosition, 3);
//ImCursorPosition
- variant = m_view->page()->inputMethodQuery(Qt::ImCursorPosition);
+ variant = page->inputMethodQuery(Qt::ImCursorPosition);
int cursorPosition = variant.toInt();
QCOMPARE(cursorPosition, 5);
//ImCurrentSelection
- variant = m_view->page()->inputMethodQuery(Qt::ImCurrentSelection);
+ variant = page->inputMethodQuery(Qt::ImCurrentSelection);
QString selectionValue = variant.value<QString>();
QCOMPARE(selectionValue, QString("eb"));
#endif
//ImSurroundingText
- variant = m_view->page()->inputMethodQuery(Qt::ImSurroundingText);
+ variant = page->inputMethodQuery(Qt::ImSurroundingText);
QString value = variant.value<QString>();
QCOMPARE(value, QString("QtWebKit"));
@@ -1284,29 +1462,31 @@ void tst_QWebPage::inputMethods()
QInputMethodEvent::Attribute newSelection(QInputMethodEvent::Selection, 0, 0, QVariant());
attributes.append(newSelection);
QInputMethodEvent event("composition", attributes);
- m_view->page()->event(&event);
+ page->event(&event);
}
// A ongoing composition should not change the surrounding text before it is committed.
- variant = m_view->page()->inputMethodQuery(Qt::ImSurroundingText);
+ variant = page->inputMethodQuery(Qt::ImSurroundingText);
value = variant.value<QString>();
QCOMPARE(value, QString("QtWebKit"));
#endif
//ImhHiddenText
QMouseEvent evpresPassword(QEvent::MouseButtonPress, inputs.at(1).geometry().center(), Qt::LeftButton, Qt::NoButton, Qt::NoModifier);
- m_view->page()->event(&evpresPassword);
+ page->event(&evpresPassword);
QMouseEvent evrelPassword(QEvent::MouseButtonRelease, inputs.at(1).geometry().center(), Qt::LeftButton, Qt::NoButton, Qt::NoModifier);
- m_view->page()->event(&evrelPassword);
+ page->event(&evrelPassword);
- QVERIFY(m_view->testAttribute(Qt::WA_InputMethodEnabled));
+ QVERIFY(inputMethodEnabled(view));
#if QT_VERSION >= 0x040600
- QVERIFY(m_view->inputMethodHints() & Qt::ImhHiddenText);
+ QVERIFY(inputMethodHints(view) & Qt::ImhHiddenText);
- m_view->page()->event(&evpres);
- m_view->page()->event(&evrel);
- QVERIFY(!(m_view->inputMethodHints() & Qt::ImhHiddenText));
+ page->event(&evpres);
+ page->event(&evrel);
+ QVERIFY(!(inputMethodHints(view) & Qt::ImhHiddenText));
#endif
+
+ delete container;
}
// import a little DRT helper function to trigger the garbage collector
@@ -1370,8 +1550,10 @@ void tst_QWebPage::testOptionalJSObjects()
webPage1.currentFrame()->setHtml(QString("<html><body>test</body></html>"), QUrl());
webPage2.currentFrame()->setHtml(QString("<html><body>test</body></html>"), QUrl());
+ QEXPECT_FAIL("","Feature enabled/disabled checking problem. Look at bugs.webkit.org/show_bug.cgi?id=29867", Continue);
QCOMPARE(testFlag(webPage1, QWebSettings::OfflineWebApplicationCacheEnabled, "applicationCache", false), false);
QCOMPARE(testFlag(webPage2, QWebSettings::OfflineWebApplicationCacheEnabled, "applicationCache", true), true);
+ QEXPECT_FAIL("","Feature enabled/disabled checking problem. Look at bugs.webkit.org/show_bug.cgi?id=29867", Continue);
QCOMPARE(testFlag(webPage1, QWebSettings::OfflineWebApplicationCacheEnabled, "applicationCache", false), false);
QCOMPARE(testFlag(webPage2, QWebSettings::OfflineWebApplicationCacheEnabled, "applicationCache", false), true);
@@ -1379,11 +1561,6 @@ void tst_QWebPage::testOptionalJSObjects()
QCOMPARE(testFlag(webPage2, QWebSettings::LocalStorageEnabled, "localStorage", true), true);
QCOMPARE(testFlag(webPage1, QWebSettings::LocalStorageEnabled, "localStorage", false), false);
QCOMPARE(testFlag(webPage2, QWebSettings::LocalStorageEnabled, "localStorage", false), true);
-
- QCOMPARE(testFlag(webPage1, QWebSettings::SessionStorageEnabled, "sessionStorage", false), false);
- QCOMPARE(testFlag(webPage2, QWebSettings::SessionStorageEnabled, "sessionStorage", true), true);
- QCOMPARE(testFlag(webPage1, QWebSettings::SessionStorageEnabled, "sessionStorage", false), false);
- QCOMPARE(testFlag(webPage2, QWebSettings::SessionStorageEnabled, "sessionStorage", false), true);
}
void tst_QWebPage::testEnablePersistentStorage()
@@ -1410,6 +1587,95 @@ void tst_QWebPage::testEnablePersistentStorage()
QVERIFY(!webPage.settings()->iconDatabasePath().isEmpty());
}
+void tst_QWebPage::defaultTextEncoding()
+{
+ QWebFrame* mainFrame = m_page->mainFrame();
+
+ QString defaultCharset = mainFrame->evaluateJavaScript("document.defaultCharset").toString();
+ QVERIFY(!defaultCharset.isEmpty());
+ QCOMPARE(QWebSettings::globalSettings()->defaultTextEncoding(), defaultCharset);
+
+ m_page->settings()->setDefaultTextEncoding(QString("utf-8"));
+ QString charset = mainFrame->evaluateJavaScript("document.defaultCharset").toString();
+ QCOMPARE(charset, QString("utf-8"));
+ QCOMPARE(m_page->settings()->defaultTextEncoding(), charset);
+
+ m_page->settings()->setDefaultTextEncoding(QString());
+ charset = mainFrame->evaluateJavaScript("document.defaultCharset").toString();
+ QVERIFY(!charset.isEmpty());
+ QCOMPARE(charset, defaultCharset);
+
+ QWebSettings::globalSettings()->setDefaultTextEncoding(QString("utf-8"));
+ charset = mainFrame->evaluateJavaScript("document.defaultCharset").toString();
+ QCOMPARE(charset, QString("utf-8"));
+ QCOMPARE(QWebSettings::globalSettings()->defaultTextEncoding(), charset);
+}
+
+class ErrorPage : public QWebPage
+{
+public:
+
+ ErrorPage(QWidget* parent = 0): QWebPage(parent)
+ {
+ }
+
+ virtual bool supportsExtension(Extension extension) const
+ {
+ return extension == ErrorPageExtension;
+ }
+
+ virtual bool extension(Extension, const ExtensionOption* option, ExtensionReturn* output)
+ {
+ const ErrorPageExtensionOption* info = static_cast<const ErrorPageExtensionOption*>(option);
+ ErrorPageExtensionReturn* errorPage = static_cast<ErrorPageExtensionReturn*>(output);
+
+ if (info->frame == mainFrame()) {
+ errorPage->content = "data:text/html,error";
+ return true;
+ }
+
+ return false;
+ }
+};
+
+void tst_QWebPage::errorPageExtension()
+{
+ ErrorPage* page = new ErrorPage;
+ m_view->setPage(page);
+
+ QSignalSpy spyLoadFinished(m_view, SIGNAL(loadFinished(bool)));
+
+ page->mainFrame()->load(QUrl("qrc:///frametest/index.html"));
+ QTRY_COMPARE(spyLoadFinished.count(), 1);
+
+ page->mainFrame()->setUrl(QUrl("http://non.existent/url"));
+ QTest::qWait(2000);
+ QTRY_COMPARE(spyLoadFinished.count(), 2);
+ QCOMPARE(page->mainFrame()->toPlainText(), QString("data:text/html,error"));
+ QCOMPARE(page->history()->count(), 2);
+ QCOMPARE(page->history()->currentItem().url(), QUrl("http://non.existent/url"));
+ QCOMPARE(page->history()->canGoBack(), true);
+ QCOMPARE(page->history()->canGoForward(), false);
+
+ page->triggerAction(QWebPage::Back);
+ QTest::qWait(2000);
+ QCOMPARE(page->history()->canGoBack(), false);
+ QCOMPARE(page->history()->canGoForward(), true);
+
+ page->triggerAction(QWebPage::Forward);
+ QTest::qWait(2000);
+ QCOMPARE(page->history()->canGoBack(), true);
+ QCOMPARE(page->history()->canGoForward(), false);
+
+ page->triggerAction(QWebPage::Back);
+ QTest::qWait(2000);
+ QCOMPARE(page->history()->canGoBack(), false);
+ QCOMPARE(page->history()->canGoForward(), true);
+ QCOMPARE(page->history()->currentItem().url(), QUrl("qrc:///frametest/index.html"));
+
+ m_view->setPage(0);
+}
+
void tst_QWebPage::crashTests_LazyInitializationOfMainFrame()
{
{
@@ -1430,6 +1696,74 @@ void tst_QWebPage::crashTests_LazyInitializationOfMainFrame()
}
}
+static void takeScreenshot(QWebPage* page)
+{
+ QWebFrame* mainFrame = page->mainFrame();
+ page->setViewportSize(mainFrame->contentsSize());
+ QImage image(page->viewportSize(), QImage::Format_ARGB32);
+ QPainter painter(&image);
+ mainFrame->render(&painter);
+ painter.end();
+}
+
+void tst_QWebPage::screenshot_data()
+{
+ QTest::addColumn<QString>("html");
+ QTest::newRow("WithoutPlugin") << "<html><body id='b'>text</body></html>";
+ QTest::newRow("WindowedPlugin") << QString("<html><body id='b'>text<embed src='resources/test.swf'></embed></body></html>");
+ QTest::newRow("WindowlessPlugin") << QString("<html><body id='b'>text<embed src='resources/test.swf' wmode='transparent'></embed></body></html>");
+}
+
+void tst_QWebPage::screenshot()
+{
+ QDir::setCurrent(SRCDIR);
+
+ QFETCH(QString, html);
+ QWebPage* page = new QWebPage;
+ page->settings()->setAttribute(QWebSettings::PluginsEnabled, true);
+ QWebFrame* mainFrame = page->mainFrame();
+ mainFrame->setHtml(html, QUrl::fromLocalFile(QDir::currentPath()));
+ if (html.contains("</embed>")) {
+ // some reasonable time for the PluginStream to feed test.swf to flash and start painting
+ QTest::qWait(2000);
+ }
+
+ // take screenshot without a view
+ takeScreenshot(page);
+
+ QWebView* view = new QWebView;
+ view->setPage(page);
+
+ // take screenshot when attached to a view
+ takeScreenshot(page);
+
+ delete page;
+ delete view;
+
+ QDir::setCurrent(QApplication::applicationDirPath());
+}
+
+void tst_QWebPage::originatingObjectInNetworkRequests()
+{
+ TestNetworkManager* networkManager = new TestNetworkManager(m_page);
+ m_page->setNetworkAccessManager(networkManager);
+ networkManager->requests.clear();
+
+ m_view->setHtml(QString("data:text/html,<frameset cols=\"25%,75%\"><frame src=\"data:text/html,"
+ "<head><meta http-equiv='refresh' content='1'></head>foo \">"
+ "<frame src=\"data:text/html,bar\"></frameset>"), QUrl());
+ QVERIFY(::waitForSignal(m_view, SIGNAL(loadFinished(bool))));
+
+ QCOMPARE(networkManager->requests.count(), 2);
+
+ QList<QWebFrame*> childFrames = m_page->mainFrame()->childFrames();
+ QCOMPARE(childFrames.count(), 2);
+
+#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
+ for (int i = 0; i < 2; ++i)
+ QVERIFY(qobject_cast<QWebFrame*>(networkManager->requests.at(i).originatingObject()) == childFrames.at(i));
+#endif
+}
QTEST_MAIN(tst_QWebPage)
#include "tst_qwebpage.moc"
diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebplugindatabase/qwebplugindatabase.pro b/src/3rdparty/webkit/WebKit/qt/tests/qwebplugindatabase/qwebplugindatabase.pro
index 1376ca5879..569146abdc 100644
--- a/src/3rdparty/webkit/WebKit/qt/tests/qwebplugindatabase/qwebplugindatabase.pro
+++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebplugindatabase/qwebplugindatabase.pro
@@ -5,4 +5,7 @@ SOURCES += tst_qwebplugindatabase.cpp
QT += testlib network
QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR
-symbian:TARGET.UID3 = 0xA000E540
+symbian {
+ TARGET.UID3 = 0xA000E540
+ TARGET.CAPABILITY = ReadUserData WriteUserData NetworkServices
+}
diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebview/data/frame_a.html b/src/3rdparty/webkit/WebKit/qt/tests/qwebview/data/frame_a.html
new file mode 100644
index 0000000000..9ff68f13a4
--- /dev/null
+++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebview/data/frame_a.html
@@ -0,0 +1,2 @@
+<a href="http://google.com" target="frame_b"><img src="" width=100 height=100 alt="Google"></a>
+<a href="http://yahoo.com" target="frame_b"><img src="" width=100 height=100 alt="Yahoo"></a>
diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebview/data/index.html b/src/3rdparty/webkit/WebKit/qt/tests/qwebview/data/index.html
new file mode 100644
index 0000000000..c53ad09a7a
--- /dev/null
+++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebview/data/index.html
@@ -0,0 +1,4 @@
+<frameset cols="25%,75%">
+ <frame src="frame_a.html" name="frame_a">
+ <frame src="frame_b.html" name="frame_b">
+</frameset>
diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebview/qwebview.pro b/src/3rdparty/webkit/WebKit/qt/tests/qwebview/qwebview.pro
index d9d122c8b1..735537ba2c 100644
--- a/src/3rdparty/webkit/WebKit/qt/tests/qwebview/qwebview.pro
+++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebview/qwebview.pro
@@ -4,5 +4,10 @@ include(../../../../WebKit.pri)
SOURCES += tst_qwebview.cpp
QT += testlib network
QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR
+RESOURCES += tst_qwebview.qrc
+DEFINES += SRCDIR=\\\"$$PWD/\\\"
-symbian:TARGET.UID3 = 0xA000E53F
+symbian {
+ TARGET.UID3 = 0xA000E53F
+ TARGET.CAPABILITY = ReadUserData WriteUserData NetworkServices
+}
diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebview/tst_qwebview.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebview/tst_qwebview.cpp
index 01d0e9295e..27daf38417 100644
--- a/src/3rdparty/webkit/WebKit/qt/tests/qwebview/tst_qwebview.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebview/tst_qwebview.cpp
@@ -1,6 +1,7 @@
/*
Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
Copyright (C) 2009 Torch Mobile Inc.
+ Copyright (C) 2009 Girish Ramakrishnan <girish@forwardbias.in>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -19,6 +20,7 @@
*/
#include <qtest.h>
+#include "../util.h"
#include <qpainter.h>
#include <qwebview.h>
@@ -26,6 +28,7 @@
#include <qnetworkrequest.h>
#include <qdiriterator.h>
#include <qwebkitversion.h>
+#include <qwebframe.h>
class tst_QWebView : public QObject
{
@@ -39,9 +42,12 @@ public slots:
private slots:
void renderHints();
- void guessUrlFromString_data();
- void guessUrlFromString();
void getWebKitVersion();
+
+ void reusePage_data();
+ void reusePage();
+
+ void crashTests();
};
// This will be called before the first test function is executed.
@@ -100,73 +106,91 @@ void tst_QWebView::renderHints()
QVERIFY(!(webView.renderHints() & QPainter::HighQualityAntialiasing));
}
-void tst_QWebView::guessUrlFromString_data()
+void tst_QWebView::getWebKitVersion()
{
- QTest::addColumn<QString>("string");
- QTest::addColumn<QUrl>("guessUrlFromString");
-
- // Null
- QTest::newRow("null") << QString() << QUrl();
-
- // File
- QDirIterator it(QDir::homePath());
- QString fileString;
- int c = 0;
- while (it.hasNext()) {
- it.next();
- QTest::newRow(QString("file-%1").arg(c++).toLatin1()) << it.filePath() << QUrl::fromLocalFile(it.filePath());
- }
+ QVERIFY(qWebKitVersion().toDouble() > 0);
+}
- // basic latin1
- QTest::newRow("unicode-0") << QString::fromUtf8("å.com/") << QUrl::fromEncoded(QString::fromUtf8("http://å.com/").toUtf8(), QUrl::TolerantMode);
- // unicode
- QTest::newRow("unicode-1") << QString::fromUtf8("λ.com/") << QUrl::fromEncoded(QString::fromUtf8("http://λ.com/").toUtf8(), QUrl::TolerantMode);
-
- // no scheme
- QTest::newRow("add scheme-0") << "webkit.org" << QUrl("http://webkit.org");
- QTest::newRow("add scheme-1") << "www.webkit.org" << QUrl("http://www.webkit.org");
- QTest::newRow("add scheme-2") << "ftp.webkit.org" << QUrl("ftp://ftp.webkit.org");
- QTest::newRow("add scheme-3") << "webkit" << QUrl("webkit");
-
- // QUrl's tolerant parser should already handle this
- QTest::newRow("not-encoded-0") << "http://webkit.org/test page.html" << QUrl("http://webkit.org/test%20page.html");
-
- // Make sure the :80, i.e. port doesn't screw anything up
- QUrl portUrl("http://webkit.org");
- portUrl.setPort(80);
- QTest::newRow("port-0") << "webkit.org:80" << portUrl;
- QTest::newRow("port-1") << "http://webkit.org:80" << portUrl;
-
- // mailto doesn't have a ://, but is valid
- QUrl mailto("ben@meyerhome.net");
- mailto.setScheme("mailto");
- QTest::newRow("mailto") << "mailto:ben@meyerhome.net" << mailto;
-
- // misc
- QTest::newRow("localhost-0") << "localhost" << QUrl("http://localhost");
- QTest::newRow("localhost-1") << "localhost:80" << QUrl("http://localhost:80");
- QTest::newRow("spaces-0") << " http://webkit.org/test page.html " << QUrl("http://webkit.org/test%20page.html");
-
- // FYI: The scheme in the resulting url user
- QUrl authUrl("user:pass@domain.com");
- QTest::newRow("misc-1") << "user:pass@domain.com" << authUrl;
+void tst_QWebView::reusePage_data()
+{
+ QTest::addColumn<QString>("html");
+ QTest::newRow("WithoutPlugin") << "<html><body id='b'>text</body></html>";
+ QTest::newRow("WindowedPlugin") << QString("<html><body id='b'>text<embed src='resources/test.swf'></embed></body></html>");
+ QTest::newRow("WindowlessPlugin") << QString("<html><body id='b'>text<embed src='resources/test.swf' wmode=\"transparent\"></embed></body></html>");
}
-// public static QUrl guessUrlFromString(QString const& string)
-void tst_QWebView::guessUrlFromString()
+void tst_QWebView::reusePage()
{
- QFETCH(QString, string);
- QFETCH(QUrl, guessUrlFromString);
+ QDir::setCurrent(SRCDIR);
+
+ QFETCH(QString, html);
+ QWebView* view1 = new QWebView;
+ QPointer<QWebPage> page = new QWebPage;
+ view1->setPage(page);
+ page->settings()->setAttribute(QWebSettings::PluginsEnabled, true);
+ QWebFrame* mainFrame = page->mainFrame();
+ mainFrame->setHtml(html, QUrl::fromLocalFile(QDir::currentPath()));
+ if (html.contains("</embed>")) {
+ // some reasonable time for the PluginStream to feed test.swf to flash and start painting
+ QTest::qWait(2000);
+ }
+
+ view1->show();
+ QTest::qWait(2000);
+ delete view1;
+ QVERIFY(page != 0); // deleting view must not have deleted the page, since it's not a child of view
- QUrl url = QWebView::guessUrlFromString(string);
- QCOMPARE(url, guessUrlFromString);
+ QWebView *view2 = new QWebView;
+ view2->setPage(page);
+ view2->show(); // in Windowless mode, you should still be able to see the plugin here
+ QTest::qWait(2000);
+ delete view2;
+
+ delete page; // must not crash
+
+ QDir::setCurrent(QApplication::applicationDirPath());
}
-void tst_QWebView::getWebKitVersion()
+// Class used in crashTests
+class WebViewCrashTest : public QObject {
+ Q_OBJECT
+ QWebView* m_view;
+public:
+ bool m_executed;
+
+
+ WebViewCrashTest(QWebView* view)
+ : m_view(view)
+ , m_executed(false)
+ {
+ view->connect(view, SIGNAL(loadProgress(int)), this, SLOT(loading(int)));
+ }
+
+private slots:
+ void loading(int progress)
+ {
+ if (progress >= 20 && progress < 90) {
+ QVERIFY(!m_executed);
+ m_view->stop();
+ m_executed = true;
+ }
+ }
+};
+
+
+// Should not crash.
+void tst_QWebView::crashTests()
{
- QVERIFY(qWebKitVersion().toDouble() > 0);
+ // Test if loading can be stopped in loadProgress handler without crash.
+ // Test page should have frames.
+ QWebView view;
+ WebViewCrashTest tester(&view);
+ QUrl url("qrc:///data/index.html");
+ view.load(url);
+ QTRY_VERIFY(tester.m_executed); // If fail it means that the test wasn't executed.
}
+
QTEST_MAIN(tst_QWebView)
#include "tst_qwebview.moc"
diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebview/tst_qwebview.qrc b/src/3rdparty/webkit/WebKit/qt/tests/qwebview/tst_qwebview.qrc
new file mode 100644
index 0000000000..ede34a9831
--- /dev/null
+++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebview/tst_qwebview.qrc
@@ -0,0 +1,7 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>data/index.html</file>
+ <file>data/frame_a.html</file>
+</qresource>
+</RCC>
+
diff --git a/src/3rdparty/webkit/WebKit/qt/tests/resources/test.swf b/src/3rdparty/webkit/WebKit/qt/tests/resources/test.swf
new file mode 100644
index 0000000000..895298271a
--- /dev/null
+++ b/src/3rdparty/webkit/WebKit/qt/tests/resources/test.swf
Binary files differ
diff --git a/src/3rdparty/webkit/WebKit/qt/tests/tests.pro b/src/3rdparty/webkit/WebKit/qt/tests/tests.pro
index 81cc8f347b..939cd224ab 100644
--- a/src/3rdparty/webkit/WebKit/qt/tests/tests.pro
+++ b/src/3rdparty/webkit/WebKit/qt/tests/tests.pro
@@ -1,4 +1,4 @@
TEMPLATE = subdirs
-SUBDIRS = qwebframe qwebpage qwebelement qgraphicswebview qwebhistoryinterface qwebplugindatabase qwebview qwebhistory
+SUBDIRS = qwebframe qwebpage qwebelement qgraphicswebview qwebhistoryinterface qwebview qwebhistory
greaterThan(QT_MINOR_VERSION, 4): SUBDIRS += benchmarks/painting/tst_painting.pro benchmarks/loading/tst_loading.pro