diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/quick/qmltests/data/tst_favicon.qml | 33 | ||||
-rw-r--r-- | tests/auto/widgets/faviconmanager/tst_faviconmanager.cpp | 38 |
2 files changed, 71 insertions, 0 deletions
diff --git a/tests/auto/quick/qmltests/data/tst_favicon.qml b/tests/auto/quick/qmltests/data/tst_favicon.qml index 563a87c83..50a412384 100644 --- a/tests/auto/quick/qmltests/data/tst_favicon.qml +++ b/tests/auto/quick/qmltests/data/tst_favicon.qml @@ -375,5 +375,38 @@ TestWebEngineView { faviconImage.destroy() } + + function test_touchIconWithSameURL() + { + WebEngine.settings.touchIconsEnabled = false; + + var icon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII="; + + webEngineView.loadHtml( + "<html>" + + "<link rel='icon' type='image/png' href='" + icon + "'/>" + + "<link rel='apple-touch-icon' type='image/png' href='" + icon + "'/>" + + "</html>" + ); + verify(webEngineView.waitForLoadSucceeded()); + + // The default favicon has to be loaded even if its URL is also set as a touch icon while touch icons are disabled. + tryCompare(iconChangedSpy, "count", 1); + compare(webEngineView.icon.toString().replace(/^image:\/\/favicon\//, ''), icon); + + iconChangedSpy.clear(); + + webEngineView.loadHtml( + "<html>" + + "<link rel='apple-touch-icon' type='image/png' href='" + icon + "'/>" + + "</html>" + ); + verify(webEngineView.waitForLoadSucceeded()); + + // This page only has a touch icon. With disabled touch icons we don't expect any icon to be shown even if the same icon + // was loaded previously. + tryCompare(iconChangedSpy, "count", 1); + verify(!webEngineView.icon.toString().replace(/^image:\/\/favicon\//, '')); + } } } diff --git a/tests/auto/widgets/faviconmanager/tst_faviconmanager.cpp b/tests/auto/widgets/faviconmanager/tst_faviconmanager.cpp index 606d05d9e..540c8d505 100644 --- a/tests/auto/widgets/faviconmanager/tst_faviconmanager.cpp +++ b/tests/auto/widgets/faviconmanager/tst_faviconmanager.cpp @@ -62,6 +62,7 @@ private Q_SLOTS: void downloadTouchIconsEnabled_data(); void downloadTouchIconsEnabled(); void dynamicFavicon(); + void touchIconWithSameURL(); private: QWebEngineView *m_view; @@ -508,6 +509,43 @@ void tst_FaviconManager::dynamicFavicon() } } +void tst_FaviconManager::touchIconWithSameURL() +{ + m_page->settings()->setAttribute(QWebEngineSettings::TouchIconsEnabled, false); + + const QString icon("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII="); + QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool))); + QSignalSpy iconUrlChangedSpy(m_page, SIGNAL(iconUrlChanged(QUrl))); + QSignalSpy iconChangedSpy(m_page, SIGNAL(iconChanged(QIcon))); + + m_page->setHtml("<html>" + "<link rel='icon' type='image/png' href='" + icon + "'/>" + "<link rel='apple-touch-icon' type='image/png' href='" + icon + "'/>" + "</html>"); + QTRY_COMPARE(loadFinishedSpy.count(), 1); + + // The default favicon has to be loaded even if its URL is also set as a touch icon while touch icons are disabled. + QTRY_COMPARE(iconUrlChangedSpy.count(), 1); + QCOMPARE(m_page->iconUrl().toString(), icon); + QTRY_COMPARE(iconChangedSpy.count(), 1); + + loadFinishedSpy.clear(); + iconUrlChangedSpy.clear(); + iconChangedSpy.clear(); + + m_page->setHtml("<html>" + "<link rel='apple-touch-icon' type='image/png' href='" + icon + "'/>" + "</html>"); + QTRY_COMPARE(loadFinishedSpy.count(), 1); + + // This page only has a touch icon. With disabled touch icons we don't expect any icon to be shown even if the same icon + // was loaded previously. + QTRY_COMPARE(iconUrlChangedSpy.count(), 1); + QVERIFY(m_page->iconUrl().toString().isEmpty()); + QTRY_COMPARE(iconChangedSpy.count(), 1); + +} + QTEST_MAIN(tst_FaviconManager) #include "tst_faviconmanager.moc" |