From 688ec88511dedc1de04b4438c26ef071c55de4e8 Mon Sep 17 00:00:00 2001 From: Konstantin Tokarev Date: Tue, 6 Aug 2019 19:40:03 +0300 Subject: Import QtWebKit commit 58390740ab21cbf3ad8d7b51972c9b24fdf58a9c Change-Id: Ia730b2ca3e5c8c1556fed3301cdf2da7cfbd802f Reviewed-by: Konstantin Tokarev --- Source/WebCore/platform/graphics/qt/GradientQt.cpp | 6 +++ Source/WebCore/platform/network/qt/CookieJarQt.cpp | 2 +- .../platform/network/qt/QNetworkReplyHandler.cpp | 13 +---- Source/WebKit/qt/Api/qwebsettings.cpp | 5 +- Source/WebKit/qt/Api/qwebsettings.h | 3 +- Source/WebKit/qt/WidgetApi/qwebpage.cpp | 2 +- Source/WebKit/qt/tests/CMakeLists.txt | 2 + .../qgraphicswebview/tst_qgraphicswebview.cpp | 1 + .../qt/tests/qwebelement/tst_qwebelement.cpp | 6 +-- Source/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp | 30 +++++++---- .../qt/tests/qwebhistory/tst_qwebhistory.cpp | 8 +-- .../tst_qwebhistoryinterface.cpp | 7 +-- Source/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp | 62 +++------------------- .../qwebsecurityorigin/tst_qwebsecurityorigin.cpp | 4 +- 14 files changed, 56 insertions(+), 95 deletions(-) (limited to 'Source') diff --git a/Source/WebCore/platform/graphics/qt/GradientQt.cpp b/Source/WebCore/platform/graphics/qt/GradientQt.cpp index 3412cfadd..2c3dec5ba 100644 --- a/Source/WebCore/platform/graphics/qt/GradientQt.cpp +++ b/Source/WebCore/platform/graphics/qt/GradientQt.cpp @@ -66,6 +66,10 @@ QGradient* Gradient::platformGradient() qreal lastStop(0.0); const qreal lastStopDiff = 0.0000001; while (stopIterator != m_stops.end()) { + // Drop gradient stops after 1.0 to avoid overwriting color at 1.0 + if (lastStop >= 1) + break; + stopColor.setRgbF(stopIterator->red, stopIterator->green, stopIterator->blue, stopIterator->alpha); if (qFuzzyCompare(lastStop, qreal(stopIterator->stop))) lastStop = stopIterator->stop + lastStopDiff; @@ -78,6 +82,8 @@ QGradient* Gradient::platformGradient() lastStop += innerRadius / outerRadius; } + // Clamp stop position to 1.0, otherwise QGradient will ignore it + // https://bugs.webkit.org/show_bug.cgi?id=41484 qreal stopPosition = qMin(lastStop, qreal(1.0f)); if (m_radial && reversed) diff --git a/Source/WebCore/platform/network/qt/CookieJarQt.cpp b/Source/WebCore/platform/network/qt/CookieJarQt.cpp index d1cf87fdd..0e05e677b 100644 --- a/Source/WebCore/platform/network/qt/CookieJarQt.cpp +++ b/Source/WebCore/platform/network/qt/CookieJarQt.cpp @@ -123,7 +123,7 @@ String cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const bool cookiesEnabled(const NetworkStorageSession& session, const URL& /*firstParty*/, const URL& /*url*/) { - return true; + return session.context() ? session.context()->networkAccessManager()->cookieJar() : SharedCookieJarQt::shared(); } bool getRawCookies(const NetworkStorageSession& session, const URL& /*firstParty*/, const URL& /*url*/, Vector& rawCookies) diff --git a/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp b/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp index 0ce68838e..48432d974 100644 --- a/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp +++ b/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp @@ -588,19 +588,10 @@ void QNetworkReplyHandler::sendResponseIfNeeded() m_replyWrapper->reply()->header(QNetworkRequest::ContentLengthHeader).toLongLong(), m_replyWrapper->encoding()); - if (url.isLocalFile()) { - if (client->usesAsyncCallbacks()) { - setLoadingDeferred(true); - client->didReceiveResponseAsync(m_resourceHandle, response); - } else - client->didReceiveResponse(m_resourceHandle, response); - return; - } - - // The status code is equal to 0 for protocols not in the HTTP family. - int statusCode = m_replyWrapper->reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); if (url.protocolIsInHTTPFamily()) { + // The status code is equal to 0 for protocols not in the HTTP family. + int statusCode = m_replyWrapper->reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); response.setHTTPStatusCode(statusCode); response.setHTTPStatusText(m_replyWrapper->reply()->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toByteArray().constData()); diff --git a/Source/WebKit/qt/Api/qwebsettings.cpp b/Source/WebKit/qt/Api/qwebsettings.cpp index d552cec17..3cbb831af 100644 --- a/Source/WebKit/qt/Api/qwebsettings.cpp +++ b/Source/WebKit/qt/Api/qwebsettings.cpp @@ -600,6 +600,7 @@ QWebSettings::QWebSettings() d->attributes.insert(QWebSettings::FullScreenSupportEnabled, true); d->attributes.insert(QWebSettings::ImagesEnabled, true); d->attributes.insert(QWebSettings::AllowRunningInsecureContent, false); + d->attributes.insert(QWebSettings::ErrorPageEnabled, true); d->offlineStorageDefaultQuota = 5 * 1024 * 1024; d->defaultTextEncoding = QLatin1String("iso-8859-1"); d->thirdPartyCookiePolicy = AlwaysAllowThirdPartyCookies; @@ -936,10 +937,8 @@ void QWebSettings::clearMemoryCaches() // FastMalloc has lock-free thread specific caches that can only be cleared from the thread itself. WebCore::StorageThread::releaseFastMallocFreeMemoryInAllThreads(); -#if ENABLE(WORKERS) WebCore::WorkerThread::releaseFastMallocFreeMemoryInAllThreads(); -#endif - WTF::releaseFastMallocFreeMemory(); + WTF::releaseFastMallocFreeMemory(); } /*! diff --git a/Source/WebKit/qt/Api/qwebsettings.h b/Source/WebKit/qt/Api/qwebsettings.h index 0b0a1f00a..2c22fb46e 100644 --- a/Source/WebKit/qt/Api/qwebsettings.h +++ b/Source/WebKit/qt/Api/qwebsettings.h @@ -92,7 +92,8 @@ public: WebSecurityEnabled, FullScreenSupportEnabled, ImagesEnabled, - AllowRunningInsecureContent + AllowRunningInsecureContent, + ErrorPageEnabled }; enum WebGraphic { MissingImageGraphic, diff --git a/Source/WebKit/qt/WidgetApi/qwebpage.cpp b/Source/WebKit/qt/WidgetApi/qwebpage.cpp index f8d8c0abc..b27ac1357 100644 --- a/Source/WebKit/qt/WidgetApi/qwebpage.cpp +++ b/Source/WebKit/qt/WidgetApi/qwebpage.cpp @@ -3219,7 +3219,7 @@ bool QWebPage::supportsExtension(Extension extension) const if (extension == ChooseMultipleFilesExtension) return true; #endif - return extension == ErrorPageExtension; + return extension == ErrorPageExtension && d->settings->testAttribute(QWebSettings::ErrorPageEnabled); } /*! 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 a4056f996..2068eec3f 100644 --- a/Source/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp +++ b/Source/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp @@ -99,10 +99,10 @@ private Q_SLOTS: 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) @@ -341,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() @@ -463,7 +473,7 @@ void tst_QWebFrame::setHtmlWithBaseURL() QDir::setCurrent(TESTS_SOURCE_DIR); - QString html("

hello world

"); + QString html("

hello world

"); QWebPage page; QWebFrame* frame = page.mainFrame(); @@ -1268,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); @@ -1277,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"); @@ -1294,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); @@ -1303,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() 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 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 760a242af..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(); @@ -217,8 +216,8 @@ private Q_SLOTS: #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("foo \">" - ""), QUrl()); + m_view->setHtml(QString("" + ""), QUrl()); QVERIFY(::waitForSignal(m_view, SIGNAL(loadFinished(bool)))); QCOMPARE(networkManager->requests.count(), 2); QList 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(); 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() -- cgit v1.2.1