~ubuntu-branches/ubuntu/saucy/qtdeclarative-opensource-src/saucy

« back to all changes in this revision

Viewing changes to tests/auto/qml/qqmlxmlhttprequest/data/statusText.qml

  • Committer: Package Import Robot
  • Author(s): Timo Jyrinki
  • Date: 2013-02-05 14:17:19 UTC
  • Revision ID: package-import@ubuntu.com-20130205141719-qqeyml8wslpyez52
Tags: upstream-5.0.1
ImportĀ upstreamĀ versionĀ 5.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import QtQuick 2.0
 
2
 
 
3
QtObject {
 
4
    property string url
 
5
    property string expectedStatus
 
6
 
 
7
    property bool unsentException: false;
 
8
    property bool openedException: false;
 
9
    property bool sentException: false;
 
10
 
 
11
    property bool headersReceived: false
 
12
    property bool loading: false
 
13
    property bool done: false
 
14
 
 
15
    property bool resetException: false
 
16
 
 
17
    property bool dataOK: false
 
18
 
 
19
    Component.onCompleted: {
 
20
        var x = new XMLHttpRequest;
 
21
 
 
22
        try {
 
23
            var a = x.statusText;
 
24
        } catch (e) {
 
25
            if (e.code == DOMException.INVALID_STATE_ERR)
 
26
                unsentException = true;
 
27
        }
 
28
 
 
29
        x.open("GET", url);
 
30
        x.setRequestHeader("Accept-Language", "en-US");
 
31
 
 
32
        try {
 
33
            var a = x.statusText;
 
34
        } catch (e) {
 
35
            if (e.code == DOMException.INVALID_STATE_ERR)
 
36
                openedException = true;
 
37
        }
 
38
 
 
39
        // Test to the end
 
40
        x.onreadystatechange = function() {
 
41
            if (x.readyState == XMLHttpRequest.HEADERS_RECEIVED) {
 
42
                if (x.statusText == expectedStatus)
 
43
                    headersReceived = true;
 
44
            } else if (x.readyState == XMLHttpRequest.LOADING) {
 
45
                if (x.statusText == expectedStatus)
 
46
                    loading = true;
 
47
            } else if (x.readyState == XMLHttpRequest.DONE) {
 
48
                if (x.statusText == expectedStatus)
 
49
                    done = true;
 
50
 
 
51
                dataOK = (x.responseText == "QML Rocks!\n");
 
52
 
 
53
                x.open("GET", url);
 
54
                x.setRequestHeader("Accept-Language", "en-US");
 
55
 
 
56
                try {
 
57
                    var a = x.statusText;
 
58
                } catch (e) {
 
59
                    if (e.code == DOMException.INVALID_STATE_ERR)
 
60
                        resetException = true;
 
61
                }
 
62
 
 
63
            }
 
64
        }
 
65
 
 
66
        x.send()
 
67
 
 
68
        try {
 
69
            var a = x.statusText;
 
70
        } catch (e) {
 
71
            if (e.code == DOMException.INVALID_STATE_ERR)
 
72
                sentException = true;
 
73
        }
 
74
    }
 
75
}