summaryrefslogtreecommitdiffstats
path: root/Source/WebKit/qt/tests
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit/qt/tests')
-rw-r--r--Source/WebKit/qt/tests/CMakeLists.txt2
-rw-r--r--Source/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp1
-rw-r--r--Source/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp6
-rw-r--r--Source/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp62
-rw-r--r--Source/WebKit/qt/tests/qwebhistory/tst_qwebhistory.cpp8
-rw-r--r--Source/WebKit/qt/tests/qwebhistoryinterface/tst_qwebhistoryinterface.cpp7
-rw-r--r--Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp75
-rw-r--r--Source/WebKit/qt/tests/qwebsecurityorigin/tst_qwebsecurityorigin.cpp4
8 files changed, 76 insertions, 89 deletions
diff --git a/Source/WebKit/qt/tests/CMakeLists.txt b/Source/WebKit/qt/tests/CMakeLists.txt
index 3dc6af1d5..42d636573 100644
--- a/Source/WebKit/qt/tests/CMakeLists.txt
+++ b/Source/WebKit/qt/tests/CMakeLists.txt
@@ -14,6 +14,8 @@ include_directories(SYSTEM
${Qt5Test_INCLUDE_DIRS}
)
+add_definitions(-DTESTS_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}/")
+
if (ENABLE_TEST_SUPPORT)
add_definitions(-DHAVE_QTTESTSUPPORT)
endif ()
diff --git a/Source/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp b/Source/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp
index 0fd5d0a85..8417d0ef7 100644
--- a/Source/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp
+++ b/Source/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp
@@ -190,6 +190,7 @@ void tst_QGraphicsWebView::widgetsRenderingThroughCache()
// 1. Reference without tiling.
webView->settings()->setAttribute(QWebSettings::TiledBackingStoreEnabled, false);
QPixmap referencePixmap(view.size());
+ QApplication::processEvents();
widget->render(&referencePixmap);
// 2. With tiling.
diff --git a/Source/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp b/Source/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp
index 32935e6a2..4ca5fe5f9 100644
--- a/Source/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp
+++ b/Source/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp
@@ -74,9 +74,9 @@ private Q_SLOTS:
void addElementToHead();
private:
- QWebView* m_view;
- QWebPage* m_page;
- QWebFrame* m_mainFrame;
+ QWebView* m_view { nullptr };
+ QWebPage* m_page { nullptr };
+ QWebFrame* m_mainFrame { nullptr };
};
tst_QWebElement::tst_QWebElement()
diff --git a/Source/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp b/Source/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
index 17bc703fc..2068eec3f 100644
--- a/Source/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
+++ b/Source/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
@@ -94,14 +94,15 @@ private Q_SLOTS:
void setUrlThenLoads_data();
void setUrlThenLoads();
void loadFinishedAfterNotFoundError();
+ void signalsDuringErrorHandling();
void loadInSignalHandlers_data();
void loadInSignalHandlers();
private:
- QWebView* m_view;
- QWebPage* m_page;
- QWebView* m_inputFieldsTestView;
- int m_inputFieldTestPaintCount;
+ QWebView* m_view { nullptr };
+ QWebPage* m_page { nullptr };
+ QWebView* m_inputFieldsTestView { nullptr };
+ int m_inputFieldTestPaintCount { 0 };
};
bool tst_QWebFrame::eventFilter(QObject* watched, QEvent* event)
@@ -169,12 +170,7 @@ void tst_QWebFrame::progressSignal()
::waitForSignal(m_view, SIGNAL(loadFinished(bool)));
- QVERIFY(progressSpy.size() >= 2);
-
- // WebKit defines initialProgressValue as 10%, not 0%
- QCOMPARE(progressSpy.first().first().toInt(), 10);
-
- // But we always end at 100%
+ QVERIFY(progressSpy.size() >= 1);
QCOMPARE(progressSpy.last().first().toInt(), 100);
}
@@ -345,11 +341,21 @@ void tst_QWebFrame::requestedUrlAfterSetAndLoadFailures()
const QUrl second("http://abcdef.abcdef/another_page.html");
QVERIFY(first != second);
+ page.settings()->setAttribute(QWebSettings::ErrorPageEnabled, false);
+
frame->load(second);
::waitForSignal(frame, SIGNAL(loadFinished(bool)));
QCOMPARE(frame->url(), first);
QCOMPARE(frame->requestedUrl(), second);
QVERIFY(!spy.at(1).first().toBool());
+
+ page.settings()->setAttribute(QWebSettings::ErrorPageEnabled, true);
+
+ frame->load(second);
+ ::waitForSignal(frame, SIGNAL(loadFinished(bool)));
+ QCOMPARE(frame->url(), second);
+ QCOMPARE(frame->requestedUrl(), second);
+ QVERIFY(!spy.at(2).first().toBool());
}
void tst_QWebFrame::javaScriptWindowObjectCleared_data()
@@ -467,7 +473,7 @@ void tst_QWebFrame::setHtmlWithBaseURL()
QDir::setCurrent(TESTS_SOURCE_DIR);
- QString html("<html><body><p>hello world</p><img src='resources/image2.png'/></body></html>");
+ QString html("<html><body><p>hello world</p><img src='qwebframe/resources/image.png'/></body></html>");
QWebPage page;
QWebFrame* frame = page.mainFrame();
@@ -1272,7 +1278,7 @@ void tst_QWebFrame::setUrlHistory()
QCOMPARE(spy.count(), expectedLoadFinishedCount);
QCOMPARE(frame->url(), url);
QCOMPARE(frame->requestedUrl(), url);
- QCOMPARE(m_page->history()->count(), 0);
+ QCOMPARE(m_page->history()->count(), 1);
url = QUrl("qrc:/test1.html");
frame->setUrl(url);
@@ -1281,14 +1287,14 @@ void tst_QWebFrame::setUrlHistory()
QCOMPARE(spy.count(), expectedLoadFinishedCount);
QCOMPARE(frame->url(), url);
QCOMPARE(frame->requestedUrl(), url);
- QCOMPARE(m_page->history()->count(), 1);
+ QCOMPARE(m_page->history()->count(), 2);
frame->setUrl(QUrl());
expectedLoadFinishedCount++;
QCOMPARE(spy.count(), expectedLoadFinishedCount);
QCOMPARE(frame->url(), aboutBlank);
QCOMPARE(frame->requestedUrl(), QUrl());
- QCOMPARE(m_page->history()->count(), 1);
+ QCOMPARE(m_page->history()->count(), 2);
// Loading same page as current in history, so history count doesn't change.
url = QUrl("qrc:/test1.html");
@@ -1298,7 +1304,7 @@ void tst_QWebFrame::setUrlHistory()
QCOMPARE(spy.count(), expectedLoadFinishedCount);
QCOMPARE(frame->url(), url);
QCOMPARE(frame->requestedUrl(), url);
- QCOMPARE(m_page->history()->count(), 1);
+ QCOMPARE(m_page->history()->count(), 2);
url = QUrl("qrc:/test2.html");
frame->setUrl(url);
@@ -1307,7 +1313,7 @@ void tst_QWebFrame::setUrlHistory()
QCOMPARE(spy.count(), expectedLoadFinishedCount);
QCOMPARE(frame->url(), url);
QCOMPARE(frame->requestedUrl(), url);
- QCOMPARE(m_page->history()->count(), 2);
+ QCOMPARE(m_page->history()->count(), 3);
}
void tst_QWebFrame::setUrlUsingStateObject()
@@ -1472,6 +1478,30 @@ void tst_QWebFrame::loadFinishedAfterNotFoundError()
QVERIFY(!wasLoadOk);
}
+void tst_QWebFrame::signalsDuringErrorHandling()
+{
+ QWebPage page;
+ QWebFrame* frame = page.mainFrame();
+
+ QSignalSpy loadStartedSpy(frame, &QWebFrame::loadStarted);
+ QSignalSpy loadFinishedSpy(frame, &QWebFrame::loadFinished);
+ FakeNetworkManager* networkManager = new FakeNetworkManager(&page);
+ page.setNetworkAccessManager(networkManager);
+
+ frame->setUrl(FakeReply::urlFor404ErrorWithoutContents);
+ QTRY_COMPARE(loadStartedSpy.count(), 1);
+ QTRY_COMPARE(loadFinishedSpy.count(), 1);
+ bool wasLoadOk = loadFinishedSpy.at(0).at(0).toBool();
+ QVERIFY(!wasLoadOk);
+
+ frame->load(QUrl("http://example.com"));
+ waitForSignal(frame, SIGNAL(loadFinished(bool)));
+ QCOMPARE(loadStartedSpy.count(), 2);
+ QCOMPARE(loadFinishedSpy.count(), 2);
+ wasLoadOk = loadFinishedSpy.at(1).at(0).toBool();
+ QVERIFY(wasLoadOk);
+}
+
class URLSetter : public QObject {
Q_OBJECT
diff --git a/Source/WebKit/qt/tests/qwebhistory/tst_qwebhistory.cpp b/Source/WebKit/qt/tests/qwebhistory/tst_qwebhistory.cpp
index 17488ebb9..8df3d26d6 100644
--- a/Source/WebKit/qt/tests/qwebhistory/tst_qwebhistory.cpp
+++ b/Source/WebKit/qt/tests/qwebhistory/tst_qwebhistory.cpp
@@ -70,11 +70,11 @@ private Q_SLOTS:
private:
- QWebPage* page;
- QWebFrame* frame;
- QWebHistory* hist;
+ QWebPage* page { nullptr };
+ QWebFrame* frame { nullptr };
+ QWebHistory* hist { nullptr };
QScopedPointer<SignalBarrier> loadFinishedBarrier;
- int histsize;
+ int histsize {0};
};
tst_QWebHistory::tst_QWebHistory()
diff --git a/Source/WebKit/qt/tests/qwebhistoryinterface/tst_qwebhistoryinterface.cpp b/Source/WebKit/qt/tests/qwebhistoryinterface/tst_qwebhistoryinterface.cpp
index 1612eb7b9..91d1c997f 100644
--- a/Source/WebKit/qt/tests/qwebhistoryinterface/tst_qwebhistoryinterface.cpp
+++ b/Source/WebKit/qt/tests/qwebhistoryinterface/tst_qwebhistoryinterface.cpp
@@ -42,11 +42,8 @@ private Q_SLOTS:
void visitedLinks();
private:
-
-
-private:
- QWebView* m_view;
- QWebPage* m_page;
+ QWebView* m_view { nullptr };
+ QWebPage* m_page { nullptr };
};
tst_QWebHistoryInterface::tst_QWebHistoryInterface()
diff --git a/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp b/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
index e545c5c0f..db4c911e6 100644
--- a/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
+++ b/Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp
@@ -173,7 +173,6 @@ private Q_SLOTS:
void errorPageExtension();
void errorPageExtensionInIFrames();
void errorPageExtensionInFrameset();
- void errorPageExtensionLoadFinished();
void userAgentApplicationName();
void userAgentNewlineStripping();
void undoActionHaveCustomText();
@@ -212,13 +211,13 @@ private Q_SLOTS:
void cssMediaTypeGlobalSetting();
void cssMediaTypePageSetting();
-#ifdef Q_OS_MAC
+#ifdef Q_OS_MACOS
void macCopyUnicodeToClipboard();
#endif
private:
- QWebView* m_view;
- QWebPage* m_page;
+ QWebView* m_view { nullptr };
+ QWebPage* m_page { nullptr };
QString tmpDirPath() const
{
static QString tmpd = QDir::tempPath() + "/tst_qwebpage-"
@@ -379,7 +378,7 @@ public:
}
private:
- bool m_allowGeolocation;
+ bool m_allowGeolocation { false };
};
// [Qt] tst_QWebPage::infiniteLoopJS() timeouts with DFG JIT
@@ -2755,35 +2754,6 @@ void tst_QWebPage::errorPageExtensionInFrameset()
m_view->setPage(0);
}
-void tst_QWebPage::errorPageExtensionLoadFinished()
-{
- ErrorPage page;
- m_view->setPage(&page);
-
- QSignalSpy spyLoadFinished(m_view, SIGNAL(loadFinished(bool)));
- QSignalSpy spyFrameLoadFinished(m_view->page()->mainFrame(), SIGNAL(loadFinished(bool)));
-
- m_view->setUrl(QUrl("data:text/html,foo"));
- QTRY_COMPARE(spyLoadFinished.count(), 1);
- QTRY_COMPARE(spyFrameLoadFinished.count(), 1);
-
- const bool loadSucceded = spyLoadFinished.at(0).at(0).toBool();
- QVERIFY(loadSucceded);
- const bool frameLoadSucceded = spyFrameLoadFinished.at(0).at(0).toBool();
- QVERIFY(frameLoadSucceded);
-
- m_view->page()->mainFrame()->setUrl(QUrl("http://non.existent/url"));
- QTRY_COMPARE(spyLoadFinished.count(), 2);
- QTRY_COMPARE(spyFrameLoadFinished.count(), 2);
-
- const bool nonExistantLoadSucceded = spyLoadFinished.at(1).at(0).toBool();
- QVERIFY(nonExistantLoadSucceded);
- const bool nonExistantFrameLoadSucceded = spyFrameLoadFinished.at(1).at(0).toBool();
- QVERIFY(nonExistantFrameLoadSucceded);
-
- m_view->setPage(0);
-}
-
class FriendlyWebPage : public QWebPage
{
public:
@@ -2926,15 +2896,13 @@ void tst_QWebPage::originatingObjectInNetworkRequests()
m_page->setNetworkAccessManager(networkManager);
networkManager->requests.clear();
- m_view->setHtml(QString("<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());
+ m_view->setHtml(QString("<frameset cols=\"25%,75%\"><frame src=\"qrc:///frame_c.html\">"
+ "<frame src=\"qrc:///frame_b.html\"></frameset>"), QUrl());
QVERIFY(::waitForSignal(m_view, SIGNAL(loadFinished(bool))));
QCOMPARE(networkManager->requests.count(), 2);
QList<QWebFrame*> childFrames = m_page->mainFrame()->childFrames();
- QEXPECT_FAIL("", "https://bugs.webkit.org/show_bug.cgi?id=118660", Continue);
QCOMPARE(childFrames.count(), 2);
for (int i = 0; i < 2; ++i)
@@ -3102,15 +3070,6 @@ void tst_QWebPage::findText()
}
}
-static QString getMimeTypeForExtension(const QString &ext)
-{
- QMimeType mimeType = QMimeDatabase().mimeTypeForFile(QStringLiteral("filename.") + ext.toLower(), QMimeDatabase::MatchExtension);
- if (mimeType.isValid() && !mimeType.isDefault())
- return mimeType.name();
-
- return QString();
-}
-
void tst_QWebPage::supportedContentType()
{
QStringList contentTypes;
@@ -3118,19 +3077,14 @@ void tst_QWebPage::supportedContentType()
// Add supported non image types...
contentTypes << "text/html" << "text/xml" << "text/xsl" << "text/plain" << "text/"
<< "application/xml" << "application/xhtml+xml" << "application/vnd.wap.xhtml+xml"
- << "application/rss+xml" << "application/atom+xml" << "application/json";
+ << "application/rss+xml" << "application/atom+xml" << "application/json"
+ // Add JPEG MIME type
+ << "image/jpeg";
#if ENABLE_MHTML
contentTypes << "application/x-mimearchive";
#endif
- // Add supported image types...
- Q_FOREACH(const QByteArray& imageType, QImageWriter::supportedImageFormats()) {
- const QString mimeType = getMimeTypeForExtension(imageType);
- if (!mimeType.isEmpty())
- contentTypes << mimeType;
- }
-
// Get the mime types supported by webkit...
const QStringList supportedContentTypes = m_page->supportedContentTypes();
@@ -3194,7 +3148,7 @@ void tst_QWebPage::thirdPartyCookiePolicy()
}
#endif
-#ifdef Q_OS_MAC
+#ifdef Q_OS_MACOS
void tst_QWebPage::macCopyUnicodeToClipboard()
{
QString unicodeText = QString::fromUtf8("αβγδεζηθικλμπ");
@@ -3329,9 +3283,12 @@ void tst_QWebPage::contextMenuPopulatedOnce()
QList<QAction *> list = contextMenu->actions();
QStringList entries;
while (!list.isEmpty()) {
- QString entry = list.takeFirst()->text();
- QVERIFY(!entries.contains(entry));
- entries << entry;
+ const QAction* action = list.takeFirst();
+ if (!action->isSeparator()) {
+ QString entry = action->text();
+ QVERIFY(!entries.contains(entry));
+ entries << entry;
+ }
}
}
diff --git a/Source/WebKit/qt/tests/qwebsecurityorigin/tst_qwebsecurityorigin.cpp b/Source/WebKit/qt/tests/qwebsecurityorigin/tst_qwebsecurityorigin.cpp
index a15838274..225c42d0a 100644
--- a/Source/WebKit/qt/tests/qwebsecurityorigin/tst_qwebsecurityorigin.cpp
+++ b/Source/WebKit/qt/tests/qwebsecurityorigin/tst_qwebsecurityorigin.cpp
@@ -38,8 +38,8 @@ private slots:
void whiteList_data();
void whiteList();
private:
- QWebView* m_view;
- QWebPage* m_page;
+ QWebView* m_view { nullptr };
+ QWebPage* m_page { nullptr };
};
tst_QWebSecurityOrigin::tst_QWebSecurityOrigin()