diff options
Diffstat (limited to 'tests/auto/widgets/qwebengineframe/tst_qwebengineframe.cpp')
-rw-r--r-- | tests/auto/widgets/qwebengineframe/tst_qwebengineframe.cpp | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/tests/auto/widgets/qwebengineframe/tst_qwebengineframe.cpp b/tests/auto/widgets/qwebengineframe/tst_qwebengineframe.cpp index 4b18f8e7a..9901bcd76 100644 --- a/tests/auto/widgets/qwebengineframe/tst_qwebengineframe.cpp +++ b/tests/auto/widgets/qwebengineframe/tst_qwebengineframe.cpp @@ -32,6 +32,7 @@ #include <QNetworkRequest> #include <QNetworkReply> #include <QTextCodec> +#include <QWebEngineSettings> #ifndef QT_NO_OPENSSL #include <qsslerror.h> #endif @@ -124,6 +125,7 @@ void tst_QWebEngineFrame::init() { m_view = new QWebEngineView(); m_page = m_view->page(); + m_page->settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, false); } void tst_QWebEngineFrame::cleanup() @@ -347,7 +349,7 @@ void tst_QWebEngineFrame::requestedUrl() void tst_QWebEngineFrame::requestedUrlAfterSetAndLoadFailures() { QWebEnginePage page; - + page.settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, false); QSignalSpy spy(&page, SIGNAL(loadFinished(bool))); const QUrl first("http://abcdef.abcdef/"); @@ -365,7 +367,6 @@ void tst_QWebEngineFrame::requestedUrlAfterSetAndLoadFailures() ::waitForSignal(&page, SIGNAL(loadFinished(bool))); QCOMPARE(spy.count(), 2); QCOMPARE(page.url(), first); - QEXPECT_FAIL("", "Slight change: The requestedUrl() function catches the error page's entry here thus it results the error page's requested url.", Continue); QCOMPARE(page.requestedUrl(), second); QVERIFY(!spy.at(1).first().toBool()); } @@ -1369,15 +1370,19 @@ void tst_QWebEngineFrame::setUrlHistory() QTRY_COMPARE(spy.count(), expectedLoadFinishedCount); QCOMPARE(m_page->url(), aboutBlank); QCOMPARE(m_page->requestedUrl(), QUrl()); - QCOMPARE(collectHistoryUrls(m_page->history()), QStringList()); + // Chromium stores navigation entry for every successful loads. The load of the empty page is committed and stored as about:blank. + QCOMPARE(collectHistoryUrls(m_page->history()), QStringList() << aboutBlank.toString()); url = QUrl("http://non.existent/"); m_page->setUrl(url); expectedLoadFinishedCount++; QTRY_COMPARE(spy.count(), expectedLoadFinishedCount); - QCOMPARE(m_page->url(), url); - QCOMPARE(m_page->requestedUrl(), url); - QCOMPARE(collectHistoryUrls(m_page->history()), QStringList()); + // When error page is disabled in case of LoadFail the entry of the unavailable page is not stored. + // We expect the url of the previously loaded page here. + QCOMPARE(m_page->url(), aboutBlank); + QCOMPARE(m_page->requestedUrl(), QUrl()); + // Since the entry of the unavailable page is not stored it will not available in the history. + QCOMPARE(collectHistoryUrls(m_page->history()), QStringList() << aboutBlank.toString()); url = QUrl("qrc:/test1.html"); m_page->setUrl(url); @@ -1385,25 +1390,31 @@ void tst_QWebEngineFrame::setUrlHistory() QTRY_COMPARE(spy.count(), expectedLoadFinishedCount); QCOMPARE(m_page->url(), url); QCOMPARE(m_page->requestedUrl(), url); - QCOMPARE(collectHistoryUrls(m_page->history()), QStringList() << QStringLiteral("qrc:/test1.html")); + QCOMPARE(collectHistoryUrls(m_page->history()), QStringList() << aboutBlank.toString() << QStringLiteral("qrc:/test1.html")); m_page->setUrl(QUrl()); expectedLoadFinishedCount++; QTRY_COMPARE(spy.count(), expectedLoadFinishedCount); QCOMPARE(m_page->url(), aboutBlank); QCOMPARE(m_page->requestedUrl(), QUrl()); - QEXPECT_FAIL("", "Slight change: load(QUrl()) currently loads about:blank and nothing prevents it from being added to the history.", Continue); - QCOMPARE(collectHistoryUrls(m_page->history()), QStringList() << QStringLiteral("qrc:/test1.html")); + // Chromium stores navigation entry for every successful loads. The load of the empty page is committed and stored as about:blank. + QCOMPARE(collectHistoryUrls(m_page->history()), QStringList() + << aboutBlank.toString() + << QStringLiteral("qrc:/test1.html") + << aboutBlank.toString()); - // Loading same page as current in history, so history count doesn't change. url = QUrl("qrc:/test1.html"); m_page->setUrl(url); expectedLoadFinishedCount++; QTRY_COMPARE(spy.count(), expectedLoadFinishedCount); QCOMPARE(m_page->url(), url); QCOMPARE(m_page->requestedUrl(), url); - QEXPECT_FAIL("", "Slight change: load(QUrl()) currently loads about:blank and nothing prevents it from being added to the history.", Continue); - QCOMPARE(collectHistoryUrls(m_page->history()), QStringList() << QStringLiteral("qrc:/test1.html")); + // The history count DOES change since the about:blank is in the list. + QCOMPARE(collectHistoryUrls(m_page->history()), QStringList() + << aboutBlank.toString() + << QStringLiteral("qrc:/test1.html") + << aboutBlank.toString() + << QStringLiteral("qrc:/test1.html")); url = QUrl("qrc:/test2.html"); m_page->setUrl(url); @@ -1411,8 +1422,12 @@ void tst_QWebEngineFrame::setUrlHistory() QTRY_COMPARE(spy.count(), expectedLoadFinishedCount); QCOMPARE(m_page->url(), url); QCOMPARE(m_page->requestedUrl(), url); - QEXPECT_FAIL("", "Slight change: load(QUrl()) currently loads about:blank and nothing prevents it from being added to the history.", Continue); - QCOMPARE(collectHistoryUrls(m_page->history()), QStringList() << QStringLiteral("qrc:/test1.html") << QStringLiteral("qrc:/test2.html")); + QCOMPARE(collectHistoryUrls(m_page->history()), QStringList() + << aboutBlank.toString() + << QStringLiteral("qrc:/test1.html") + << aboutBlank.toString() + << QStringLiteral("qrc:/test1.html") + << QStringLiteral("qrc:/test2.html")); } void tst_QWebEngineFrame::setUrlUsingStateObject() @@ -1534,7 +1549,6 @@ void tst_QWebEngineFrame::setUrlThenLoads() // Just after first load. URL didn't changed yet. m_page->load(urlToLoad1); - QEXPECT_FAIL("", "Slight change: url() will return the loaded URL immediately.", Continue); QCOMPARE(m_page->url(), url); QCOMPARE(m_page->requestedUrl(), urlToLoad1); // baseUrlSync spins an event loop and this sometimes return the next result. @@ -1551,7 +1565,6 @@ void tst_QWebEngineFrame::setUrlThenLoads() // Just after second load. URL didn't changed yet. m_page->load(urlToLoad2); - QEXPECT_FAIL("", "Slight change: url() will return the loaded URL immediately.", Continue); QCOMPARE(m_page->url(), urlToLoad1); QCOMPARE(m_page->requestedUrl(), urlToLoad2); QCOMPARE(baseUrlSync(m_page), extractBaseUrl(urlToLoad1)); |