aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativexmlhttprequest/data
diff options
context:
space:
mode:
authorQt by Nokia <qt-info@nokia.com>2011-04-27 12:05:43 +0200
committeraxis <qt-info@nokia.com>2011-04-27 12:05:43 +0200
commit885735d011472bcfbb96e688d9e64553d7fe9d4b (patch)
tree734963625eba643bf11bc4870a4c407809a6400a /tests/auto/declarative/qdeclarativexmlhttprequest/data
Initial import from the monolithic Qt.
This is the beginning of revision history for this module. If you want to look at revision history older than this, please refer to the Qt Git wiki for how to use Git history grafting. At the time of writing, this wiki is located here: http://qt.gitorious.org/qt/pages/GitIntroductionWithQt If you have already performed the grafting and you don't see any history beyond this commit, try running "git log" with the "--follow" argument. Branched from the monolithic repo, Qt master branch, at commit 896db169ea224deb96c59ce8af800d019de63f12
Diffstat (limited to 'tests/auto/declarative/qdeclarativexmlhttprequest/data')
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.expect10
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.qml44
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.reply3
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_opened.qml60
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_unsent.qml55
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.qml78
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.xml1
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/callbackException.qml25
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.qml133
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.xml2
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/constructor.qml14
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/defaultState.qml30
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/document.qml56
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/document.xml3
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/domExceptionCodes.qml60
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/element.qml145
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/element.xml1
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders.qml66
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_args.qml23
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_sent.qml20
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_unsent.qml16
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.expect7
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.qml76
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.reply8
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_args.qml23
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_sent.qml20
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_unsent.qml16
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/instanceStateValues.qml33
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/invalidMethodUsage.qml160
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/open.qml54
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.1.qml18
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.2.qml18
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/open_invalid_method.qml16
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.expect7
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.reply3
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.wait0
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/open_sync.qml17
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/open_user.qml54
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/open_username.qml54
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectError.qml23
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectRecur.qml23
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/redirects.qml22
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/redirecttarget.html1
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/responseText.qml54
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/responseXML_invalid.qml24
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/seconddocument.html1
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_alreadySent.qml28
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.expect10
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.qml22
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.2.qml24
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.3.qml24
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.expect10
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.qml24
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.5.qml24
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.expect10
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.qml22
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.7.qml24
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.reply3
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.qml27
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.reply3
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_GET.expect7
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_PUT.expect7
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/send_unsent.qml16
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.expect9
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.qml29
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.reply3
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_args.qml18
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_illegalName.qml58
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_sent.qml32
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_unsent.qml17
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/staticStateValues.qml24
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/status.200.reply3
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/status.404.reply3
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/status.expect7
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/status.qml79
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/statusText.qml79
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/testdocument.html1
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/text.qml129
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/text.xml1
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.html1
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.qml29
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.xmlbin0 -> 154 bytes
82 files changed, 2384 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.expect
new file mode 100644
index 0000000000..4d21122531
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.expect
@@ -0,0 +1,10 @@
+PUT /testdocument.html HTTP/1.1
+ACCEPT-LANGUAGE: en-US
+Content-Type: text/plain;charset=UTF-8
+Content-Length: 9
+Connection: Keep-Alive
+Accept-Encoding: gzip
+User-Agent: Mozilla/5.0
+Host: 127.0.0.1:14445
+
+Test Data \ No newline at end of file
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.qml
new file mode 100644
index 0000000000..0196586bb7
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.qml
@@ -0,0 +1,44 @@
+import QtQuick 1.0
+
+QtObject {
+ property string urlDummy
+ property string url
+
+ property bool seenDone: false
+ property bool didNotSeeUnsent: true
+ property bool endStateUnsent: false
+ property bool dataOK: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+ x.open("GET", urlDummy);
+ x.setRequestHeader("Test-header", "TestValue");
+ x.setRequestHeader("Accept-Language", "en-US");
+ x.send();
+
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.DONE) {
+ seenDone = true;
+ } else if (x.readyState == XMLHttpRequest.UNSENT) {
+ didNotSeeUnsent = false;
+ }
+ }
+
+ x.abort();
+
+ if (x.readyState == XMLHttpRequest.UNSENT) {
+ endStateUnsent = true;
+ }
+
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.DONE) {
+ dataOK = (x.responseText == "QML Rocks!\n");
+ }
+ }
+ x.open("PUT", url);
+ x.setRequestHeader("Accept-Language", "en-US");
+ x.send("Test Data");
+ }
+}
+
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.reply b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.reply
new file mode 100644
index 0000000000..7ae6951f9b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.reply
@@ -0,0 +1,3 @@
+HTTP/1.0 200 OK
+Connection: close
+Content-type: text/html; charset=UTF-8
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_opened.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_opened.qml
new file mode 100644
index 0000000000..aeea278967
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_opened.qml
@@ -0,0 +1,60 @@
+import QtQuick 1.0
+
+QtObject {
+ property string url: "testdocument.html"
+
+ property bool readyState: false
+ property bool openedState: false
+
+ property bool status: false
+ property bool statusText: false
+ property bool responseText: false
+ property bool responseXML: false
+
+ property bool dataOK: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+ x.abort();
+
+ if (x.readyState == XMLHttpRequest.UNSENT)
+ readyState = true;
+
+ x.open("PUT", url);
+ x.setRequestHeader("Accept-Language", "en-US");
+
+ x.abort();
+
+ x.open("GET", url);
+ x.setRequestHeader("Accept-Language", "en-US");
+
+ if (x.readyState == XMLHttpRequest.OPENED)
+ openedState = true;
+
+ try {
+ var a = x.status;
+ } catch (error) {
+ if (error.code == DOMException.INVALID_STATE_ERR)
+ status = true;
+ }
+ try {
+ var a = x.statusText;
+ } catch (error) {
+ if (error.code == DOMException.INVALID_STATE_ERR)
+ statusText = true;
+ }
+ responseText = (x.responseText == "");
+ responseXML = (x.responseXML == null);
+
+ // Test to the end
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.DONE) {
+ dataOK = (x.responseText == "QML Rocks!\n");
+ }
+ }
+
+
+ x.send()
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_unsent.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_unsent.qml
new file mode 100644
index 0000000000..fffc3d9c09
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_unsent.qml
@@ -0,0 +1,55 @@
+import QtQuick 1.0
+
+QtObject {
+ property string url: "testdocument.html"
+
+ property bool readyState: false
+ property bool openedState: false
+
+ property bool status: false
+ property bool statusText: false
+ property bool responseText: false
+ property bool responseXML: false
+
+ property bool dataOK: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+ x.abort();
+
+ if (x.readyState == XMLHttpRequest.UNSENT)
+ readyState = true;
+
+ x.open("GET", url);
+ x.setRequestHeader("Accept-Language", "en-US");
+
+ if (x.readyState == XMLHttpRequest.OPENED)
+ openedState = true;
+
+ try {
+ var a = x.status;
+ } catch (error) {
+ if (error.code == DOMException.INVALID_STATE_ERR)
+ status = true;
+ }
+ try {
+ var a = x.statusText;
+ } catch (error) {
+ if (error.code == DOMException.INVALID_STATE_ERR)
+ statusText = true;
+ }
+ responseText = (x.responseText == "");
+ responseXML = (x.responseXML == null);
+
+ // Test to the end
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.DONE) {
+ dataOK = (x.responseText == "QML Rocks!\n");
+ }
+ }
+
+
+ x.send()
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.qml
new file mode 100644
index 0000000000..5d5dd12f54
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.qml
@@ -0,0 +1,78 @@
+import QtQuick 1.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()
+ }
+}
+
+
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.xml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.xml
new file mode 100644
index 0000000000..2aa64a3d00
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.xml
@@ -0,0 +1 @@
+<root attr="myvalue" />
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/callbackException.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/callbackException.qml
new file mode 100644
index 0000000000..ec6902dc45
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/callbackException.qml
@@ -0,0 +1,25 @@
+import QtQuick 1.0
+
+QtObject {
+ id: obj
+ property string url
+ property string which
+ property bool threw: false
+
+ onWhichChanged: {
+ var x = new XMLHttpRequest;
+
+ x.onreadystatechange = function() {
+ if (x.readyState == which) {
+ obj.threw = true
+ throw(new Error("Exception from Callback"))
+ }
+ }
+
+ x.open("GET", url);
+ x.setRequestHeader("Test-header", "TestValue");
+ x.send();
+ }
+}
+
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.qml
new file mode 100644
index 0000000000..be60664e03
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.qml
@@ -0,0 +1,133 @@
+import QtQuick 1.0
+
+QtObject {
+ property bool xmlTest: false
+ property bool dataOK: false
+
+ function checkCData(text, whitespacetext)
+ {
+ // This is essentially a copy of text.qml/checkText()
+
+ if (text == null)
+ return;
+
+ if (text.nodeName != "#cdata-section")
+ return;
+
+ if (text.nodeValue != "Hello world!")
+ return;
+
+ if (text.nodeType != 4)
+ return;
+
+ if (text.parentNode.nodeName != "item")
+ return;
+
+ if (text.childNodes.length != 0)
+ return;
+
+ if (text.firstChild != null)
+ return;
+
+ if (text.lastChild != null)
+ return;
+
+ if (text.previousSibling != null)
+ return;
+
+ if (text.nextSibling != null)
+ return;
+
+ if (text.attributes != null)
+ return;
+
+ if (text.wholeText != "Hello world!")
+ return;
+
+ if (text.data != "Hello world!")
+ return;
+
+ if (text.length != 12)
+ return;
+
+ if (text.isElementContentWhitespace != false)
+ return;
+
+ if (whitespacetext.nodeName != "#cdata-section")
+ return;
+
+ if (whitespacetext.nodeValue != " ")
+ return;
+
+ if (whitespacetext.nodeType != 4)
+ return;
+
+ if (whitespacetext.parentNode.nodeName != "item")
+ return;
+
+ if (whitespacetext.childNodes.length != 0)
+ return;
+
+ if (whitespacetext.firstChild != null)
+ return;
+
+ if (whitespacetext.lastChild != null)
+ return;
+
+ if (whitespacetext.previousSibling != null)
+ return;
+
+ if (whitespacetext.nextSibling != null)
+ return;
+
+ if (whitespacetext.attributes != null)
+ return;
+
+ if (whitespacetext.wholeText != " ")
+ return;
+
+ if (whitespacetext.data != " ")
+ return;
+
+ if (whitespacetext.length != 3)
+ return;
+
+ if (whitespacetext.isElementContentWhitespace != true)
+ return;
+
+
+ xmlTest = true;
+ }
+
+ function checkXML(document)
+ {
+ checkCData(document.documentElement.childNodes[0].childNodes[0],
+ document.documentElement.childNodes[1].childNodes[0]);
+
+ }
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+
+ x.open("GET", "cdata.xml");
+
+ // Test to the end
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.DONE) {
+
+ dataOK = true;
+
+ if (x.responseXML != null)
+ checkXML(x.responseXML);
+
+ }
+ }
+
+ x.send()
+ }
+}
+
+
+
+
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.xml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.xml
new file mode 100644
index 0000000000..061d37c0b6
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.xml
@@ -0,0 +1,2 @@
+<root><item><![CDATA[Hello world!]]></item><item><![CDATA[ ]]></item></root>
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/constructor.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/constructor.qml
new file mode 100644
index 0000000000..0050f919d1
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/constructor.qml
@@ -0,0 +1,14 @@
+import QtQuick 1.0
+
+QtObject {
+ property bool calledAsConstructor
+ property bool calledAsFunction
+
+ Component.onCompleted: {
+ var x1 = new XMLHttpRequest;
+ var x2 = XMLHttpRequest();
+
+ calledAsConstructor = (x1 != null && x1 instanceof XMLHttpRequest);
+ calledAsFunction = (x2 == undefined);
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/defaultState.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/defaultState.qml
new file mode 100644
index 0000000000..77b2b94e29
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/defaultState.qml
@@ -0,0 +1,30 @@
+import QtQuick 1.0
+
+QtObject {
+ property int readyState
+ property bool statusIsException: false
+ property bool statusTextIsException: false
+ property string responseText
+ property bool responseXMLIsNull
+
+ Component.onCompleted: {
+ var xhr = new XMLHttpRequest();
+
+ readyState = xhr.readyState;
+ try {
+ status = xhr.status;
+ } catch (error) {
+ if (error.code == DOMException.INVALID_STATE_ERR)
+ statusIsException = true;
+ }
+ try {
+ statusText = xhr.statusText;
+ } catch (error) {
+ if (error.code == DOMException.INVALID_STATE_ERR)
+ statusTextIsException = true;
+ }
+ responseText = xhr.responseText;
+ responseXMLIsNull = (xhr.responseXML == null);
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/document.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/document.qml
new file mode 100644
index 0000000000..faf3af0acb
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/document.qml
@@ -0,0 +1,56 @@
+import QtQuick 1.0
+
+QtObject {
+ property bool xmlTest: false
+ property bool dataOK: false
+
+ function checkXML(document)
+ {
+ if (document.xmlVersion != "1.0")
+ return;
+
+ if (document.xmlEncoding != "UTF-8")
+ return;
+
+ if (document.xmlStandalone != true)
+ return;
+
+ if (document.documentElement == null)
+ return;
+
+ if (document.nodeName != "#document")
+ return;
+
+ if (document.nodeValue != null)
+ return;
+
+ if (document.parentNode != null)
+ return;
+
+ // ### Test other node properties
+ // ### test encoding (what is a valid qt encoding?)
+ xmlTest = true;
+ }
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+
+ x.open("GET", "document.xml");
+
+ // Test to the end
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.DONE) {
+
+ dataOK = true;
+
+ if (x.responseXML != null)
+ checkXML(x.responseXML);
+
+ }
+ }
+
+ x.send()
+ }
+}
+
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/document.xml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/document.xml
new file mode 100644
index 0000000000..fb693ea193
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/document.xml
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8" standalone='yes'?>
+<root>
+</root>
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/domExceptionCodes.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/domExceptionCodes.qml
new file mode 100644
index 0000000000..0f32a64a94
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/domExceptionCodes.qml
@@ -0,0 +1,60 @@
+import QtQuick 1.0
+
+QtObject {
+ property int index_size_err: DOMException.INDEX_SIZE_ERR
+ property int domstring_size_err: DOMException.DOMSTRING_SIZE_ERR
+ property int hierarchy_request_err: DOMException.HIERARCHY_REQUEST_ERR
+ property int wrong_document_err: DOMException.WRONG_DOCUMENT_ERR
+ property int invalid_character_err: DOMException.INVALID_CHARACTER_ERR
+ property int no_data_allowed_err: DOMException.NO_DATA_ALLOWED_ERR
+ property int no_modification_allowed_err: DOMException.NO_MODIFICATION_ALLOWED_ERR
+ property int not_found_err: DOMException.NOT_FOUND_ERR
+ property int not_supported_err: DOMException.NOT_SUPPORTED_ERR
+ property int inuse_attribute_err: DOMException.INUSE_ATTRIBUTE_ERR
+ property int invalid_state_err: DOMException.INVALID_STATE_ERR
+ property int syntax_err: DOMException.SYNTAX_ERR
+ property int invalid_modification_err: DOMException.INVALID_MODIFICATION_ERR
+ property int namespace_err: DOMException.NAMESPACE_ERR
+ property int invalid_access_err: DOMException.INVALID_ACCESS_ERR
+ property int validation_err: DOMException.VALIDATION_ERR
+ property int type_mismatch_err: DOMException.TYPE_MISMATCH_ERR
+
+ Component.onCompleted: {
+ // Attempt to overwrite and delete values
+ DOMException.INDEX_SIZE_ERR = 44;
+ DOMException.DOMSTRING_SIZE_ERR = 44;
+ DOMException.HIERARCHY_REQUEST_ERR = 44;
+ DOMException.WRONG_DOCUMENT_ERR = 44;
+ DOMException.INVALID_CHARACTER_ERR = 44;
+ DOMException.NO_DATA_ALLOWED_ERR = 44;
+ DOMException.NO_MODIFICATION_ALLOWED_ERR = 44;
+ DOMException.NOT_FOUND_ERR = 44;
+ DOMException.NOT_SUPPORTED_ERR = 44;
+ DOMException.INUSE_ATTRIBUTE_ERR = 44;
+ DOMException.INVALID_STATE_ERR = 44;
+ DOMException.SYNTAX_ERR = 44;
+ DOMException.INVALID_MODIFICATION_ERR = 44;
+ DOMException.NAMESPACE_ERR = 44;
+ DOMException.INVALID_ACCESS_ERR = 44;
+ DOMException.VALIDATION_ERR = 44;
+ DOMException.TYPE_MISMATCH_ERR = 44;
+
+ delete DOMException.INDEX_SIZE_ERR;
+ delete DOMException.DOMSTRING_SIZE_ERR;
+ delete DOMException.HIERARCHY_REQUEST_ERR;
+ delete DOMException.WRONG_DOCUMENT_ERR;
+ delete DOMException.INVALID_CHARACTER_ERR;
+ delete DOMException.NO_DATA_ALLOWED_ERR;
+ delete DOMException.NO_MODIFICATION_ALLOWED_ERR;
+ delete DOMException.NOT_FOUND_ERR;
+ delete DOMException.NOT_SUPPORTED_ERR;
+ delete DOMException.INUSE_ATTRIBUTE_ERR;
+ delete DOMException.INVALID_STATE_ERR;
+ delete DOMException.SYNTAX_ERR;
+ delete DOMException.INVALID_MODIFICATION_ERR;
+ delete DOMException.NAMESPACE_ERR;
+ delete DOMException.INVALID_ACCESS_ERR;
+ delete DOMException.VALIDATION_ERR;
+ delete DOMException.TYPE_MISMATCH_ERR;
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/element.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/element.qml
new file mode 100644
index 0000000000..daec950343
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/element.qml
@@ -0,0 +1,145 @@
+import QtQuick 1.0
+
+QtObject {
+ property bool xmlTest: false
+ property bool dataOK: false
+
+ function checkElement(e, person, fruit)
+ {
+ if (e.tagName != "root")
+ return;
+
+ if (e.nodeName != "root")
+ return;
+
+ if (e.nodeValue != null)
+ return;
+
+ if (e.nodeType != 1)
+ return;
+
+ var childTagNames = [ "person", "fruit" ];
+
+ if (e.childNodes.length != childTagNames.length)
+ return;
+
+ for (var ii = 0; ii < childTagNames.length; ++ii) {
+ if (e.childNodes[ii].tagName != childTagNames[ii])
+ return;
+ }
+
+ if (e.childNodes[childTagNames.length + 1] != null)
+ return;
+
+ // Check writing fails
+ e.childNodes[0] = null;
+ if (e.childNodes[0] == null)
+ return;
+
+ e.childNodes[10] = 10;
+ if (e.childNodes[10] != null)
+ return;
+
+ if (e.firstChild.tagName != e.childNodes[0].tagName)
+ return;
+
+ if (e.lastChild.tagName != e.childNodes[1].tagName)
+ return;
+
+ if (e.previousSibling != null)
+ return;
+
+ if (e.nextSibling != null)
+ return;
+
+ if (e.attributes == null)
+ return;
+
+ if (e.attributes.length != 2)
+ return;
+
+ var attr1 = e.attributes["attr"];
+ if (attr1.nodeValue != "value")
+ return;
+
+ var attrIdx = e.attributes[0];
+ if (attrIdx.nodeValue != "value")
+ return;
+
+ var attr2 = e.attributes["attr2"];
+ if (attr2.nodeValue != "value2")
+ return;
+
+ var attr3 = e.attributes["attr3"];
+ if (attr3 != null)
+ return;
+
+ var attrIdx2 = e.attributes[11];
+ if (attrIdx2 != null)
+ return;
+
+ // Check writing fails
+ e.attributes[0] = null;
+ if (e.attributes[0] == null)
+ return;
+
+ e.attributes["attr"] = null;
+ if (e.attributes["attr"] == null)
+ return;
+
+ e.attributes["attr3"] = 10;
+ if (e.attributes["attr3"] != null)
+ return;
+
+ // Check person and fruit sub elements
+ if (person.parentNode.nodeName != "root")
+ return;
+
+ if (person.previousSibling != null)
+ return;
+
+ if (person.nextSibling.nodeName != "fruit")
+ return;
+
+ if (fruit.parentNode.nodeName != "root")
+ return;
+
+ if (fruit.previousSibling.nodeName != "person")
+ return;
+
+ if (fruit.nextSibling != null)
+ return;
+
+ xmlTest = true;
+ }
+
+ function checkXML(document)
+ {
+ checkElement(document.documentElement,
+ document.documentElement.childNodes[0],
+ document.documentElement.childNodes[1]);
+ }
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+
+ x.open("GET", "element.xml");
+
+ // Test to the end
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.DONE) {
+
+ dataOK = true;
+
+ if (x.responseXML != null)
+ checkXML(x.responseXML);
+
+ }
+ }
+
+ x.send()
+ }
+}
+
+
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/element.xml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/element.xml
new file mode 100644
index 0000000000..071ffae057
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/element.xml
@@ -0,0 +1 @@
+<root attr="value" attr2="value2"><person /><fruit /></root>
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders.qml
new file mode 100644
index 0000000000..686e7e5cf0
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders.qml
@@ -0,0 +1,66 @@
+import QtQuick 1.0
+
+QtObject {
+ property string url
+
+ property bool unsentException: false
+ property bool openedException: false
+
+ property bool readyState: false
+ property bool openedState: false
+
+ property bool headersReceivedState: false
+ property bool headersReceivedHeader: false
+
+ property bool doneState: false
+ property bool doneHeader: false
+
+ property bool dataOK: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+
+ try {
+ x.getResponseHeader("Test-Header");
+ } catch (e) {
+ if (e.code == DOMException.INVALID_STATE_ERR)
+ unsentException = true;
+ }
+
+ if (x.readyState == XMLHttpRequest.UNSENT)
+ readyState = true;
+
+ x.open("GET", url);
+ x.setRequestHeader("Accept-Language", "en-US");
+
+ if (x.readyState == XMLHttpRequest.OPENED)
+ openedState = true;
+
+ try {
+ x.getResponseHeader("Test-Header");
+ } catch (e) {
+ if (e.code == DOMException.INVALID_STATE_ERR)
+ openedException = true;
+ }
+
+ var headers = "connection: close\r\ncontent-type: text/html; charset=UTF-8\r\ntest-header: TestValue\r\nmultitest-header: TestValue, SecondTestValue\r\ncontent-length: 11";
+
+ // Test to the end
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.HEADERS_RECEIVED) {
+ headersReceivedState = true;
+
+ headersReceivedHeader = (x.getAllResponseHeaders() == headers);
+ } else if (x.readyState == XMLHttpRequest.DONE) {
+ doneState = headersReceivedState && true;
+
+ doneHeader = (x.getAllResponseHeaders() == headers);
+ dataOK = (x.responseText == "QML Rocks!\n");
+ }
+ }
+
+ x.send()
+ }
+}
+
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_args.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_args.qml
new file mode 100644
index 0000000000..e8b7b770c1
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_args.qml
@@ -0,0 +1,23 @@
+import QtQuick 1.0
+
+QtObject {
+ property bool exceptionThrown: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+
+ x.open("GET", "testdocument.html");
+ x.send();
+
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.DONE) {
+ try {
+ x.getAllResponseHeaders("Test-header");
+ } catch (e) {
+ if (e.code == DOMException.SYNTAX_ERR)
+ exceptionThrown = true;
+ }
+ }
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_sent.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_sent.qml
new file mode 100644
index 0000000000..1d4883ea7d
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_sent.qml
@@ -0,0 +1,20 @@
+import QtQuick 1.0
+
+QtObject {
+ property bool test: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+
+ x.open("GET", "testdocument.html");
+ x.send();
+
+ try {
+ x.getAllResponseHeaders();
+ } catch (e) {
+ if (e.code == DOMException.INVALID_STATE_ERR)
+ test = true;
+ }
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_unsent.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_unsent.qml
new file mode 100644
index 0000000000..360286d3e4
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_unsent.qml
@@ -0,0 +1,16 @@
+import QtQuick 1.0
+
+QtObject {
+ property bool test: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+
+ try {
+ x.getAllResponseHeaders();
+ } catch (e) {
+ if (e.code == DOMException.INVALID_STATE_ERR)
+ test = true;
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.expect
new file mode 100644
index 0000000000..c6cad7063b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.expect
@@ -0,0 +1,7 @@
+GET /testdocument.html HTTP/1.1
+ACCEPT-LANGUAGE: en-US
+Connection: Keep-Alive
+Accept-Encoding: gzip
+User-Agent: Mozilla/5.0
+Host: 127.0.0.1:14445
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.qml
new file mode 100644
index 0000000000..f37545e1e6
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.qml
@@ -0,0 +1,76 @@
+import QtQuick 1.0
+
+QtObject {
+ property string url
+
+ property bool unsentException: false
+ property bool openedException: false
+
+ property bool readyState: false
+ property bool openedState: false
+
+ property bool headersReceivedState: false
+ property bool headersReceivedNullHeader: false
+ property bool headersReceivedValidHeader: false
+ property bool headersReceivedMultiValidHeader: false
+ property bool headersReceivedCookieHeader: false
+
+ property bool doneState: false
+ property bool doneNullHeader: false
+ property bool doneValidHeader: false
+ property bool doneMultiValidHeader: false
+ property bool doneCookieHeader: false
+
+ property bool dataOK: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+
+ try {
+ x.getResponseHeader("Test-Header");
+ } catch (e) {
+ if (e.code == DOMException.INVALID_STATE_ERR)
+ unsentException = true;
+ }
+
+ if (x.readyState == XMLHttpRequest.UNSENT)
+ readyState = true;
+
+ x.open("GET", url);
+ x.setRequestHeader("Accept-Language", "en-US");
+
+ if (x.readyState == XMLHttpRequest.OPENED)
+ openedState = true;
+
+ try {
+ x.getResponseHeader("Test-Header");
+ } catch (e) {
+ if (e.code == DOMException.INVALID_STATE_ERR)
+ openedException = true;
+ }
+
+ // Test to the end
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.HEADERS_RECEIVED) {
+ headersReceivedState = true;
+
+ headersReceivedNullHeader = (x.getResponseHeader("Nonexistant-header") == "");
+ headersReceivedValidHeader = (x.getResponseHeader("Test-HEAder") == "TestValue");
+ headersReceivedMultiValidHeader = (x.getResponseHeader("MultiTest-HEAder") == "TestValue, SecondTestValue");
+ headersReceivedCookieHeader = (x.getResponseHeader("Set-Cookie") == "" && x.getResponseHeader("Set-Cookie2") == "");
+ } else if (x.readyState == XMLHttpRequest.DONE) {
+ doneState = headersReceivedState && true;
+
+ doneNullHeader = (x.getResponseHeader("Nonexistant-header") == "");
+ doneValidHeader = (x.getResponseHeader("Test-HEAder") == "TestValue");
+ doneMultiValidHeader = (x.getResponseHeader("MultiTest-HEAder") == "TestValue, SecondTestValue");
+ doneCookieHeader = (x.getResponseHeader("Set-Cookie") == "" && x.getResponseHeader("Set-Cookie2") == "");
+ dataOK = (x.responseText == "QML Rocks!\n");
+ }
+ }
+
+ x.send()
+ }
+}
+
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.reply b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.reply
new file mode 100644
index 0000000000..c4b4bb2763
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.reply
@@ -0,0 +1,8 @@
+HTTP/1.0 200 OK
+Connection: close
+Content-type: text/html; charset=UTF-8
+Test-Header: TestValue
+MultiTest-Header: TestValue
+MultiTest-Header: SecondTestValue
+Set-Cookie: mycook=Value
+Set-Cookie2: mycook=Value
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_args.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_args.qml
new file mode 100644
index 0000000000..61ce9c6f67
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_args.qml
@@ -0,0 +1,23 @@
+import QtQuick 1.0
+
+QtObject {
+ property bool exceptionThrown: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+
+ x.open("GET", "testdocument.html");
+ x.send();
+
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.DONE) {
+ try {
+ x.getResponseHeader();
+ } catch (e) {
+ if (e.code == DOMException.SYNTAX_ERR)
+ exceptionThrown = true;
+ }
+ }
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_sent.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_sent.qml
new file mode 100644
index 0000000000..7cd91a2a1f
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_sent.qml
@@ -0,0 +1,20 @@
+import QtQuick 1.0
+
+QtObject {
+ property bool test: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+
+ x.open("GET", "testdocument.html");
+ x.send();
+
+ try {
+ x.getResponseHeader("Test-header");
+ } catch (e) {
+ if (e.code == DOMException.INVALID_STATE_ERR)
+ test = true;
+ }
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_unsent.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_unsent.qml
new file mode 100644
index 0000000000..983ea1b82a
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_unsent.qml
@@ -0,0 +1,16 @@
+import QtQuick 1.0
+
+QtObject {
+ property bool test: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+
+ try {
+ x.getResponseHeader("Test-header");
+ } catch (e) {
+ if (e.code == DOMException.INVALID_STATE_ERR)
+ test = true;
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/instanceStateValues.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/instanceStateValues.qml
new file mode 100644
index 0000000000..79e06d483b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/instanceStateValues.qml
@@ -0,0 +1,33 @@
+import QtQuick 1.0
+
+QtObject {
+ property int unsent
+ property int opened
+ property int headers_received
+ property int loading
+ property int done
+
+ Component.onCompleted: {
+ // Attempt to overwrite and delete values
+ var x = new XMLHttpRequest();
+
+ x.UNSENT = 9;
+ x.OPENED = 9;
+ x.HEADERS_RECEIVED = 9;
+ x.LOADING = 9;
+ x.DONE = 9;
+
+ delete x.UNSENT;
+ delete x.OPENED;
+ delete x.HEADERS_RECEIVED;
+ delete x.LOADING;
+ delete x.DONE;
+
+ unsent = x.UNSENT
+ opened = x.OPENED
+ headers_received = x.HEADERS_RECEIVED
+ loading = x.LOADING
+ done = x.DONE
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/invalidMethodUsage.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/invalidMethodUsage.qml
new file mode 100644
index 0000000000..68f22f5f33
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/invalidMethodUsage.qml
@@ -0,0 +1,160 @@
+import QtQuick 1.0
+
+QtObject {
+ property bool onreadystatechange: false
+ property bool readyState: false
+ property bool status: false
+ property bool statusText: false
+ property bool responseText: false
+ property bool responseXML: false
+
+ property bool open: false
+ property bool setRequestHeader: false
+ property bool send: false
+ property bool abort: false
+ property bool getResponseHeader: false
+ property bool getAllResponseHeaders: false
+
+ Component.onCompleted: {
+ var o = 10;
+
+ try {
+ XMLHttpRequest.prototype.onreadystatechange
+ } catch (e) {
+ if (!(e instanceof ReferenceError))
+ return;
+
+ if (e.message != "Not an XMLHttpRequest object")
+ return;
+
+ onreadystatechange = true;
+ }
+ try {
+ XMLHttpRequest.prototype.readyState
+ } catch (e) {
+ if (!(e instanceof ReferenceError))
+ return;
+
+ if (e.message != "Not an XMLHttpRequest object")
+ return;
+
+ readyState = true;
+ }
+ try {
+ XMLHttpRequest.prototype.status
+ } catch (e) {
+ if (!(e instanceof ReferenceError))
+ return;
+
+ if (e.message != "Not an XMLHttpRequest object")
+ return;
+
+ status = true;
+ }
+ try {
+ XMLHttpRequest.prototype.statusText
+ } catch (e) {
+ if (!(e instanceof ReferenceError))
+ return;
+
+ if (e.message != "Not an XMLHttpRequest object")
+ return;
+
+ statusText = true;
+ }
+ try {
+ XMLHttpRequest.prototype.responseText
+ } catch (e) {
+ if (!(e instanceof ReferenceError))
+ return;
+
+ if (e.message != "Not an XMLHttpRequest object")
+ return;
+
+ responseText = true;
+ }
+ try {
+ XMLHttpRequest.prototype.responseXML
+ } catch (e) {
+ if (!(e instanceof ReferenceError))
+ return;
+
+ if (e.message != "Not an XMLHttpRequest object")
+ return;
+
+ responseXML = true;
+ }
+
+ try {
+ XMLHttpRequest.prototype.open.call(o);
+ } catch (e) {
+ if (!(e instanceof ReferenceError))
+ return;
+
+ if (e.message != "Not an XMLHttpRequest object")
+ return;
+
+ open = true;
+ }
+
+ try {
+ XMLHttpRequest.prototype.setRequestHeader.call(o);
+ } catch (e) {
+ if (!(e instanceof ReferenceError))
+ return;
+
+ if (e.message != "Not an XMLHttpRequest object")
+ return;
+
+ setRequestHeader = true;
+ }
+
+ try {
+ XMLHttpRequest.prototype.send.call(o);
+ } catch (e) {
+ if (!(e instanceof ReferenceError))
+ return;
+
+ if (e.message != "Not an XMLHttpRequest object")
+ return;
+
+ send = true;
+ }
+
+ try {
+ XMLHttpRequest.prototype.abort.call(o);
+ } catch (e) {
+ if (!(e instanceof ReferenceError))
+ return;
+
+ if (e.message != "Not an XMLHttpRequest object")
+ return;
+
+ abort = true;
+ }
+
+ try {
+ XMLHttpRequest.prototype.getResponseHeader.call(o);
+ } catch (e) {
+ if (!(e instanceof ReferenceError))
+ return;
+
+ if (e.message != "Not an XMLHttpRequest object")
+ return;
+
+ getResponseHeader = true;
+ }
+
+ try {
+ XMLHttpRequest.prototype.getAllResponseHeaders.call(o);
+ } catch (e) {
+ if (!(e instanceof ReferenceError))
+ return;
+
+ if (e.message != "Not an XMLHttpRequest object")
+ return;
+
+ getAllResponseHeaders = true;
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open.qml
new file mode 100644
index 0000000000..4bb5b1d657
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open.qml
@@ -0,0 +1,54 @@
+import QtQuick 1.0
+
+QtObject {
+ property string url
+
+ property bool readyState: false
+ property bool openedState: false
+
+ property bool status: false
+ property bool statusText: false
+ property bool responseText: false
+ property bool responseXML: false
+
+ property bool dataOK: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+
+ if (x.readyState == XMLHttpRequest.UNSENT)
+ readyState = true;
+
+ x.open("GET", url);
+ x.setRequestHeader("Accept-Language","en-US");
+
+ if (x.readyState == XMLHttpRequest.OPENED)
+ openedState = true;
+
+ try {
+ var a = x.status;
+ } catch (error) {
+ if (error.code == DOMException.INVALID_STATE_ERR)
+ status = true;
+ }
+ try {
+ var a = x.statusText;
+ } catch (error) {
+ if (error.code == DOMException.INVALID_STATE_ERR)
+ statusText = true;
+ }
+ responseText = (x.responseText == "");
+ responseXML = (x.responseXML == null);
+
+ // Test to the end
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.DONE) {
+ dataOK = (x.responseText == "QML Rocks!\n");
+ }
+ }
+
+
+ x.send()
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.1.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.1.qml
new file mode 100644
index 0000000000..da6eb14273
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.1.qml
@@ -0,0 +1,18 @@
+import QtQuick 1.0
+
+QtObject {
+ property bool exceptionThrown: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+
+ try {
+ x.open("GET");
+ } catch (e) {
+ if (e.code == DOMException.SYNTAX_ERR)
+ exceptionThrown = true;
+ }
+ }
+}
+
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.2.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.2.qml
new file mode 100644
index 0000000000..f003292703
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.2.qml
@@ -0,0 +1,18 @@
+import QtQuick 1.0
+
+QtObject {
+ property bool exceptionThrown: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+
+ try {
+ x.open("GET", "http://www.nokia.com", true, "user", "password", "extra");
+ } catch (e) {
+ if (e.code == DOMException.SYNTAX_ERR)
+ exceptionThrown = true;
+ }
+ }
+}
+
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_invalid_method.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_invalid_method.qml
new file mode 100644
index 0000000000..b87823d54c
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_invalid_method.qml
@@ -0,0 +1,16 @@
+import QtQuick 1.0
+
+QtObject {
+ property bool exceptionThrown: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+
+ try {
+ x.open("BLAH", "http://www.nokia.com");
+ } catch (e) {
+ if (e.code == DOMException.SYNTAX_ERR)
+ exceptionThrown = true;
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.expect
new file mode 100644
index 0000000000..c6cad7063b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.expect
@@ -0,0 +1,7 @@
+GET /testdocument.html HTTP/1.1
+ACCEPT-LANGUAGE: en-US
+Connection: Keep-Alive
+Accept-Encoding: gzip
+User-Agent: Mozilla/5.0
+Host: 127.0.0.1:14445
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.reply b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.reply
new file mode 100644
index 0000000000..7ae6951f9b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.reply
@@ -0,0 +1,3 @@
+HTTP/1.0 200 OK
+Connection: close
+Content-type: text/html; charset=UTF-8
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.wait b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.wait
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.wait
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_sync.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_sync.qml
new file mode 100644
index 0000000000..9f8f30982f
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_sync.qml
@@ -0,0 +1,17 @@
+import QtQuick 1.0
+
+QtObject {
+ property bool exceptionThrown: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+
+ try {
+ x.open("GET", "http://www.nokia.com", false);
+ } catch (e) {
+ if (e.code == DOMException.NOT_SUPPORTED_ERR)
+ exceptionThrown = true;
+ }
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_user.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_user.qml
new file mode 100644
index 0000000000..2bec344726
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_user.qml
@@ -0,0 +1,54 @@
+import QtQuick 1.0
+
+QtObject {
+ property string url
+
+ property bool readyState: false
+ property bool openedState: false
+
+ property bool status: false
+ property bool statusText: false
+ property bool responseText: false
+ property bool responseXML: false
+
+ property bool dataOK: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+
+ if (x.readyState == XMLHttpRequest.UNSENT)
+ readyState = true;
+
+ x.open("GET", url, true, "username", "password");
+ x.setRequestHeader("Accept-Language","en-US");
+
+ if (x.readyState == XMLHttpRequest.OPENED)
+ openedState = true;
+
+ try {
+ var a = x.status;
+ } catch (error) {
+ if (error.code == DOMException.INVALID_STATE_ERR)
+ status = true;
+ }
+ try {
+ var a = x.statusText;
+ } catch (error) {
+ if (error.code == DOMException.INVALID_STATE_ERR)
+ statusText = true;
+ }
+ responseText = (x.responseText == "");
+ responseXML = (x.responseXML == null);
+
+ // Test to the end
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.DONE) {
+ dataOK = (x.responseText == "QML Rocks!\n");
+ }
+ }
+
+
+ x.send()
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_username.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_username.qml
new file mode 100644
index 0000000000..70f2fa6227
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_username.qml
@@ -0,0 +1,54 @@
+import QtQuick 1.0
+
+QtObject {
+ property string url
+
+ property bool readyState: false
+ property bool openedState: false
+
+ property bool status: false
+ property bool statusText: false
+ property bool responseText: false
+ property bool responseXML: false
+
+ property bool dataOK: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+
+ if (x.readyState == XMLHttpRequest.UNSENT)
+ readyState = true;
+
+ x.open("GET", url, true, "sampleusername", "password");
+
+ if (x.readyState == XMLHttpRequest.OPENED)
+ openedState = true;
+
+ try {
+ var a = x.status;
+ } catch (error) {
+ if (error.code == DOMException.INVALID_STATE_ERR)
+ status = true;
+ }
+ try {
+ var a = x.statusText;
+ } catch (error) {
+ if (error.code == DOMException.INVALID_STATE_ERR)
+ statusText = true;
+ }
+ responseText = (x.responseText == "");
+ responseXML = (x.responseXML == null);
+
+ // Test to the end
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.DONE) {
+ dataOK = (x.responseText == "QML Rocks!\n");
+ }
+ }
+
+
+ x.send()
+ }
+}
+
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectError.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectError.qml
new file mode 100644
index 0000000000..f009ab78c0
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectError.qml
@@ -0,0 +1,23 @@
+import QtQuick 1.0
+
+QtObject {
+ property string url
+
+ property bool dataOK: false
+ property bool done: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+ x.open("GET", url);
+
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.DONE) {
+ done = true;
+ dataOK = x.status == 404;
+ }
+ }
+
+ x.send();
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectRecur.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectRecur.qml
new file mode 100644
index 0000000000..86337c436c
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectRecur.qml
@@ -0,0 +1,23 @@
+import QtQuick 1.0
+
+QtObject {
+ property string url
+
+ property bool dataOK: false
+ property bool done: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+ x.open("GET", url);
+
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.DONE) {
+ done = true;
+ dataOK = x.status == 302;
+ }
+ }
+
+ x.send();
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirects.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirects.qml
new file mode 100644
index 0000000000..cd125adf86
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirects.qml
@@ -0,0 +1,22 @@
+import QtQuick 1.0
+
+QtObject {
+ property string url
+
+ property bool dataOK: false
+ property bool done: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+ x.open("GET", url);
+
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.DONE) {
+ done = true;
+ dataOK = x.responseText == "Redirected\n";
+ }
+ }
+
+ x.send();
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirecttarget.html b/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirecttarget.html
new file mode 100644
index 0000000000..95f35e01c7
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirecttarget.html
@@ -0,0 +1 @@
+Redirected
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/responseText.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/responseText.qml
new file mode 100644
index 0000000000..da229f6216
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/responseText.qml
@@ -0,0 +1,54 @@
+import QtQuick 1.0
+
+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);
+ x.setRequestHeader("Accept-Language", "en-US");
+
+ 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);
+ x.setRequestHeader("Accept-Language", "en-US");
+
+ reset = (x.responseText == "");
+ }
+ }
+
+ x.send()
+
+ sent = (x.responseText == "");
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/responseXML_invalid.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/responseXML_invalid.qml
new file mode 100644
index 0000000000..393ff09a01
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/responseXML_invalid.qml
@@ -0,0 +1,24 @@
+import QtQuick 1.0
+
+QtObject {
+ property bool xmlNull: false
+ property bool dataOK: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+
+ x.open("GET", "testdocument.html");
+
+ // Test to the end
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.DONE) {
+ dataOK = (x.responseText == "QML Rocks!\n");
+ xmlNull = (x.responseXML == null);
+ }
+ }
+
+
+ x.send()
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/seconddocument.html b/tests/auto/declarative/qdeclarativexmlhttprequest/data/seconddocument.html
new file mode 100644
index 0000000000..a33f44bcb5
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/seconddocument.html
@@ -0,0 +1 @@
+This should not be read!
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_alreadySent.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_alreadySent.qml
new file mode 100644
index 0000000000..fd1c424786
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_alreadySent.qml
@@ -0,0 +1,28 @@
+import QtQuick 1.0
+
+QtObject {
+ property bool dataOK: false
+ property bool test: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+ x.open("GET", "testdocument.html");
+ x.setRequestHeader("Accept-Language","en-US");
+
+ // Test to the end
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.DONE) {
+ dataOK = (x.responseText == "QML Rocks!\n");
+ }
+ }
+
+ x.send();
+
+ try {
+ x.send()
+ } catch (e) {
+ if (e.code == DOMException.INVALID_STATE_ERR)
+ test = true;
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.expect
new file mode 100644
index 0000000000..2effbdcc9d
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.expect
@@ -0,0 +1,10 @@
+POST /testdocument.html HTTP/1.1
+ACCEPT-LANGUAGE: en-US
+Content-Type: text/plain;charset=UTF-8
+Content-Length: 12
+Connection: Keep-Alive
+Accept-Encoding: gzip
+User-Agent: Mozilla/5.0
+Host: 127.0.0.1:14445
+
+My Sent Data \ No newline at end of file
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.qml
new file mode 100644
index 0000000000..3dd851e591
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.qml
@@ -0,0 +1,22 @@
+import QtQuick 1.0
+
+QtObject {
+ property string url
+
+ property bool dataOK: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+ x.open("POST", url);
+ x.setRequestHeader("Accept-Language","en-US");
+
+ // Test to the end
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.DONE) {
+ dataOK = (x.responseText == "QML Rocks!\n");
+ }
+ }
+
+ x.send("My Sent Data");
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.2.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.2.qml
new file mode 100644
index 0000000000..fb1893627d
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.2.qml
@@ -0,0 +1,24 @@
+import QtQuick 1.0
+
+QtObject {
+ property string url
+
+ property bool dataOK: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+ x.open("POST", url);
+ x.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
+ x.setRequestHeader("Accept-Language","en-US");
+
+ // Test to the end
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.DONE) {
+ dataOK = (x.responseText == "QML Rocks!\n");
+ }
+ }
+
+ x.send("My Sent Data");
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.3.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.3.qml
new file mode 100644
index 0000000000..9f2383e066
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.3.qml
@@ -0,0 +1,24 @@
+import QtQuick 1.0
+
+QtObject {
+ property string url
+
+ property bool dataOK: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+ x.open("POST", url);
+ x.setRequestHeader("Content-Type", "text/plain;charset=latin1");
+ x.setRequestHeader("Accept-Language","en-US");
+
+ // Test to the end
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.DONE) {
+ dataOK = (x.responseText == "QML Rocks!\n");
+ }
+ }
+
+ x.send("My Sent Data");
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.expect
new file mode 100644
index 0000000000..83368607b8
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.expect
@@ -0,0 +1,10 @@
+POST /testdocument.html HTTP/1.1
+ACCEPT-LANGUAGE: en-US
+Content-Type: charset=UTF-8;text/plain
+Content-Length: 12
+Connection: Keep-Alive
+Accept-Encoding: gzip
+User-Agent: Mozilla/5.0
+Host: 127.0.0.1:14445
+
+My Sent Data \ No newline at end of file
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.qml
new file mode 100644
index 0000000000..410820e244
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.qml
@@ -0,0 +1,24 @@
+import QtQuick 1.0
+
+QtObject {
+ property string url
+
+ property bool dataOK: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+ x.open("POST", url);
+ x.setRequestHeader("Content-Type", "charset=UTF-8;text/plain");
+ x.setRequestHeader("Accept-Language","en-US");
+
+ // Test to the end
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.DONE) {
+ dataOK = (x.responseText == "QML Rocks!\n");
+ }
+ }
+
+ x.send("My Sent Data");
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.5.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.5.qml
new file mode 100644
index 0000000000..f56c51b8c3
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.5.qml
@@ -0,0 +1,24 @@
+import QtQuick 1.0
+
+QtObject {
+ property string url
+
+ property bool dataOK: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+ x.open("POST", url);
+ x.setRequestHeader("Content-Type", "charset=latin1;text/plain");
+ x.setRequestHeader("Accept-Language","en-US");
+
+ // Test to the end
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.DONE) {
+ dataOK = (x.responseText == "QML Rocks!\n");
+ }
+ }
+
+ x.send("My Sent Data");
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.expect
new file mode 100644
index 0000000000..4f10bbc696
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.expect
@@ -0,0 +1,10 @@
+PUT /testdocument.html HTTP/1.1
+ACCEPT-LANGUAGE: en-US
+Content-Type: text/plain;charset=UTF-8
+Content-Length: 12
+Connection: Keep-Alive
+Accept-Encoding: gzip
+User-Agent: Mozilla/5.0
+Host: 127.0.0.1:14445
+
+My Sent Data \ No newline at end of file
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.qml
new file mode 100644
index 0000000000..d44864ccee
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.qml
@@ -0,0 +1,22 @@
+import QtQuick 1.0
+
+QtObject {
+ property string url
+
+ property bool dataOK: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+ x.open("PUT", url);
+ x.setRequestHeader("Accept-Language","en-US");
+
+ // Test to the end
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.DONE) {
+ dataOK = (x.responseText == "QML Rocks!\n");
+ }
+ }
+
+ x.send("My Sent Data");
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.7.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.7.qml
new file mode 100644
index 0000000000..427d9f4312
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.7.qml
@@ -0,0 +1,24 @@
+import QtQuick 1.0
+
+QtObject {
+ property string url
+
+ property bool dataOK: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+ x.open("POST", url);
+ x.setRequestHeader("Content-Type", "text/plain");
+ x.setRequestHeader("Accept-Language","en-US");
+
+ // Test to the end
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.DONE) {
+ dataOK = (x.responseText == "QML Rocks!\n");
+ }
+ }
+
+ x.send("My Sent Data");
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.reply b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.reply
new file mode 100644
index 0000000000..7ae6951f9b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.reply
@@ -0,0 +1,3 @@
+HTTP/1.0 200 OK
+Connection: close
+Content-type: text/html; charset=UTF-8
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.qml
new file mode 100644
index 0000000000..c98555cd2f
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.qml
@@ -0,0 +1,27 @@
+import QtQuick 1.0
+
+QtObject {
+ property string reqType
+ property string url
+
+ property bool dataOK: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+ x.open(reqType, url);
+ x.setRequestHeader("Accept-Language","en-US");
+
+ // Test to the end
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.DONE) {
+ if (reqType == "HEAD")
+ dataOK = (x.responseText == "");
+ else
+ dataOK = (x.responseText == "QML Rocks!\n");
+ }
+ }
+
+ x.send("Data To Ignore");
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.reply b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.reply
new file mode 100644
index 0000000000..7ae6951f9b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.reply
@@ -0,0 +1,3 @@
+HTTP/1.0 200 OK
+Connection: close
+Content-type: text/html; charset=UTF-8
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_GET.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_GET.expect
new file mode 100644
index 0000000000..c6cad7063b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_GET.expect
@@ -0,0 +1,7 @@
+GET /testdocument.html HTTP/1.1
+ACCEPT-LANGUAGE: en-US
+Connection: Keep-Alive
+Accept-Encoding: gzip
+User-Agent: Mozilla/5.0
+Host: 127.0.0.1:14445
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_PUT.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_PUT.expect
new file mode 100644
index 0000000000..74a979817d
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_PUT.expect
@@ -0,0 +1,7 @@
+HEAD /testdocument.html HTTP/1.1
+ACCEPT-LANGUAGE: en-US
+Connection: Keep-Alive
+Accept-Encoding: gzip
+User-Agent: Mozilla/5.0
+Host: 127.0.0.1:14445
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_unsent.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_unsent.qml
new file mode 100644
index 0000000000..badd7296e8
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_unsent.qml
@@ -0,0 +1,16 @@
+import QtQuick 1.0
+
+QtObject {
+ property bool test: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+
+ try {
+ x.send();
+ } catch (e) {
+ if (e.code == DOMException.INVALID_STATE_ERR)
+ test = true;
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.expect
new file mode 100644
index 0000000000..7b8e260f1e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.expect
@@ -0,0 +1,9 @@
+GET /testdocument.html HTTP/1.1
+ACCEPT-LANGUAGE: en-US
+TEST-HEADER: value
+TEST-HEADER2: value,value2
+Connection: Keep-Alive
+Accept-Encoding: gzip
+User-Agent: Mozilla/5.0
+Host: 127.0.0.1:14445
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.qml
new file mode 100644
index 0000000000..5afab091a9
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.qml
@@ -0,0 +1,29 @@
+import QtQuick 1.0
+
+QtObject {
+ property string url
+
+ property bool dataOK: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+
+ x.open("GET", url);
+ x.setRequestHeader("Accept-Language","en-US");
+
+ x.setRequestHeader("Test-header", "value");
+ x.setRequestHeader("Test-header2", "value");
+ x.setRequestHeader("Test-header2", "value2");
+
+ // Test to the end
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.DONE) {
+ dataOK = (x.responseText == "QML Rocks!\n");
+ }
+ }
+
+ x.send();
+ }
+}
+
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.reply b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.reply
new file mode 100644
index 0000000000..7ae6951f9b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.reply
@@ -0,0 +1,3 @@
+HTTP/1.0 200 OK
+Connection: close
+Content-type: text/html; charset=UTF-8
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_args.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_args.qml
new file mode 100644
index 0000000000..4558f0e56a
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_args.qml
@@ -0,0 +1,18 @@
+import QtQuick 1.0
+
+QtObject {
+ property bool exceptionThrown: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+
+ x.open("GET", "testdocument.html");
+
+ try {
+ x.setRequestHeader("Test-header");
+ } catch (e) {
+ if (e.code == DOMException.SYNTAX_ERR)
+ exceptionThrown = true;
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_illegalName.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_illegalName.qml
new file mode 100644
index 0000000000..b15318c1e1
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_illegalName.qml
@@ -0,0 +1,58 @@
+import QtQuick 1.0
+
+QtObject {
+ property string url
+ property string header
+
+ property bool readyState: false
+ property bool openedState: false
+
+ property bool status: false
+ property bool statusText: false
+ property bool responseText: false
+ property bool responseXML: false
+
+ property bool dataOK: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+
+ if (x.readyState == XMLHttpRequest.UNSENT)
+ readyState = true;
+
+ x.open("GET", url);
+ x.setRequestHeader("Accept-Language","en-US");
+
+ x.setRequestHeader(header, "Value");
+
+ if (x.readyState == XMLHttpRequest.OPENED)
+ openedState = true;
+
+ try {
+ var a = x.status;
+ } catch (error) {
+ if (error.code == DOMException.INVALID_STATE_ERR)
+ status = true;
+ }
+ try {
+ var a = x.statusText;
+ } catch (error) {
+ if (error.code == DOMException.INVALID_STATE_ERR)
+ statusText = true;
+ }
+ responseText = (x.responseText == "");
+ responseXML = (x.responseXML == null);
+
+ // Test to the end
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.DONE) {
+ dataOK = (x.responseText == "QML Rocks!\n");
+ }
+ }
+
+
+ x.send()
+ }
+}
+
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_sent.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_sent.qml
new file mode 100644
index 0000000000..3b9a91e257
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_sent.qml
@@ -0,0 +1,32 @@
+import QtQuick 1.0
+
+QtObject {
+ property string url
+ property bool test: false
+
+ property bool dataOK: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+
+ x.open("GET", url);
+ x.setRequestHeader("Accept-Language","en-US");
+
+ // Test to the end
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.DONE) {
+ dataOK = (x.responseText == "QML Rocks!\n");
+ }
+ }
+
+ x.send();
+
+ try {
+ x.setRequestHeader("Test-header", "value");
+ } catch (e) {
+ if (e.code == DOMException.INVALID_STATE_ERR)
+ test = true;
+ }
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_unsent.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_unsent.qml
new file mode 100644
index 0000000000..327fa7fb43
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_unsent.qml
@@ -0,0 +1,17 @@
+import QtQuick 1.0
+
+QtObject {
+ property bool test: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+
+ try {
+ x.setRequestHeader("Test-header", "value");
+ } catch (e) {
+ if (e.code == DOMException.INVALID_STATE_ERR)
+ test = true;
+ }
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/staticStateValues.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/staticStateValues.qml
new file mode 100644
index 0000000000..bc22d877f5
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/staticStateValues.qml
@@ -0,0 +1,24 @@
+import QtQuick 1.0
+
+QtObject {
+ property int unsent: XMLHttpRequest.UNSENT
+ property int opened: XMLHttpRequest.OPENED
+ property int headers_received: XMLHttpRequest.HEADERS_RECEIVED
+ property int loading: XMLHttpRequest.LOADING
+ property int done: XMLHttpRequest.DONE
+
+ Component.onCompleted: {
+ // Attempt to overwrite and delete values
+ XMLHttpRequest.UNSENT = 9;
+ XMLHttpRequest.OPENED = 9;
+ XMLHttpRequest.HEADERS_RECEIVED = 9;
+ XMLHttpRequest.LOADING = 9;
+ XMLHttpRequest.DONE = 9;
+
+ delete XMLHttpRequest.UNSENT;
+ delete XMLHttpRequest.OPENED;
+ delete XMLHttpRequest.HEADERS_RECEIVED;
+ delete XMLHttpRequest.LOADING;
+ delete XMLHttpRequest.DONE;
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.200.reply b/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.200.reply
new file mode 100644
index 0000000000..7ae6951f9b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.200.reply
@@ -0,0 +1,3 @@
+HTTP/1.0 200 OK
+Connection: close
+Content-type: text/html; charset=UTF-8
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.404.reply b/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.404.reply
new file mode 100644
index 0000000000..2e29f56d41
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.404.reply
@@ -0,0 +1,3 @@
+HTTP/1.0 404 Document not found
+Connection: close
+Content-type: text/html; charset=UTF-8
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.expect b/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.expect
new file mode 100644
index 0000000000..c6cad7063b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.expect
@@ -0,0 +1,7 @@
+GET /testdocument.html HTTP/1.1
+ACCEPT-LANGUAGE: en-US
+Connection: Keep-Alive
+Accept-Encoding: gzip
+User-Agent: Mozilla/5.0
+Host: 127.0.0.1:14445
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.qml
new file mode 100644
index 0000000000..7aa08743ff
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.qml
@@ -0,0 +1,79 @@
+import QtQuick 1.0
+
+QtObject {
+ property string url
+ property int expectedStatus
+
+ property bool unsentException: false;
+ property bool openedException: false;
+ property bool sentException: false;
+
+ property bool headersReceived: false
+ property bool loading: false
+ property bool done: false
+
+ property bool resetException: false
+
+ property bool dataOK: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+
+ try {
+ var a = x.status;
+ } catch (e) {
+ if (e.code == DOMException.INVALID_STATE_ERR)
+ unsentException = true;
+ }
+
+ x.open("GET", url);
+ x.setRequestHeader("Accept-Language", "en-US");
+
+ try {
+ var a = x.status;
+ } catch (e) {
+ if (e.code == DOMException.INVALID_STATE_ERR)
+ openedException = true;
+ }
+
+ // Test to the end
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.HEADERS_RECEIVED) {
+ if (x.status == expectedStatus)
+ headersReceived = true;
+ } else if (x.readyState == XMLHttpRequest.LOADING) {
+ if (x.status == expectedStatus)
+ loading = true;
+ } else if (x.readyState == XMLHttpRequest.DONE) {
+ if (x.status == expectedStatus)
+ done = true;
+
+ if (expectedStatus == 404) {
+ dataOK = (x.responseText == "");
+ } else {
+ dataOK = (x.responseText == "QML Rocks!\n");
+ }
+
+ x.open("GET", url);
+ x.setRequestHeader("Accept-Language", "en-US");
+
+ try {
+ var a = x.status;
+ } catch (e) {
+ if (e.code == DOMException.INVALID_STATE_ERR)
+ resetException = true;
+ }
+
+ }
+ }
+
+ x.send()
+
+ try {
+ var a = x.status;
+ } catch (e) {
+ if (e.code == DOMException.INVALID_STATE_ERR)
+ sentException = true;
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/statusText.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/statusText.qml
new file mode 100644
index 0000000000..d42e0cca0a
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/statusText.qml
@@ -0,0 +1,79 @@
+import QtQuick 1.0
+
+QtObject {
+ property string url
+ property string expectedStatus
+
+ property bool unsentException: false;
+ property bool openedException: false;
+ property bool sentException: false;
+
+ property bool headersReceived: false
+ property bool loading: false
+ property bool done: false
+
+ property bool resetException: false
+
+ property bool dataOK: false
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+
+ try {
+ var a = x.statusText;
+ } catch (e) {
+ if (e.code == DOMException.INVALID_STATE_ERR)
+ unsentException = true;
+ }
+
+ x.open("GET", url);
+ x.setRequestHeader("Accept-Language", "en-US");
+
+ try {
+ var a = x.statusText;
+ } catch (e) {
+ if (e.code == DOMException.INVALID_STATE_ERR)
+ openedException = true;
+ }
+
+ // Test to the end
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.HEADERS_RECEIVED) {
+ if (x.statusText == expectedStatus)
+ headersReceived = true;
+ } else if (x.readyState == XMLHttpRequest.LOADING) {
+ if (x.statusText == expectedStatus)
+ loading = true;
+ } else if (x.readyState == XMLHttpRequest.DONE) {
+ if (x.statusText == expectedStatus)
+ done = true;
+
+ if (expectedStatus != "OK") {
+ dataOK = (x.responseText == "");
+ } else {
+ dataOK = (x.responseText == "QML Rocks!\n");
+ }
+
+ x.open("GET", url);
+ x.setRequestHeader("Accept-Language", "en-US");
+
+ try {
+ var a = x.statusText;
+ } catch (e) {
+ if (e.code == DOMException.INVALID_STATE_ERR)
+ resetException = true;
+ }
+
+ }
+ }
+
+ x.send()
+
+ try {
+ var a = x.statusText;
+ } catch (e) {
+ if (e.code == DOMException.INVALID_STATE_ERR)
+ sentException = true;
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/testdocument.html b/tests/auto/declarative/qdeclarativexmlhttprequest/data/testdocument.html
new file mode 100644
index 0000000000..8fe0f4b0e2
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/testdocument.html
@@ -0,0 +1 @@
+QML Rocks!
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/text.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/text.qml
new file mode 100644
index 0000000000..e8c8731240
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/text.qml
@@ -0,0 +1,129 @@
+import QtQuick 1.0
+
+QtObject {
+ property bool xmlTest: false
+ property bool dataOK: false
+
+ function checkText(text, whitespacetext)
+ {
+ if (text == null)
+ return;
+
+ if (text.nodeName != "#text")
+ return;
+
+ if (text.nodeValue != "Hello world!")
+ return;
+
+ if (text.nodeType != 3)
+ return;
+
+ if (text.parentNode.nodeName != "item")
+ return;
+
+ if (text.childNodes.length != 0)
+ return;
+
+ if (text.firstChild != null)
+ return;
+
+ if (text.lastChild != null)
+ return;
+
+ if (text.previousSibling != null)
+ return;
+
+ if (text.nextSibling != null)
+ return;
+
+ if (text.attributes != null)
+ return;
+
+ if (text.wholeText != "Hello world!")
+ return;
+
+ if (text.data != "Hello world!")
+ return;
+
+ if (text.length != 12)
+ return;
+
+ if (text.isElementContentWhitespace != false)
+ return;
+
+ if (whitespacetext.nodeName != "#text")
+ return;
+
+ if (whitespacetext.nodeValue != " ")
+ return;
+
+ if (whitespacetext.nodeType != 3)
+ return;
+
+ if (whitespacetext.parentNode.nodeName != "item")
+ return;
+
+ if (whitespacetext.childNodes.length != 0)
+ return;
+
+ if (whitespacetext.firstChild != null)
+ return;
+
+ if (whitespacetext.lastChild != null)
+ return;
+
+ if (whitespacetext.previousSibling != null)
+ return;
+
+ if (whitespacetext.nextSibling != null)
+ return;
+
+ if (whitespacetext.attributes != null)
+ return;
+
+ if (whitespacetext.wholeText != " ")
+ return;
+
+ if (whitespacetext.data != " ")
+ return;
+
+ if (whitespacetext.length != 3)
+ return;
+
+ if (whitespacetext.isElementContentWhitespace != true)
+ return;
+
+ xmlTest = true;
+ }
+
+ function checkXML(document)
+ {
+ checkText(document.documentElement.childNodes[0].childNodes[0],
+ document.documentElement.childNodes[1].childNodes[0]);
+
+ }
+
+ Component.onCompleted: {
+ var x = new XMLHttpRequest;
+
+ x.open("GET", "text.xml");
+
+ // Test to the end
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.DONE) {
+
+ dataOK = true;
+
+ if (x.responseXML != null)
+ checkXML(x.responseXML);
+
+ }
+ }
+
+ x.send()
+ }
+}
+
+
+
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/text.xml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/text.xml
new file mode 100644
index 0000000000..e7416888fd
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/text.xml
@@ -0,0 +1 @@
+<root><item>Hello world!</item><item> </item></root>
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.html b/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.html
new file mode 100644
index 0000000000..b640733f1e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.html
@@ -0,0 +1 @@
+უ Σ
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.qml
new file mode 100644
index 0000000000..0f9da30963
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.qml
@@ -0,0 +1,29 @@
+import QtQuick 1.0
+
+QtObject {
+ property bool dataOK: false
+
+ property string fileName
+ property string responseText
+ property string responseXmlRootNodeValue
+
+ function startRequest() {
+ var x = new XMLHttpRequest;
+
+ x.open("GET", fileName);
+
+ // Test to the end
+ x.onreadystatechange = function() {
+ if (x.readyState == XMLHttpRequest.DONE) {
+
+ responseText = x.responseText
+ if (x.responseXML)
+ responseXmlRootNodeValue = x.responseXML.documentElement.childNodes[0].nodeValue
+
+ dataOK = true;
+ }
+ }
+ x.send()
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.xml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.xml
new file mode 100644
index 0000000000..0fbb126ed8
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.xml
Binary files differ