aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlxmlhttprequest/data/abort_opened.qml
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/qqmlxmlhttprequest/data/abort_opened.qml')
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/abort_opened.qml60
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/abort_opened.qml b/tests/auto/qml/qqmlxmlhttprequest/data/abort_opened.qml
new file mode 100644
index 0000000000..d5bb84ddc0
--- /dev/null
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/abort_opened.qml
@@ -0,0 +1,60 @@
+import QtQuick 2.0
+
+QtObject {
+ property string url: "testdocument.html"
+
+ property bool readyState: false
+ property bool openedState: false
+
+ property bool status: false
+ property bool statusText: false
+ property bool responseText: false
+ property bool responseXML: false
+
+ property bool dataOK: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+ x.abort();
+
+ if (x.readyState == XMLHttpRequest.UNSENT)
+ readyState = true;
+
+ x.open("PUT", url);
+ x.setRequestHeader("Accept-Language", "en-US");
+
+ x.abort();
+
+ x.open("GET", url);
+ x.setRequestHeader("Accept-Language", "en-US");
+
+ if (x.readyState == XMLHttpRequest.OPENED)
+ openedState = true;
+
+ try {
+ var a = x.status;
+ } catch (error) {
+ if (error.code == DOMException.INVALID_STATE_ERR)
+ status = true;
+ }
+ try {
+ var a = x.statusText;
+ } catch (error) {
+ if (error.code == DOMException.INVALID_STATE_ERR)
+ statusText = true;
+ }
+ responseText = (x.responseText == "");
+ responseXML = (x.responseXML == null);
+
+ // Test to the end
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.DONE) {
+ dataOK = (x.responseText == "QML Rocks!\n");
+ }
+ }
+
+
+ x.send()
+ }
+}
+