From 256503fadf5a925933fc03980d7c878643b1fdca Mon Sep 17 00:00:00 2001 From: Maximilian Goldstein Date: Fri, 3 Jul 2020 11:50:06 +0200 Subject: URL: Allow non-string parameters Previously we only allowed string parameters as the first parameter of the URL constructor. This excluded types like url. The behavior of instead trying to convert the parameter to a string and then interpreting this as an url matches the specification more closely. Change-Id: I6ef8db9d8c0f238ba8c51b1023decdfcc1caad87 Reviewed-by: Ulf Hermann --- tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests') diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 9b750d5399..0865628061 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -335,6 +335,9 @@ private slots: void qualifiedScopeInCustomParser(); void checkUncreatableNoReason(); + + void checkURLtoURLObject(); + private: QQmlEngine engine; QStringList defaultImportPathList; @@ -5929,6 +5932,16 @@ void tst_qqmllanguage::checkUncreatableNoReason() QCOMPARE(c.errors().first().description(), QString("Type cannot be created in QML.")); } +void tst_qqmllanguage::checkURLtoURLObject() +{ + QQmlEngine engine; + QString qml = QString("import QtQuick 2.0\nItem { property url source: 'file:///foo/bar/'; " + "Component.onCompleted: { new URL(parent.source); } }"); + QQmlComponent c(&engine); + c.setData(qml.toUtf8(), QUrl::fromLocalFile(QDir::currentPath())); + QCOMPARE(c.errors().count(), 0); +} + QTEST_MAIN(tst_qqmllanguage) #include "tst_qqmllanguage.moc" -- cgit v1.2.3