aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2017-11-01 16:29:44 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2023-04-20 22:00:44 +0200
commit66f167aedce5d9739859bd00dab5c1e1091aacb4 (patch)
tree8ce4a1e38087a83ae31bcc33c1074ec9bcff5ae6 /tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp
parentd7fac6923a6d4e4ac7dc22458256366968acbdb3 (diff)
XMLHttpRequest: Implement XHR.overrideMimeType()
It was missing from QQmlXMLHttpRequestCtor, making life painful for XHR users. It's a method that has existed in every XHR specification, and is required, if the goal is to be compliant with any XHR web standard. [ChangeLog][Qml][XMLHttpRequest] Added missing overrideMimeType(mime) method. This function can be used to force the XHR object to parse the data in HTTP responses differently than what the server suggests. Done-with: Oliver Eftevaag <oliver.eftevaag@qt.io> Task-number: QTBUG-53709 Change-Id: I9f8ff37e1604b95306a85fc7e64db6d111b9e069 Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp')
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp b/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp
index defbe3cf01..1a6ff59ae2 100644
--- a/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp
+++ b/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp
@@ -90,6 +90,8 @@ private slots:
void sendFileRequestNoRead();
#endif
+ void overrideMime();
+
// WebDAV
void sendPropfind();
void sendPropfind_data();
@@ -1545,6 +1547,26 @@ void tst_qqmlxmlhttprequest::stateChangeCallingContext()
QTRY_VERIFY(object->property("success").toBool());
}
+void tst_qqmlxmlhttprequest::overrideMime()
+{
+ // overrideMimeType.reply sets the Content-Type to text/plain
+ // overrideMimeType.qml overrides it to text/xml and checks the responseXML property.
+
+ TestHTTPServer server;
+ QVERIFY2(server.listen(), qPrintable(server.errorString()));
+ QVERIFY(server.wait(testFileUrl("text.expect"),
+ testFileUrl("overrideMimeType.reply"),
+ testFileUrl("text.xml")));
+
+ QQmlComponent component(engine.get(), testFileUrl("overrideMimeType.qml"));
+ QScopedPointer<QObject> object(component.beginCreate(engine.get()->rootContext()));
+ QVERIFY(!object.isNull());
+ object->setProperty("url", server.urlString("/text.xml"));
+ component.completeCreate();
+
+ QTRY_VERIFY(object->property("dataOK").toBool());
+}
+
QTEST_MAIN(tst_qqmlxmlhttprequest)
#include "tst_qqmlxmlhttprequest.moc"