Initial import from the monolithic Qt.
[profile/ivi/qtdeclarative.git] / tests / auto / declarative / qdeclarativexmlhttprequest / data / abort_unsent.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("GET", url);
24         x.setRequestHeader("Accept-Language", "en-US");
25
26         if (x.readyState  == XMLHttpRequest.OPENED)
27             openedState = true;
28
29         try {
30             var a = x.status;
31         } catch (error) {
32             if (error.code == DOMException.INVALID_STATE_ERR)
33                 status = true;
34         }
35         try {
36             var a = x.statusText;
37         } catch (error) {
38             if (error.code == DOMException.INVALID_STATE_ERR)
39                 statusText = true;
40         }
41         responseText = (x.responseText == "");
42         responseXML = (x.responseXML == null);
43
44         // Test to the end
45         x.onreadystatechange = function() {
46             if (x.readyState == XMLHttpRequest.DONE) {
47                 dataOK = (x.responseText == "QML Rocks!\n");
48             }
49         }
50
51
52         x.send()
53     }
54 }
55