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