From 858a468b77ed969333efe4985cb4a64d46c5c154 Mon Sep 17 00:00:00 2001 From: Viktor Engelmann Date: Wed, 23 Aug 2017 12:51:57 +0200 Subject: Add Autotest for restoring history that contains an internal page Since this issue has re-appeared at least once, we add an Autotest that navigates to an internal page (view-source:...), saves and then restores the history. Task-number: QTBUG-57826 Change-Id: Ida771ebacefd38592873d02f47133d0f3f6894ea Reviewed-by: Peter Varga Reviewed-by: Allan Sandfeld Jensen --- .../qwebenginehistory/tst_qwebenginehistory.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'tests/auto/widgets/qwebenginehistory') diff --git a/tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp b/tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp index d9bbce173..7c8497fef 100644 --- a/tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp +++ b/tests/auto/widgets/qwebenginehistory/tst_qwebenginehistory.cpp @@ -65,6 +65,7 @@ private Q_SLOTS: void saveAndRestore_crash_2(); void saveAndRestore_crash_3(); void saveAndRestore_crash_4(); + void saveAndRestore_InternalPage(); void popPushState_data(); void popPushState(); @@ -420,6 +421,26 @@ void tst_QWebEngineHistory::saveAndRestore_crash_4() QTRY_COMPARE(loadFinishedSpy2.count(), 1); } +void tst_QWebEngineHistory::saveAndRestore_InternalPage() +{ + QWebEngineView view; + view.show(); + QSignalSpy loadFinishedSpy(&view, &QWebEngineView::loadFinished); + view.load(QUrl("view-source:http://qt.io")); + QTRY_LOOP_IMPL((loadFinishedSpy.size() == 1), 30000, 200) + if (loadFinishedSpy.size() != 1 || !loadFinishedSpy.at(0).at(0).toBool()) + QSKIP("Couldn't load page from network, skipping test."); + + // get history + QByteArray data; + QDataStream stream1(&data, QIODevice::WriteOnly); + stream1 << *view.history(); + + // restore history - this should not crash. see QTBUG-57826 + QDataStream stream2(data); + stream2 >> *view.history(); +} + void tst_QWebEngineHistory::popPushState_data() { QTest::addColumn("script"); -- cgit v1.2.3