summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/xmlhttprequest/data/responseText.qml
blob: 4bb3a7afd1d3d63a28fb20bf84114c2f838d3cac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import Qt 4.6

QtObject {
    property string url
    property string expectedText

    property bool unsent: false
    property bool opened: false
    property bool sent: false
    property bool headersReceived: false

    property bool loading: false
    property bool done: false

    property bool reset: false

    property bool dataOK: false

    Component.onCompleted: {
        var x = new XMLHttpRequest;

        unsent = (x.responseText == "");

        x.open("GET", url);

        opened = (x.responseText == "");

        // Test to the end
        x.onreadystatechange = function() {
            if (x.readyState == XMLHttpRequest.HEADERS_RECEIVED) {
                headersReceived = (x.responseText == "");
            } else if (x.readyState == XMLHttpRequest.LOADING) {
                if (x.responseText == expectedText)
                    loading = true;
            } else if (x.readyState == XMLHttpRequest.DONE) {
                if (x.responseText == expectedText)
                    done = true;

                dataOK = (x.responseText == expectedText);

                x.open("GET", url);

                reset = (x.responseText == "");
            }
        }

        x.send()

        sent = (x.responseText == "");
    }
}