Initial import from the monolithic Qt.
[profile/ivi/qtdeclarative.git] / tests / auto / declarative / qdeclarativexmlhttprequest / data / abort_opened.qml
1 import QtQuick 1.0
2
3 QtObject {
4     property string url: "testdocument.html"
5
6     property bool readyState: false
7     property bool openedState: false
8
9     property bool status: false
10     property bool statusText: false
11     property bool responseText: false
12     property bool responseXML: false
13
14     property bool dataOK: false
15
16     Component.onCompleted: {
17         var x = new XMLHttpRequest;
18         x.abort();
19
20         if (x.readyState == XMLHttpRequest.UNSENT)
21             readyState = true;
22
23         x.open("PUT", url);
24         x.setRequestHeader("Accept-Language", "en-US");
25
26         x.abort();
27
28         x.open("GET", url);
29         x.setRequestHeader("Accept-Language", "en-US");
30
31         if (x.readyState  == XMLHttpRequest.OPENED)
32             openedState = true;
33
34         try {
35             var a = x.status;
36         } catch (error) {
37             if (error.code == DOMException.INVALID_STATE_ERR)
38                 status = true;
39         }
40         try {
41             var a = x.statusText;
42         } catch (error) {
43             if (error.code == DOMException.INVALID_STATE_ERR)
44                 statusText = true;
45         }
46         responseText = (x.responseText == "");
47         responseXML = (x.responseXML == null);
48
49         // Test to the end
50         x.onreadystatechange = function() {
51             if (x.readyState == XMLHttpRequest.DONE) {
52                 dataOK = (x.responseText == "QML Rocks!\n");
53             }
54         }
55
56
57         x.send()
58     }
59 }
60