aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlxmlhttprequest/data/attr.qml
blob: b1c081c5fdbfcc31fa0c33ad12427d2e7441cb0f (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import QtQuick 2.0

QtObject {
    property bool xmlTest: false
    property bool dataOK: false

    function checkAttr(documentElement, attr)
    {
        if (attr == null)
            return;

        if (attr.name != "attr")
            return;

        if (attr.value != "myvalue")
            return;

        if (attr.ownerElement.tagName != documentElement.tagName)
            return;

        if (attr.nodeName != "attr")
            return;

        if (attr.nodeValue != "myvalue")
            return;

        if (attr.nodeType != 2)
            return;

        if (attr.childNodes.length != 0)
            return;

        if (attr.firstChild != null)
            return;

        if (attr.lastChild != null)
            return;

        if (attr.previousSibling != null)
            return;

        if (attr.nextSibling != null)
            return;

        if (attr.attributes != null)
            return;

        xmlTest = true;
    }

    function checkXML(document)
    {
        checkAttr(document.documentElement, document.documentElement.attributes[0]);
    }

    Component.onCompleted: {
        var x = new XMLHttpRequest;

        x.open("GET", "attr.xml");

        // Test to the end
        x.onreadystatechange = function() {
            if (x.readyState == XMLHttpRequest.DONE) {

                dataOK = true;

                if (x.responseXML != null)
                    checkXML(x.responseXML);

            }
        }

        x.send()
    }
}