summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-02-05 13:27:14 +0100
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-02-10 14:49:01 +0000
commit9db27320eda70ec4e4948ae0853dd3f2dd08912b (patch)
tree78ac95011fc1ac4929439573e931eece166ad9a3 /tests/auto
parent776442f2117c4b2d6dac75ab56b42bd82e2ce6d0 (diff)
Fix double LoadFinished on URL errors
RenderFrameDeleted was called before DidFinishLoad, which meant m_loadingErrorFrameList was empty and wouldn't detect the page loaded was an error page. Instead this patch relies on the chromium error-page url which we already asserted. Additonally we delay emitting the loadFinished signal until the error page is also done loading, since the error-page can be considered part of the load, and we otherwise have a race condition on toPlainText. Finally we were not getting error-pages when blocking requests because we reported them as aborted them instead of blocked. Change-Id: I945eb838b7f080d4e146f18354e8986e1b88b5cd Task-number: QTBUG-50752 Reviewed-by: Michael BrĂ¼ning <michael.bruning@theqtcompany.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp33
-rw-r--r--tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp3
2 files changed, 35 insertions, 1 deletions
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
index 690cf70e4..207eb019a 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
@@ -241,6 +241,8 @@ private Q_SLOTS:
void loadInSignalHandlers();
void restoreHistory();
+ void toPlainTextLoadFinishedRace_data();
+ void toPlainTextLoadFinishedRace();
private:
QWebEngineView* m_view;
@@ -5115,5 +5117,36 @@ void tst_QWebEnginePage::restoreHistory()
delete channel;
}
+void tst_QWebEnginePage::toPlainTextLoadFinishedRace_data()
+{
+ QTest::addColumn<bool>("enableErrorPage");
+ QTest::newRow("disableErrorPage") << false;
+ QTest::newRow("enableErrorPage") << true;
+}
+
+void tst_QWebEnginePage::toPlainTextLoadFinishedRace()
+{
+ QFETCH(bool, enableErrorPage);
+
+ QWebEnginePage *page = new QWebEnginePage;
+ page->settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, enableErrorPage);
+ QSignalSpy spy(page, SIGNAL(loadFinished(bool)));
+
+ page->load(QUrl("data:text/plain,foobarbaz"));
+ QTRY_VERIFY(spy.count() == 1);
+ QCOMPARE(toPlainTextSync(page), QString("foobarbaz"));
+
+ page->load(QUrl("fail:unknown/scheme"));
+ QTRY_VERIFY(spy.count() == 2);
+ QString s = toPlainTextSync(page);
+ QVERIFY(s.contains("foobarbaz") == !enableErrorPage);
+
+ page->load(QUrl("data:text/plain,lalala"));
+ QTRY_VERIFY(spy.count() == 3);
+ QCOMPARE(toPlainTextSync(page), QString("lalala"));
+ delete page;
+ QVERIFY(spy.count() == 3);
+}
+
QTEST_MAIN(tst_QWebEnginePage)
#include "tst_qwebenginepage.moc"
diff --git a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
index 9195a5190..7cd423356 100644
--- a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
+++ b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
@@ -182,9 +182,10 @@ void tst_QWebEngineProfile::urlSchemeHandlerFailRequest()
QWebEngineView view;
QSignalSpy loadFinishedSpy(&view, SIGNAL(loadFinished(bool)));
view.setPage(new QWebEnginePage(&profile, &view));
+ view.settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, false);
view.load(QUrl(QStringLiteral("foo://bar")));
QVERIFY(loadFinishedSpy.wait());
- QVERIFY(toPlainTextSync(view.page()).isEmpty());
+ QCOMPARE(toPlainTextSync(view.page()), QString());
}
QTEST_MAIN(tst_QWebEngineProfile)