summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-06-29 09:27:09 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-06-29 09:27:09 +0200
commitbdeb49e55617ce42fd7d93075badec5f147bedf8 (patch)
treedb1089078d3b15495d041c2ab3dddc9f81d30d44 /tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
parent4bdccc8abcd7ab3a80c0d84fd005452d5ffceb6b (diff)
parent1a26c0ace958c3604c8a751134429dd38168a1a1 (diff)
Merge remote-tracking branch 'origin/5.15' into dev
Conflicts: src/src.pro Change-Id: I03c260ba676296f93d8137e79b46f3978f5f41ef
Diffstat (limited to 'tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp')
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
index 7bd540cc6..16670ff30 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
@@ -229,6 +229,8 @@ private Q_SLOTS:
void backgroundColor();
void audioMuted();
void closeContents();
+ void isSafeRedirect_data();
+ void isSafeRedirect();
private:
static QPoint elementCenter(QWebEnginePage *page, const QString &id);
@@ -4648,6 +4650,36 @@ void tst_QWebEnginePage::closeContents()
delete dialogView;
}
+// Based on QTBUG-84011
+void tst_QWebEnginePage::isSafeRedirect_data()
+{
+ QTest::addColumn<QUrl>("requestedUrl");
+ QTest::addColumn<QUrl>("expectedUrl");
+ QString fileScheme = "file://";
+
+#ifdef Q_OS_WIN
+ fileScheme += "/";
+#endif
+
+ QString tempDir(fileScheme + QDir::tempPath());
+ QTest::newRow(qPrintable(tempDir)) << QUrl(tempDir) << QUrl(tempDir + "/");
+ QTest::newRow(qPrintable(tempDir + QString("/foo/bar"))) << QUrl(tempDir + "/foo/bar") << QUrl(tempDir + "/foo/bar");
+ QTest::newRow("filesystem:http://foo.com/bar") << QUrl("filesystem:http://foo.com/bar") << QUrl("filesystem:http://foo.com/bar/");
+}
+
+void tst_QWebEnginePage::isSafeRedirect()
+{
+ QFETCH(QUrl, requestedUrl);
+ QFETCH(QUrl, expectedUrl);
+
+ TestPage page;
+ QSignalSpy spy(&page, SIGNAL(loadFinished(bool)));
+ page.setUrl(requestedUrl);
+ QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, 20000);
+ QCOMPARE(page.url(), expectedUrl);
+ spy.clear();
+}
+
static QByteArrayList params = {QByteArrayLiteral("--use-fake-device-for-media-stream")};
W_QTEST_MAIN(tst_QWebEnginePage, params)