From a94275402997c11dd2e778633dacf4b7e630a35d Mon Sep 17 00:00:00 2001 From: Ben Murdoch Date: Fri, 22 Oct 2010 13:02:20 +0100 Subject: Merge WebKit at r70209: Initial merge by Git Change-Id: Id23a68efa36e9d1126bcce0b137872db00892c8e --- WebKit/qt/tests/qwebpage/tst_qwebpage.cpp | 83 +++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) (limited to 'WebKit/qt/tests/qwebpage/tst_qwebpage.cpp') diff --git a/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp b/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp index 36fa050..0462953 100644 --- a/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp +++ b/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp @@ -41,6 +41,7 @@ #include #include #include +#include class EventSpy : public QObject, public QList { @@ -126,6 +127,7 @@ private slots: void showModalDialog(); void testStopScheduledPageRefresh(); void findText(); + void supportedContentType(); private: QWebView* m_view; @@ -247,6 +249,12 @@ void tst_QWebPage::infiniteLoopJS() void tst_QWebPage::geolocationRequestJS() { + /* + This test is disabled because it can only succeed if ENABLE(GEOLOCATION) is true. + The code needs to be updated when the API of requestPermissionFromUser is updated. + */ + QSKIP("Test disabled as long as geolocation is disabled from the build.", SkipSingle); + JSTestPage* newPage = new JSTestPage(m_view); connect(newPage, SIGNAL(requestPermissionFromUser(QWebFrame*, QWebPage::PermissionDomain)), newPage, SLOT(requestPermission(QWebFrame*, QWebPage::PermissionDomain))); @@ -2197,5 +2205,80 @@ void tst_QWebPage::findText() } } +struct ImageExtensionMap { + const char* extension; + const char* mimeType; +}; + +static const ImageExtensionMap extensionMap[] = { + { "bmp", "image/bmp" }, + { "css", "text/css" }, + { "gif", "image/gif" }, + { "html", "text/html" }, + { "htm", "text/html" }, + { "ico", "image/x-icon" }, + { "jpeg", "image/jpeg" }, + { "jpg", "image/jpeg" }, + { "js", "application/x-javascript" }, + { "mng", "video/x-mng" }, + { "pbm", "image/x-portable-bitmap" }, + { "pgm", "image/x-portable-graymap" }, + { "pdf", "application/pdf" }, + { "png", "image/png" }, + { "ppm", "image/x-portable-pixmap" }, + { "rss", "application/rss+xml" }, + { "svg", "image/svg+xml" }, + { "text", "text/plain" }, + { "tif", "image/tiff" }, + { "tiff", "image/tiff" }, + { "txt", "text/plain" }, + { "xbm", "image/x-xbitmap" }, + { "xml", "text/xml" }, + { "xpm", "image/x-xpm" }, + { "xsl", "text/xsl" }, + { "xhtml", "application/xhtml+xml" }, + { "wml", "text/vnd.wap.wml" }, + { "wmlc", "application/vnd.wap.wmlc" }, + { 0, 0 } +}; + +static QString getMimeTypeForExtension(const QString &ext) +{ + const ImageExtensionMap *e = extensionMap; + while (e->extension) { + if (ext.compare(QLatin1String(e->extension), Qt::CaseInsensitive) == 0) + return QLatin1String(e->mimeType); + ++e; + } + + return QString(); +} + +void tst_QWebPage::supportedContentType() +{ + QStringList contentTypes; + + // 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"; + + // 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(); + + Q_FOREACH(const QString& mimeType, contentTypes) + QVERIFY2(supportedContentTypes.contains(mimeType), QString("'%1' is not a supported content type!").arg(mimeType).toLatin1()); + + Q_FOREACH(const QString& mimeType, contentTypes) + QVERIFY2(m_page->supportsContentType(mimeType), QString("Cannot handle content types '%1'!").arg(mimeType).toLatin1()); +} + QTEST_MAIN(tst_QWebPage) #include "tst_qwebpage.moc" -- cgit v1.1