From cda2680d801acce4e221b23e88d9b3c5504f86e8 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 23 May 2018 12:28:46 +0200 Subject: On network redirects, update finalUrl, not url We want all further imports to be relative to the redirected URL, not the base one. Note that this will incorporate any prior URL interceptions into the final URL if a redirect happens. We don't really want this to happen because the result of interception is not meant to be the base for further URL lookup. However, as interception occurs before redirection, this is unavoidable. Don't use URL interceptors on remote URLs. Task-number: QTBUG-67882 Change-Id: I2717bdd4de119ac67caa08fdccc041432025abff Reviewed-by: Simon Hausmann --- tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp') diff --git a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp index c10a8a08c1..d336d033a3 100644 --- a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp +++ b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp @@ -33,6 +33,7 @@ #include #include #include +#include "../../shared/testhttpserver.h" #include "../../shared/util.h" class tst_QQMLTypeLoader : public QQmlDataTest @@ -48,6 +49,7 @@ private slots: void keepSingleton(); void keepRegistrations(); void intercept(); + void redirect(); }; void tst_QQMLTypeLoader::testLoadComplete() @@ -410,6 +412,22 @@ void tst_QQMLTypeLoader::intercept() QVERIFY(factory.loadedFiles.contains(QLatin1String(QT_TESTCASE_BUILDDIR) + "/Slow/qmldir")); } +void tst_QQMLTypeLoader::redirect() +{ + TestHTTPServer server; + QVERIFY2(server.listen(), qPrintable(server.errorString())); + QVERIFY(server.serveDirectory(dataDirectory())); + server.addRedirect("Base.qml", server.urlString("/redirected/Redirected.qml")); + + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(server.urlString("/Load.qml"), QQmlComponent::Asynchronous); + QTRY_VERIFY2(component.isReady(), qPrintable(component.errorString())); + + QObject *object = component.create(); + QTRY_COMPARE(object->property("xy").toInt(), 323232); +} + QTEST_MAIN(tst_QQMLTypeLoader) #include "tst_qqmltypeloader.moc" -- cgit v1.2.3