diff options
Diffstat (limited to 'tests/auto/declarative/qmlxmlhttprequest')
81 files changed, 3657 insertions, 0 deletions
diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/abort.expect b/tests/auto/declarative/qmlxmlhttprequest/data/abort.expect new file mode 100644 index 0000000..f43e043 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/abort.expect @@ -0,0 +1,10 @@ +PUT /testdocument.html HTTP/1.1 +Content-Type: text/plain;charset=UTF-8 +Content-Length: 9 +Connection: Keep-Alive +Accept-Encoding: gzip +Accept-Language: en-US,* +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/qmlxmlhttprequest/data/abort.qml b/tests/auto/declarative/qmlxmlhttprequest/data/abort.qml new file mode 100644 index 0000000..d7b9266 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/abort.qml @@ -0,0 +1,42 @@ +import Qt 4.6 + +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.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.send("Test Data"); + } +} + + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/abort.reply b/tests/auto/declarative/qmlxmlhttprequest/data/abort.reply new file mode 100644 index 0000000..35b11f4 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/abort.reply @@ -0,0 +1,2 @@ +HTTP/1.0 200 OK +Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/abort_opened.qml b/tests/auto/declarative/qmlxmlhttprequest/data/abort_opened.qml new file mode 100644 index 0000000..72a45e7 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/abort_opened.qml @@ -0,0 +1,58 @@ +import Qt 4.6 + +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.abort(); + + x.open("GET", url); + + 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/qmlxmlhttprequest/data/abort_unsent.qml b/tests/auto/declarative/qmlxmlhttprequest/data/abort_unsent.qml new file mode 100644 index 0000000..aa78cde --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/abort_unsent.qml @@ -0,0 +1,54 @@ +import Qt 4.6 + +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); + + 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/qmlxmlhttprequest/data/attr.qml b/tests/auto/declarative/qmlxmlhttprequest/data/attr.qml new file mode 100644 index 0000000..9049fc7 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/attr.qml @@ -0,0 +1,80 @@ +import Qt 4.6 + +QtObject { + property bool xmlTest: false + property bool dataOK: false + + Script { + 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/qmlxmlhttprequest/data/attr.xml b/tests/auto/declarative/qmlxmlhttprequest/data/attr.xml new file mode 100644 index 0000000..2aa64a3 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/attr.xml @@ -0,0 +1 @@ +<root attr="myvalue" /> diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/callbackException.qml b/tests/auto/declarative/qmlxmlhttprequest/data/callbackException.qml new file mode 100644 index 0000000..9255922 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/callbackException.qml @@ -0,0 +1,25 @@ +import Qt 4.6 + +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/qmlxmlhttprequest/data/cdata.qml b/tests/auto/declarative/qmlxmlhttprequest/data/cdata.qml new file mode 100644 index 0000000..b2d0209 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/cdata.qml @@ -0,0 +1,135 @@ +import Qt 4.6 + +QtObject { + property bool xmlTest: false + property bool dataOK: false + + Script { + 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/qmlxmlhttprequest/data/cdata.xml b/tests/auto/declarative/qmlxmlhttprequest/data/cdata.xml new file mode 100644 index 0000000..061d37c --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/cdata.xml @@ -0,0 +1,2 @@ +<root><item><![CDATA[Hello world!]]></item><item><![CDATA[ ]]></item></root> + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/constructor.qml b/tests/auto/declarative/qmlxmlhttprequest/data/constructor.qml new file mode 100644 index 0000000..93e44fd --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/constructor.qml @@ -0,0 +1,14 @@ +import Qt 4.6 + +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/qmlxmlhttprequest/data/defaultState.qml b/tests/auto/declarative/qmlxmlhttprequest/data/defaultState.qml new file mode 100644 index 0000000..4dcf6f9 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/defaultState.qml @@ -0,0 +1,30 @@ +import Qt 4.6 + +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/qmlxmlhttprequest/data/document.qml b/tests/auto/declarative/qmlxmlhttprequest/data/document.qml new file mode 100644 index 0000000..e372361 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/document.qml @@ -0,0 +1,58 @@ +import Qt 4.6 + +QtObject { + property bool xmlTest: false + property bool dataOK: false + + Script { + 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/qmlxmlhttprequest/data/document.xml b/tests/auto/declarative/qmlxmlhttprequest/data/document.xml new file mode 100644 index 0000000..fb693ea --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/document.xml @@ -0,0 +1,3 @@ +<?xml version="1.0" encoding="UTF-8" standalone='yes'?> +<root> +</root> diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/domExceptionCodes.qml b/tests/auto/declarative/qmlxmlhttprequest/data/domExceptionCodes.qml new file mode 100644 index 0000000..de5ee4f --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/domExceptionCodes.qml @@ -0,0 +1,60 @@ +import Qt 4.6 + +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/qmlxmlhttprequest/data/element.qml b/tests/auto/declarative/qmlxmlhttprequest/data/element.qml new file mode 100644 index 0000000..78c0374 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/element.qml @@ -0,0 +1,147 @@ +import Qt 4.6 + +QtObject { + property bool xmlTest: false + property bool dataOK: false + + Script { + 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/qmlxmlhttprequest/data/element.xml b/tests/auto/declarative/qmlxmlhttprequest/data/element.xml new file mode 100644 index 0000000..071ffae --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/element.xml @@ -0,0 +1 @@ +<root attr="value" attr2="value2"><person /><fruit /></root> diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders.qml b/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders.qml new file mode 100644 index 0000000..02a8083 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders.qml @@ -0,0 +1,65 @@ +import Qt 4.6 + +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); + + 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 = "content-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/qmlxmlhttprequest/data/getAllResponseHeaders_args.qml b/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders_args.qml new file mode 100644 index 0000000..37124c7 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders_args.qml @@ -0,0 +1,23 @@ +import Qt 4.6 + +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/qmlxmlhttprequest/data/getAllResponseHeaders_sent.qml b/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders_sent.qml new file mode 100644 index 0000000..505e4b1 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders_sent.qml @@ -0,0 +1,20 @@ +import Qt 4.6 + +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/qmlxmlhttprequest/data/getAllResponseHeaders_unsent.qml b/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders_unsent.qml new file mode 100644 index 0000000..20fb040 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders_unsent.qml @@ -0,0 +1,16 @@ +import Qt 4.6 + +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/qmlxmlhttprequest/data/getResponseHeader.expect b/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.expect new file mode 100644 index 0000000..a740c79 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.expect @@ -0,0 +1,7 @@ +GET /testdocument.html HTTP/1.1 +Connection: Keep-Alive +Accept-Encoding: gzip +Accept-Language: en-US,* +User-Agent: Mozilla/5.0 +Host: 127.0.0.1:14445 + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.qml b/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.qml new file mode 100644 index 0000000..2f949e1 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.qml @@ -0,0 +1,75 @@ +import Qt 4.6 + +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); + + 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/qmlxmlhttprequest/data/getResponseHeader.reply b/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.reply new file mode 100644 index 0000000..62ec67b --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.reply @@ -0,0 +1,7 @@ +HTTP/1.0 200 OK +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/qmlxmlhttprequest/data/getResponseHeader_args.qml b/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader_args.qml new file mode 100644 index 0000000..d5aa4b1 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader_args.qml @@ -0,0 +1,23 @@ +import Qt 4.6 + +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/qmlxmlhttprequest/data/getResponseHeader_sent.qml b/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader_sent.qml new file mode 100644 index 0000000..7538ffd --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader_sent.qml @@ -0,0 +1,20 @@ +import Qt 4.6 + +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/qmlxmlhttprequest/data/getResponseHeader_unsent.qml b/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader_unsent.qml new file mode 100644 index 0000000..3b55802 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader_unsent.qml @@ -0,0 +1,16 @@ +import Qt 4.6 + +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/qmlxmlhttprequest/data/instanceStateValues.qml b/tests/auto/declarative/qmlxmlhttprequest/data/instanceStateValues.qml new file mode 100644 index 0000000..b8d01c4 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/instanceStateValues.qml @@ -0,0 +1,33 @@ +import Qt 4.6 + +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/qmlxmlhttprequest/data/invalidMethodUsage.qml b/tests/auto/declarative/qmlxmlhttprequest/data/invalidMethodUsage.qml new file mode 100644 index 0000000..b30989b --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/invalidMethodUsage.qml @@ -0,0 +1,160 @@ +import Qt 4.6 + +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/qmlxmlhttprequest/data/open.qml b/tests/auto/declarative/qmlxmlhttprequest/data/open.qml new file mode 100644 index 0000000..c06bae3 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/open.qml @@ -0,0 +1,53 @@ +import Qt 4.6 + +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); + + 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/qmlxmlhttprequest/data/open_arg_count.1.qml b/tests/auto/declarative/qmlxmlhttprequest/data/open_arg_count.1.qml new file mode 100644 index 0000000..b6d4c32 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/open_arg_count.1.qml @@ -0,0 +1,18 @@ +import Qt 4.6 + +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/qmlxmlhttprequest/data/open_arg_count.2.qml b/tests/auto/declarative/qmlxmlhttprequest/data/open_arg_count.2.qml new file mode 100644 index 0000000..8c86c20 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/open_arg_count.2.qml @@ -0,0 +1,18 @@ +import Qt 4.6 + +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/qmlxmlhttprequest/data/open_invalid_method.qml b/tests/auto/declarative/qmlxmlhttprequest/data/open_invalid_method.qml new file mode 100644 index 0000000..69f79ae --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/open_invalid_method.qml @@ -0,0 +1,16 @@ +import Qt 4.6 + +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/qmlxmlhttprequest/data/open_network.expect b/tests/auto/declarative/qmlxmlhttprequest/data/open_network.expect new file mode 100644 index 0000000..a740c79 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/open_network.expect @@ -0,0 +1,7 @@ +GET /testdocument.html HTTP/1.1 +Connection: Keep-Alive +Accept-Encoding: gzip +Accept-Language: en-US,* +User-Agent: Mozilla/5.0 +Host: 127.0.0.1:14445 + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/open_network.reply b/tests/auto/declarative/qmlxmlhttprequest/data/open_network.reply new file mode 100644 index 0000000..35b11f4 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/open_network.reply @@ -0,0 +1,2 @@ +HTTP/1.0 200 OK +Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/open_network.wait b/tests/auto/declarative/qmlxmlhttprequest/data/open_network.wait new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/open_network.wait diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/open_sync.qml b/tests/auto/declarative/qmlxmlhttprequest/data/open_sync.qml new file mode 100644 index 0000000..1477279 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/open_sync.qml @@ -0,0 +1,17 @@ +import Qt 4.6 + +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/qmlxmlhttprequest/data/open_user.qml b/tests/auto/declarative/qmlxmlhttprequest/data/open_user.qml new file mode 100644 index 0000000..19e37fa --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/open_user.qml @@ -0,0 +1,53 @@ +import Qt 4.6 + +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"); + + 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/qmlxmlhttprequest/data/open_username.qml b/tests/auto/declarative/qmlxmlhttprequest/data/open_username.qml new file mode 100644 index 0000000..983ea14 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/open_username.qml @@ -0,0 +1,54 @@ +import Qt 4.6 + +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/qmlxmlhttprequest/data/redirectError.qml b/tests/auto/declarative/qmlxmlhttprequest/data/redirectError.qml new file mode 100644 index 0000000..6b345cc --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/redirectError.qml @@ -0,0 +1,23 @@ +import Qt 4.6 + +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/qmlxmlhttprequest/data/redirectRecur.qml b/tests/auto/declarative/qmlxmlhttprequest/data/redirectRecur.qml new file mode 100644 index 0000000..c0321dc --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/redirectRecur.qml @@ -0,0 +1,23 @@ +import Qt 4.6 + +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/qmlxmlhttprequest/data/redirects.qml b/tests/auto/declarative/qmlxmlhttprequest/data/redirects.qml new file mode 100644 index 0000000..f6fabdb --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/redirects.qml @@ -0,0 +1,22 @@ +import Qt 4.6 + +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/qmlxmlhttprequest/data/redirecttarget.html b/tests/auto/declarative/qmlxmlhttprequest/data/redirecttarget.html new file mode 100644 index 0000000..95f35e0 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/redirecttarget.html @@ -0,0 +1 @@ +Redirected diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/responseText.qml b/tests/auto/declarative/qmlxmlhttprequest/data/responseText.qml new file mode 100644 index 0000000..4bb3a7a --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/responseText.qml @@ -0,0 +1,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 == ""); + } +} + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/responseXML_invalid.qml b/tests/auto/declarative/qmlxmlhttprequest/data/responseXML_invalid.qml new file mode 100644 index 0000000..63f288e --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/responseXML_invalid.qml @@ -0,0 +1,24 @@ +import Qt 4.6 + +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/qmlxmlhttprequest/data/seconddocument.html b/tests/auto/declarative/qmlxmlhttprequest/data/seconddocument.html new file mode 100644 index 0000000..a33f44b --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/seconddocument.html @@ -0,0 +1 @@ +This should not be read! diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_alreadySent.qml b/tests/auto/declarative/qmlxmlhttprequest/data/send_alreadySent.qml new file mode 100644 index 0000000..0bad7df --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_alreadySent.qml @@ -0,0 +1,27 @@ +import Qt 4.6 + +QtObject { + property bool dataOK: false + property bool test: 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"); + } + } + + x.send(); + + try { + x.send() + } catch (e) { + if (e.code == DOMException.INVALID_STATE_ERR) + test = true; + } + } +} diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.1.expect b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.1.expect new file mode 100644 index 0000000..81dd4a0 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.1.expect @@ -0,0 +1,10 @@ +POST /testdocument.html HTTP/1.1 +Content-Type: text/plain;charset=UTF-8 +Content-Length: 12 +Connection: Keep-Alive +Accept-Encoding: gzip +Accept-Language: en-US,* +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/qmlxmlhttprequest/data/send_data.1.qml b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.1.qml new file mode 100644 index 0000000..03543a9 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.1.qml @@ -0,0 +1,21 @@ +import Qt 4.6 + +QtObject { + property string url + + property bool dataOK: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + x.open("POST", url); + + // 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/qmlxmlhttprequest/data/send_data.2.qml b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.2.qml new file mode 100644 index 0000000..79a27b6 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.2.qml @@ -0,0 +1,23 @@ +import Qt 4.6 + +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"); + + // 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/qmlxmlhttprequest/data/send_data.3.qml b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.3.qml new file mode 100644 index 0000000..e048769 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.3.qml @@ -0,0 +1,23 @@ +import Qt 4.6 + +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"); + + // 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/qmlxmlhttprequest/data/send_data.4.expect b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.4.expect new file mode 100644 index 0000000..8fcf3ac --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.4.expect @@ -0,0 +1,10 @@ +POST /testdocument.html HTTP/1.1 +Content-Type: charset=UTF-8;text/plain +Content-Length: 12 +Connection: Keep-Alive +Accept-Encoding: gzip +Accept-Language: en-US,* +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/qmlxmlhttprequest/data/send_data.4.qml b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.4.qml new file mode 100644 index 0000000..7ab0b27 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.4.qml @@ -0,0 +1,23 @@ +import Qt 4.6 + +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"); + + // 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/qmlxmlhttprequest/data/send_data.5.qml b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.5.qml new file mode 100644 index 0000000..29bf2c2 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.5.qml @@ -0,0 +1,23 @@ +import Qt 4.6 + +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"); + + // 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/qmlxmlhttprequest/data/send_data.6.expect b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.6.expect new file mode 100644 index 0000000..97e6fac --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.6.expect @@ -0,0 +1,10 @@ +PUT /testdocument.html HTTP/1.1 +Content-Type: text/plain;charset=UTF-8 +Content-Length: 12 +Connection: Keep-Alive +Accept-Encoding: gzip +Accept-Language: en-US,* +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/qmlxmlhttprequest/data/send_data.6.qml b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.6.qml new file mode 100644 index 0000000..135f45c --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.6.qml @@ -0,0 +1,21 @@ +import Qt 4.6 + +QtObject { + property string url + + property bool dataOK: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + x.open("PUT", url); + + // 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/qmlxmlhttprequest/data/send_data.7.qml b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.7.qml new file mode 100644 index 0000000..4a09527 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.7.qml @@ -0,0 +1,23 @@ +import Qt 4.6 + +QtObject { + property string url + + property bool dataOK: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + x.open("POST", url); + x.setRequestHeader("Content-Type", "text/plain"); + + // 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/qmlxmlhttprequest/data/send_data.reply b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.reply new file mode 100644 index 0000000..35b11f4 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.reply @@ -0,0 +1,2 @@ +HTTP/1.0 200 OK +Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.qml b/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.qml new file mode 100644 index 0000000..dd5fa46 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.qml @@ -0,0 +1,26 @@ +import Qt 4.6 + +QtObject { + property string reqType + property string url + + property bool dataOK: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + x.open(reqType, url); + + // 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/qmlxmlhttprequest/data/send_ignoreData.reply b/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.reply new file mode 100644 index 0000000..35b11f4 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.reply @@ -0,0 +1,2 @@ +HTTP/1.0 200 OK +Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData_GET.expect b/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData_GET.expect new file mode 100644 index 0000000..a740c79 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData_GET.expect @@ -0,0 +1,7 @@ +GET /testdocument.html HTTP/1.1 +Connection: Keep-Alive +Accept-Encoding: gzip +Accept-Language: en-US,* +User-Agent: Mozilla/5.0 +Host: 127.0.0.1:14445 + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData_PUT.expect b/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData_PUT.expect new file mode 100644 index 0000000..991bd59 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData_PUT.expect @@ -0,0 +1,7 @@ +HEAD /testdocument.html HTTP/1.1 +Connection: Keep-Alive +Accept-Encoding: gzip +Accept-Language: en-US,* +User-Agent: Mozilla/5.0 +Host: 127.0.0.1:14445 + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_unsent.qml b/tests/auto/declarative/qmlxmlhttprequest/data/send_unsent.qml new file mode 100644 index 0000000..7f51ecf --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_unsent.qml @@ -0,0 +1,16 @@ +import Qt 4.6 + +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/qmlxmlhttprequest/data/setRequestHeader.expect b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.expect new file mode 100644 index 0000000..4600f2a --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.expect @@ -0,0 +1,9 @@ +GET /testdocument.html HTTP/1.1 +TEST-HEADER: value +TEST-HEADER2: value,value2 +Connection: Keep-Alive +Accept-Encoding: gzip +Accept-Language: en-US,* +User-Agent: Mozilla/5.0 +Host: 127.0.0.1:14445 + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.qml b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.qml new file mode 100644 index 0000000..b0723aa --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.qml @@ -0,0 +1,28 @@ +import Qt 4.6 + +QtObject { + property string url + + property bool dataOK: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + + x.open("GET", url); + + 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/qmlxmlhttprequest/data/setRequestHeader.reply b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.reply new file mode 100644 index 0000000..35b11f4 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.reply @@ -0,0 +1,2 @@ +HTTP/1.0 200 OK +Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_args.qml b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_args.qml new file mode 100644 index 0000000..8305ae1 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_args.qml @@ -0,0 +1,18 @@ +import Qt 4.6 + +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/qmlxmlhttprequest/data/setRequestHeader_illegalName.qml b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_illegalName.qml new file mode 100644 index 0000000..bf31eca --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_illegalName.qml @@ -0,0 +1,57 @@ +import Qt 4.6 + +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(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/qmlxmlhttprequest/data/setRequestHeader_sent.qml b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_sent.qml new file mode 100644 index 0000000..c2bbc6e --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_sent.qml @@ -0,0 +1,31 @@ +import Qt 4.6 + +QtObject { + property string url + property bool test: false + + property bool dataOK: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + + x.open("GET", url); + + // 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/qmlxmlhttprequest/data/setRequestHeader_unsent.qml b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_unsent.qml new file mode 100644 index 0000000..30bc93e --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_unsent.qml @@ -0,0 +1,17 @@ +import Qt 4.6 + +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/qmlxmlhttprequest/data/staticStateValues.qml b/tests/auto/declarative/qmlxmlhttprequest/data/staticStateValues.qml new file mode 100644 index 0000000..ec1c5d8 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/staticStateValues.qml @@ -0,0 +1,24 @@ +import Qt 4.6 + +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/qmlxmlhttprequest/data/status.200.reply b/tests/auto/declarative/qmlxmlhttprequest/data/status.200.reply new file mode 100644 index 0000000..35b11f4 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/status.200.reply @@ -0,0 +1,2 @@ +HTTP/1.0 200 OK +Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/status.404.reply b/tests/auto/declarative/qmlxmlhttprequest/data/status.404.reply new file mode 100644 index 0000000..964a7a8 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/status.404.reply @@ -0,0 +1,2 @@ +HTTP/1.0 404 Document not found +Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/status.expect b/tests/auto/declarative/qmlxmlhttprequest/data/status.expect new file mode 100644 index 0000000..a740c79 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/status.expect @@ -0,0 +1,7 @@ +GET /testdocument.html HTTP/1.1 +Connection: Keep-Alive +Accept-Encoding: gzip +Accept-Language: en-US,* +User-Agent: Mozilla/5.0 +Host: 127.0.0.1:14445 + diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/status.qml b/tests/auto/declarative/qmlxmlhttprequest/data/status.qml new file mode 100644 index 0000000..04202c4 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/status.qml @@ -0,0 +1,77 @@ +import Qt 4.6 + +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); + + 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); + + 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/qmlxmlhttprequest/data/statusText.qml b/tests/auto/declarative/qmlxmlhttprequest/data/statusText.qml new file mode 100644 index 0000000..8becc3b --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/statusText.qml @@ -0,0 +1,77 @@ +import Qt 4.6 + +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); + + 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); + + 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/qmlxmlhttprequest/data/testdocument.html b/tests/auto/declarative/qmlxmlhttprequest/data/testdocument.html new file mode 100644 index 0000000..8fe0f4b --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/testdocument.html @@ -0,0 +1 @@ +QML Rocks! diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/text.qml b/tests/auto/declarative/qmlxmlhttprequest/data/text.qml new file mode 100644 index 0000000..4615a07 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/text.qml @@ -0,0 +1,131 @@ +import Qt 4.6 + +QtObject { + property bool xmlTest: false + property bool dataOK: false + + Script { + 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/qmlxmlhttprequest/data/text.xml b/tests/auto/declarative/qmlxmlhttprequest/data/text.xml new file mode 100644 index 0000000..e741688 --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/data/text.xml @@ -0,0 +1 @@ +<root><item>Hello world!</item><item> </item></root> diff --git a/tests/auto/declarative/qmlxmlhttprequest/qmlxmlhttprequest.pro b/tests/auto/declarative/qmlxmlhttprequest/qmlxmlhttprequest.pro new file mode 100644 index 0000000..ed87b2a --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/qmlxmlhttprequest.pro @@ -0,0 +1,13 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative network +macx:CONFIG -= app_bundle + +INCLUDEPATH += ../shared/ +HEADERS += ../shared/testhttpserver.h + +SOURCES += tst_qmlxmlhttprequest.cpp \ + ../shared/testhttpserver.cpp + + +# Define SRCDIR equal to test's source directory +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qmlxmlhttprequest/tst_qmlxmlhttprequest.cpp b/tests/auto/declarative/qmlxmlhttprequest/tst_qmlxmlhttprequest.cpp new file mode 100644 index 0000000..df5442c --- /dev/null +++ b/tests/auto/declarative/qmlxmlhttprequest/tst_qmlxmlhttprequest.cpp @@ -0,0 +1,1315 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <qtest.h> +#include <QmlEngine> +#include <QmlComponent> +#include <QDebug> +#include <QNetworkCookieJar> +#include "testhttpserver.h" + +#define SERVER_PORT 14445 + +class tst_xmlhttprequest : public QObject +{ + Q_OBJECT +public: + tst_xmlhttprequest() {} + +private slots: + void initTestCase() { + if (QLocale::system().name().replace(QChar::fromAscii('_'),QChar::fromAscii('-')) != QLatin1String("en-US")) { + qWarning() << "Test will fail unless LANG is en_US"; + } + } + + void domExceptionCodes(); + void callbackException(); + void callbackException_data(); + void staticStateValues(); + void instanceStateValues(); + void constructor(); + void defaultState(); + void open(); + void open_invalid_method(); + void open_sync(); + void open_arg_count(); + void setRequestHeader(); + void setRequestHeader_unsent(); + void setRequestHeader_illegalName_data(); + void setRequestHeader_illegalName(); + void setRequestHeader_sent(); + void setRequestHeader_args(); + void send_unsent(); + void send_alreadySent(); + void send_ignoreData(); + void send_withdata(); + void abort(); + void abort_unsent(); + void abort_opened(); + void getResponseHeader(); + void getResponseHeader_unsent(); + void getResponseHeader_sent(); + void getResponseHeader_args(); + void getAllResponseHeaders(); + void getAllResponseHeaders_unsent(); + void getAllResponseHeaders_sent(); + void getAllResponseHeaders_args(); + void status(); + void statusText(); + void responseText(); + void responseXML_invalid(); + void invalidMethodUsage(); + void redirects(); + + // Attributes + void document(); + void element(); + void attr(); + void text(); + void cdata(); + + // Crashes + // void outstanding_request_at_shutdown(); + + // void network_errors() + // void readyState() + +private: + QmlEngine engine; +}; + +inline QUrl TEST_FILE(const QString &filename) +{ + return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); +} + +// Test that the dom exception codes are correct +void tst_xmlhttprequest::domExceptionCodes() +{ + QmlComponent component(&engine, TEST_FILE("domExceptionCodes.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("index_size_err").toInt(), 1); + QCOMPARE(object->property("domstring_size_err").toInt(), 2); + QCOMPARE(object->property("hierarchy_request_err").toInt(), 3); + QCOMPARE(object->property("wrong_document_err").toInt(), 4); + QCOMPARE(object->property("invalid_character_err").toInt(), 5); + QCOMPARE(object->property("no_data_allowed_err").toInt(), 6); + QCOMPARE(object->property("no_modification_allowed_err").toInt(), 7); + QCOMPARE(object->property("not_found_err").toInt(), 8); + QCOMPARE(object->property("not_supported_err").toInt(), 9); + QCOMPARE(object->property("inuse_attribute_err").toInt(), 10); + QCOMPARE(object->property("invalid_state_err").toInt(), 11); + QCOMPARE(object->property("syntax_err").toInt(), 12); + QCOMPARE(object->property("invalid_modification_err").toInt(), 13); + QCOMPARE(object->property("namespace_err").toInt(), 14); + QCOMPARE(object->property("invalid_access_err").toInt(), 15); + QCOMPARE(object->property("validation_err").toInt(), 16); + QCOMPARE(object->property("type_mismatch_err").toInt(), 17); + + delete object; +} + +#define TRY_WAIT(expr) \ + do { \ + for (int ii = 0; ii < 6; ++ii) { \ + if ((expr)) break; \ + QTest::qWait(50); \ + } \ + QVERIFY((expr)); \ + } while (false) + + +void tst_xmlhttprequest::callbackException_data() +{ + QTest::addColumn<QString>("which"); + QTest::addColumn<int>("line"); + + QTest::newRow("on-opened") << "1" << 15; + QTest::newRow("on-loading") << "3" << 15; + QTest::newRow("on-done") << "4" << 15; +} + +void tst_xmlhttprequest::callbackException() +{ + // Test exception reporting for exceptions thrown at various points. + + QFETCH(QString, which); + QFETCH(int, line); + + QString expect = TEST_FILE("callbackException.qml").toString() + ":"+QString::number(line)+": Error: Exception from Callback"; + QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); + + QmlComponent component(&engine, TEST_FILE("callbackException.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "testdocument.html"); + object->setProperty("which", which); + component.completeCreate(); + + TRY_WAIT(object->property("threw").toBool() == true); + + delete object; +} + +// Test that the state value properties on the XMLHttpRequest constructor have the correct values. +// ### WebKit does not do this, but it seems to fit the standard and QML better +void tst_xmlhttprequest::staticStateValues() +{ + QmlComponent component(&engine, TEST_FILE("staticStateValues.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("unsent").toInt(), 0); + QCOMPARE(object->property("opened").toInt(), 1); + QCOMPARE(object->property("headers_received").toInt(), 2); + QCOMPARE(object->property("loading").toInt(), 3); + QCOMPARE(object->property("done").toInt(), 4); + + delete object; +} + +// Test that the state value properties on instances have the correct values. +void tst_xmlhttprequest::instanceStateValues() +{ + QmlComponent component(&engine, TEST_FILE("instanceStateValues.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("unsent").toInt(), 0); + QCOMPARE(object->property("opened").toInt(), 1); + QCOMPARE(object->property("headers_received").toInt(), 2); + QCOMPARE(object->property("loading").toInt(), 3); + QCOMPARE(object->property("done").toInt(), 4); + + delete object; +} + +// Test calling constructor +void tst_xmlhttprequest::constructor() +{ + QmlComponent component(&engine, TEST_FILE("constructor.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("calledAsConstructor").toBool(), true); + QCOMPARE(object->property("calledAsFunction").toBool(), true); + + delete object; +} + +// Test that all the properties are set correctly before any request is sent +void tst_xmlhttprequest::defaultState() +{ + QmlComponent component(&engine, TEST_FILE("defaultState.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("readState").toInt(), 0); + QCOMPARE(object->property("statusIsException").toBool(), true); + QCOMPARE(object->property("statusTextIsException").toBool(), true); + QCOMPARE(object->property("responseText").toString(), QString()); + QCOMPARE(object->property("responseXMLIsNull").toBool(), true); + + delete object; +} + +// Test valid XMLHttpRequest.open() calls +void tst_xmlhttprequest::open() +{ + // Relative url + { + QmlComponent component(&engine, TEST_FILE("open.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "testdocument.html"); + component.completeCreate(); + + QCOMPARE(object->property("readyState").toBool(), true); + QCOMPARE(object->property("openedState").toBool(), true); + QCOMPARE(object->property("status").toBool(), true); + QCOMPARE(object->property("statusText").toBool(), true); + QCOMPARE(object->property("responseText").toBool(), true); + QCOMPARE(object->property("responseXML").toBool(), true); + + TRY_WAIT(object->property("dataOK").toBool() == true); + + delete object; + } + + // Absolute url + { + QmlComponent component(&engine, TEST_FILE("open.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", TEST_FILE("testdocument.html").toString()); + component.completeCreate(); + + QCOMPARE(object->property("readyState").toBool(), true); + QCOMPARE(object->property("openedState").toBool(), true); + QCOMPARE(object->property("status").toBool(), true); + QCOMPARE(object->property("statusText").toBool(), true); + QCOMPARE(object->property("responseText").toBool(), true); + QCOMPARE(object->property("responseXML").toBool(), true); + + TRY_WAIT(object->property("dataOK").toBool() == true); + + delete object; + } + + // Absolute network url + { + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(TEST_FILE("open_network.expect"), + TEST_FILE("open_network.reply"), + TEST_FILE("testdocument.html"))); + + QmlComponent component(&engine, TEST_FILE("open.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + component.completeCreate(); + + QCOMPARE(object->property("readyState").toBool(), true); + QCOMPARE(object->property("openedState").toBool(), true); + QCOMPARE(object->property("status").toBool(), true); + QCOMPARE(object->property("statusText").toBool(), true); + QCOMPARE(object->property("responseText").toBool(), true); + QCOMPARE(object->property("responseXML").toBool(), true); + + TRY_WAIT(object->property("dataOK").toBool() == true); + + delete object; + } + + // User/pass + { + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(TEST_FILE("open_network.expect"), + TEST_FILE("open_network.reply"), + TEST_FILE("testdocument.html"))); + + QmlComponent component(&engine, TEST_FILE("open_user.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + component.completeCreate(); + + QCOMPARE(object->property("readyState").toBool(), true); + QCOMPARE(object->property("openedState").toBool(), true); + QCOMPARE(object->property("status").toBool(), true); + QCOMPARE(object->property("statusText").toBool(), true); + QCOMPARE(object->property("responseText").toBool(), true); + QCOMPARE(object->property("responseXML").toBool(), true); + + TRY_WAIT(object->property("dataOK").toBool() == true); + + // ### Check that the username/password were sent to the server + + delete object; + } +} + +// Test that calling XMLHttpRequest.open() with an invalid method raises an exception +void tst_xmlhttprequest::open_invalid_method() +{ + QmlComponent component(&engine, TEST_FILE("open_invalid_method.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("exceptionThrown").toBool(), true); + + delete object; +} + +// Test that calling XMLHttpRequest.open() with sync raises an exception +void tst_xmlhttprequest::open_sync() +{ + QmlComponent component(&engine, TEST_FILE("open_sync.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("exceptionThrown").toBool(), true); + + delete object; +} + +// Calling with incorrect arg count raises an exception +void tst_xmlhttprequest::open_arg_count() +{ + { + QmlComponent component(&engine, TEST_FILE("open_arg_count.1.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("exceptionThrown").toBool(), true); + + delete object; + } + + { + QmlComponent component(&engine, TEST_FILE("open_arg_count.2.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("exceptionThrown").toBool(), true); + + delete object; + } +} + +// Test valid setRequestHeader() calls +void tst_xmlhttprequest::setRequestHeader() +{ + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(TEST_FILE("setRequestHeader.expect"), + TEST_FILE("setRequestHeader.reply"), + TEST_FILE("testdocument.html"))); + + QmlComponent component(&engine, TEST_FILE("setRequestHeader.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + component.completeCreate(); + + TRY_WAIT(object->property("dataOK").toBool() == true); + + delete object; +} + +// Test setting headers before open() throws exception +void tst_xmlhttprequest::setRequestHeader_unsent() +{ + QmlComponent component(&engine, TEST_FILE("setRequestHeader_unsent.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toBool(), true); + + delete object; +} + +void tst_xmlhttprequest::setRequestHeader_illegalName_data() +{ + QTest::addColumn<QString>("name"); + + QTest::newRow("Accept-Charset") << "AccePT-CHArset"; + QTest::newRow("Accept-Encoding") << "AccEpt-EnCOding"; + QTest::newRow("Connection") << "ConnECtion"; + QTest::newRow("Content-Length") << "ContEnt-LenGth"; + QTest::newRow("Cookie") << "CookIe"; + QTest::newRow("Cookie2") << "CoOkie2"; + QTest::newRow("Content-Transfer-Encoding") << "ConteNT-tRANSFER-eNCOding"; + QTest::newRow("Date") << "DaTE"; + QTest::newRow("Expect") << "ExPect"; + QTest::newRow("Host") << "HoST"; + QTest::newRow("Keep-Alive") << "KEEP-aLive"; + QTest::newRow("Referer") << "ReferEr"; + QTest::newRow("TE") << "Te"; + QTest::newRow("Trailer") << "TraILEr"; + QTest::newRow("Transfer-Encoding") << "tRANsfer-Encoding"; + QTest::newRow("Upgrade") << "UpgrADe"; + QTest::newRow("User-Agent") << "uSEr-Agent"; + QTest::newRow("Via") << "vIa"; + QTest::newRow("Proxy-") << "ProXy-"; + QTest::newRow("Sec-") << "SeC-"; + QTest::newRow("Proxy-*") << "Proxy-BLAH"; + QTest::newRow("Sec-*") << "Sec-F"; +} + +// Tests that using illegal header names has no effect +void tst_xmlhttprequest::setRequestHeader_illegalName() +{ + QFETCH(QString, name); + + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(TEST_FILE("open_network.expect"), + TEST_FILE("open_network.reply"), + TEST_FILE("testdocument.html"))); + + QmlComponent component(&engine, TEST_FILE("setRequestHeader_illegalName.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + object->setProperty("header", name); + component.completeCreate(); + + QCOMPARE(object->property("readyState").toBool(), true); + QCOMPARE(object->property("openedState").toBool(), true); + QCOMPARE(object->property("status").toBool(), true); + QCOMPARE(object->property("statusText").toBool(), true); + QCOMPARE(object->property("responseText").toBool(), true); + QCOMPARE(object->property("responseXML").toBool(), true); + + TRY_WAIT(object->property("dataOK").toBool() == true); + + delete object; +} + +// Test that attempting to set a header after a request is sent throws an exception +void tst_xmlhttprequest::setRequestHeader_sent() +{ + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(TEST_FILE("open_network.expect"), + TEST_FILE("open_network.reply"), + TEST_FILE("testdocument.html"))); + + QmlComponent component(&engine, TEST_FILE("setRequestHeader_sent.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + component.completeCreate(); + + QCOMPARE(object->property("test").toBool(), true); + + TRY_WAIT(object->property("dataOK").toBool() == true); + + delete object; +} + +// Invalid arg count throws exception +void tst_xmlhttprequest::setRequestHeader_args() +{ + QmlComponent component(&engine, TEST_FILE("setRequestHeader_args.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("exceptionThrown").toBool(), true); + + delete object; +} + +// Test that calling send() in UNSENT state throws an exception +void tst_xmlhttprequest::send_unsent() +{ + QmlComponent component(&engine, TEST_FILE("send_unsent.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toBool(), true); + + delete object; +} + +// Test attempting to resend a sent request throws an exception +void tst_xmlhttprequest::send_alreadySent() +{ + QmlComponent component(&engine, TEST_FILE("send_alreadySent.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toBool(), true); + TRY_WAIT(object->property("dataOK").toBool() == true); + + delete object; +} + +// Test that send for a GET or HEAD ignores data +void tst_xmlhttprequest::send_ignoreData() +{ + { + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(TEST_FILE("send_ignoreData_GET.expect"), + TEST_FILE("send_ignoreData.reply"), + TEST_FILE("testdocument.html"))); + + QmlComponent component(&engine, TEST_FILE("send_ignoreData.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("reqType", "GET"); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + component.completeCreate(); + + TRY_WAIT(object->property("dataOK").toBool() == true); + + delete object; + } + + { + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(TEST_FILE("send_ignoreData_PUT.expect"), + TEST_FILE("send_ignoreData.reply"), + TEST_FILE("testdocument.html"))); + + QmlComponent component(&engine, TEST_FILE("send_ignoreData.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("reqType", "HEAD"); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + component.completeCreate(); + + TRY_WAIT(object->property("dataOK").toBool() == true); + + delete object; + } +} + +// Test that send()'ing data works +void tst_xmlhttprequest::send_withdata() +{ + // No content-type + { + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(TEST_FILE("send_data.1.expect"), + TEST_FILE("send_data.reply"), + TEST_FILE("testdocument.html"))); + + QmlComponent component(&engine, TEST_FILE("send_data.1.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + component.completeCreate(); + + TRY_WAIT(object->property("dataOK").toBool() == true); + + delete object; + } + + // Correct content-type + { + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(TEST_FILE("send_data.1.expect"), + TEST_FILE("send_data.reply"), + TEST_FILE("testdocument.html"))); + + QmlComponent component(&engine, TEST_FILE("send_data.2.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + component.completeCreate(); + + TRY_WAIT(object->property("dataOK").toBool() == true); + + delete object; + } + + // Incorrect content-type + { + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(TEST_FILE("send_data.1.expect"), + TEST_FILE("send_data.reply"), + TEST_FILE("testdocument.html"))); + + QmlComponent component(&engine, TEST_FILE("send_data.3.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + component.completeCreate(); + + TRY_WAIT(object->property("dataOK").toBool() == true); + + delete object; + } + + // Correct content-type - out of order + { + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(TEST_FILE("send_data.4.expect"), + TEST_FILE("send_data.reply"), + TEST_FILE("testdocument.html"))); + + QmlComponent component(&engine, TEST_FILE("send_data.4.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + component.completeCreate(); + + TRY_WAIT(object->property("dataOK").toBool() == true); + + delete object; + } + + // Incorrect content-type - out of order + { + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(TEST_FILE("send_data.4.expect"), + TEST_FILE("send_data.reply"), + TEST_FILE("testdocument.html"))); + + QmlComponent component(&engine, TEST_FILE("send_data.5.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + component.completeCreate(); + + TRY_WAIT(object->property("dataOK").toBool() == true); + + delete object; + } + + // PUT + { + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(TEST_FILE("send_data.6.expect"), + TEST_FILE("send_data.reply"), + TEST_FILE("testdocument.html"))); + + QmlComponent component(&engine, TEST_FILE("send_data.6.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + component.completeCreate(); + + TRY_WAIT(object->property("dataOK").toBool() == true); + + delete object; + } + + // Correct content-type - no charset + { + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(TEST_FILE("send_data.1.expect"), + TEST_FILE("send_data.reply"), + TEST_FILE("testdocument.html"))); + + QmlComponent component(&engine, TEST_FILE("send_data.7.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + component.completeCreate(); + + TRY_WAIT(object->property("dataOK").toBool() == true); + + delete object; + } +} + +// Test abort() has no effect in unsent state +void tst_xmlhttprequest::abort_unsent() +{ + QmlComponent component(&engine, TEST_FILE("abort_unsent.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "testdocument.html"); + component.completeCreate(); + + QCOMPARE(object->property("readyState").toBool(), true); + QCOMPARE(object->property("openedState").toBool(), true); + QCOMPARE(object->property("status").toBool(), true); + QCOMPARE(object->property("statusText").toBool(), true); + QCOMPARE(object->property("responseText").toBool(), true); + QCOMPARE(object->property("responseXML").toBool(), true); + + TRY_WAIT(object->property("dataOK").toBool() == true); + + delete object; +} + +// Test abort() cancels an open (but unsent) request +void tst_xmlhttprequest::abort_opened() +{ + QmlComponent component(&engine, TEST_FILE("abort_opened.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "testdocument.html"); + component.completeCreate(); + + QCOMPARE(object->property("readyState").toBool(), true); + QCOMPARE(object->property("openedState").toBool(), true); + QCOMPARE(object->property("status").toBool(), true); + QCOMPARE(object->property("statusText").toBool(), true); + QCOMPARE(object->property("responseText").toBool(), true); + QCOMPARE(object->property("responseXML").toBool(), true); + + TRY_WAIT(object->property("dataOK").toBool() == true); + + delete object; +} + +// Test abort() aborts in progress send +void tst_xmlhttprequest::abort() +{ + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(TEST_FILE("abort.expect"), + TEST_FILE("abort.reply"), + TEST_FILE("testdocument.html"))); + + QmlComponent component(&engine, TEST_FILE("abort.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("urlDummy", "http://127.0.0.1:14449/testdocument.html"); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + component.completeCreate(); + + QCOMPARE(object->property("seenDone").toBool(), true); + QCOMPARE(object->property("didNotSeeUnsent").toBool(), true); + QCOMPARE(object->property("endStateUnsent").toBool(), true); + + TRY_WAIT(object->property("dataOK").toBool() == true); + + delete object; +} + +void tst_xmlhttprequest::getResponseHeader() +{ + QmlEngine engine; // Avoid cookie contamination + + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(TEST_FILE("getResponseHeader.expect"), + TEST_FILE("getResponseHeader.reply"), + TEST_FILE("testdocument.html"))); + + + QmlComponent component(&engine, TEST_FILE("getResponseHeader.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + component.completeCreate(); + + QCOMPARE(object->property("unsentException").toBool(), true); + QCOMPARE(object->property("openedException").toBool(), true); + QCOMPARE(object->property("readyState").toBool(), true); + QCOMPARE(object->property("openedState").toBool(), true); + + TRY_WAIT(object->property("dataOK").toBool() == true); + + QCOMPARE(object->property("headersReceivedState").toBool(), true); + QCOMPARE(object->property("headersReceivedNullHeader").toBool(), true); + QCOMPARE(object->property("headersReceivedValidHeader").toBool(), true); + QCOMPARE(object->property("headersReceivedMultiValidHeader").toBool(), true); + QCOMPARE(object->property("headersReceivedCookieHeader").toBool(), true); + + QCOMPARE(object->property("doneState").toBool(), true); + QCOMPARE(object->property("doneNullHeader").toBool(), true); + QCOMPARE(object->property("doneValidHeader").toBool(), true); + QCOMPARE(object->property("doneMultiValidHeader").toBool(), true); + QCOMPARE(object->property("doneCookieHeader").toBool(), true); + + delete object; +} + +// Test getResponseHeader throws an exception in an invalid state +void tst_xmlhttprequest::getResponseHeader_unsent() +{ + QmlComponent component(&engine, TEST_FILE("getResponseHeader_unsent.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toBool(), true); + + delete object; +} + +// Test getResponseHeader throws an exception in an invalid state +void tst_xmlhttprequest::getResponseHeader_sent() +{ + QmlComponent component(&engine, TEST_FILE("getResponseHeader_sent.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toBool(), true); + + delete object; +} + +// Invalid arg count throws exception +void tst_xmlhttprequest::getResponseHeader_args() +{ + QmlComponent component(&engine, TEST_FILE("getResponseHeader_args.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + TRY_WAIT(object->property("exceptionThrown").toBool() == true); + + delete object; +} + +void tst_xmlhttprequest::getAllResponseHeaders() +{ + QmlEngine engine; // Avoid cookie contamination + + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(TEST_FILE("getResponseHeader.expect"), + TEST_FILE("getResponseHeader.reply"), + TEST_FILE("testdocument.html"))); + + QmlComponent component(&engine, TEST_FILE("getAllResponseHeaders.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + component.completeCreate(); + + QCOMPARE(object->property("unsentException").toBool(), true); + QCOMPARE(object->property("openedException").toBool(), true); + QCOMPARE(object->property("readyState").toBool(), true); + QCOMPARE(object->property("openedState").toBool(), true); + + TRY_WAIT(object->property("dataOK").toBool() == true); + + QCOMPARE(object->property("headersReceivedState").toBool(), true); + QCOMPARE(object->property("headersReceivedHeader").toBool(), true); + + QCOMPARE(object->property("doneState").toBool(), true); + QCOMPARE(object->property("doneHeader").toBool(), true); + + delete object; +} + +// Test getAllResponseHeaders throws an exception in an invalid state +void tst_xmlhttprequest::getAllResponseHeaders_unsent() +{ + QmlComponent component(&engine, TEST_FILE("getAllResponseHeaders_unsent.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toBool(), true); + + delete object; +} + +// Test getAllResponseHeaders throws an exception in an invalid state +void tst_xmlhttprequest::getAllResponseHeaders_sent() +{ + QmlComponent component(&engine, TEST_FILE("getAllResponseHeaders_sent.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toBool(), true); + + delete object; +} + +// Invalid arg count throws exception +void tst_xmlhttprequest::getAllResponseHeaders_args() +{ + QmlComponent component(&engine, TEST_FILE("getAllResponseHeaders_args.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + TRY_WAIT(object->property("exceptionThrown").toBool() == true); + + delete object; +} + +void tst_xmlhttprequest::status() +{ + { + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(TEST_FILE("status.expect"), + TEST_FILE("status.200.reply"), + TEST_FILE("testdocument.html"))); + + QmlComponent component(&engine, TEST_FILE("status.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + object->setProperty("expectedStatus", 200); + component.completeCreate(); + + TRY_WAIT(object->property("dataOK").toBool() == true); + + QCOMPARE(object->property("unsentException").toBool(), true); + QCOMPARE(object->property("openedException").toBool(), true); + QCOMPARE(object->property("sentException").toBool(), true); + QCOMPARE(object->property("headersReceived").toBool(), true); + QCOMPARE(object->property("loading").toBool(), true); + QCOMPARE(object->property("done").toBool(), true); + QCOMPARE(object->property("resetException").toBool(), true); + + delete object; + } + + { + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(TEST_FILE("status.expect"), + TEST_FILE("status.404.reply"), + TEST_FILE("testdocument.html"))); + + QmlComponent component(&engine, TEST_FILE("status.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + object->setProperty("expectedStatus", 404); + component.completeCreate(); + + TRY_WAIT(object->property("dataOK").toBool() == true); + + QCOMPARE(object->property("unsentException").toBool(), true); + QCOMPARE(object->property("openedException").toBool(), true); + QCOMPARE(object->property("sentException").toBool(), true); + QCOMPARE(object->property("headersReceived").toBool(), true); + QCOMPARE(object->property("loading").toBool(), true); + QCOMPARE(object->property("done").toBool(), true); + QCOMPARE(object->property("resetException").toBool(), true); + + delete object; + } +} + +void tst_xmlhttprequest::statusText() +{ + { + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(TEST_FILE("status.expect"), + TEST_FILE("status.200.reply"), + TEST_FILE("testdocument.html"))); + + QmlComponent component(&engine, TEST_FILE("statusText.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + object->setProperty("expectedStatus", "OK"); + component.completeCreate(); + + TRY_WAIT(object->property("dataOK").toBool() == true); + + QCOMPARE(object->property("unsentException").toBool(), true); + QCOMPARE(object->property("openedException").toBool(), true); + QCOMPARE(object->property("sentException").toBool(), true); + QCOMPARE(object->property("headersReceived").toBool(), true); + QCOMPARE(object->property("loading").toBool(), true); + QCOMPARE(object->property("done").toBool(), true); + QCOMPARE(object->property("resetException").toBool(), true); + + delete object; + } + + { + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(TEST_FILE("status.expect"), + TEST_FILE("status.404.reply"), + TEST_FILE("testdocument.html"))); + + QmlComponent component(&engine, TEST_FILE("statusText.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + object->setProperty("expectedStatus", "Document not found"); + component.completeCreate(); + + TRY_WAIT(object->property("dataOK").toBool() == true); + + QCOMPARE(object->property("unsentException").toBool(), true); + QCOMPARE(object->property("openedException").toBool(), true); + QCOMPARE(object->property("sentException").toBool(), true); + QCOMPARE(object->property("headersReceived").toBool(), true); + QCOMPARE(object->property("loading").toBool(), true); + QCOMPARE(object->property("done").toBool(), true); + QCOMPARE(object->property("resetException").toBool(), true); + + delete object; + } +} + +void tst_xmlhttprequest::responseText() +{ + { + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(TEST_FILE("status.expect"), + TEST_FILE("status.200.reply"), + TEST_FILE("testdocument.html"))); + + QmlComponent component(&engine, TEST_FILE("responseText.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + object->setProperty("expectedText", "QML Rocks!\n"); + component.completeCreate(); + + TRY_WAIT(object->property("dataOK").toBool() == true); + + QCOMPARE(object->property("unsent").toBool(), true); + QCOMPARE(object->property("opened").toBool(), true); + QCOMPARE(object->property("sent").toBool(), true); + QCOMPARE(object->property("headersReceived").toBool(), true); + QCOMPARE(object->property("loading").toBool(), true); + QCOMPARE(object->property("done").toBool(), true); + QCOMPARE(object->property("reset").toBool(), true); + + delete object; + } + + { + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(TEST_FILE("status.expect"), + TEST_FILE("status.200.reply"), + QUrl())); + + QmlComponent component(&engine, TEST_FILE("responseText.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + object->setProperty("expectedText", ""); + component.completeCreate(); + + TRY_WAIT(object->property("dataOK").toBool() == true); + + QCOMPARE(object->property("unsent").toBool(), true); + QCOMPARE(object->property("opened").toBool(), true); + QCOMPARE(object->property("sent").toBool(), true); + QCOMPARE(object->property("headersReceived").toBool(), true); + QCOMPARE(object->property("loading").toBool(), true); + QCOMPARE(object->property("done").toBool(), true); + QCOMPARE(object->property("reset").toBool(), true); + + delete object; + } + + { + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(TEST_FILE("status.expect"), + TEST_FILE("status.404.reply"), + TEST_FILE("testdocument.html"))); + + QmlComponent component(&engine, TEST_FILE("responseText.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + object->setProperty("expectedText", ""); + component.completeCreate(); + + TRY_WAIT(object->property("dataOK").toBool() == true); + + QCOMPARE(object->property("unsent").toBool(), true); + QCOMPARE(object->property("opened").toBool(), true); + QCOMPARE(object->property("sent").toBool(), true); + QCOMPARE(object->property("headersReceived").toBool(), true); + QCOMPARE(object->property("loading").toBool(), true); + QCOMPARE(object->property("done").toBool(), true); + QCOMPARE(object->property("reset").toBool(), true); + + delete object; + } +} + +// Test that calling hte XMLHttpRequest methods on a non-XMLHttpRequest object +// throws an exception +void tst_xmlhttprequest::invalidMethodUsage() +{ + QmlComponent component(&engine, TEST_FILE("invalidMethodUsage.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("onreadystatechange").toBool(), true); + QCOMPARE(object->property("readyState").toBool(), true); + QCOMPARE(object->property("status").toBool(), true); + QCOMPARE(object->property("statusText").toBool(), true); + QCOMPARE(object->property("responseText").toBool(), true); + QCOMPARE(object->property("responseXML").toBool(), true); + + QCOMPARE(object->property("open").toBool(), true); + QCOMPARE(object->property("setRequestHeader").toBool(), true); + QCOMPARE(object->property("send").toBool(), true); + QCOMPARE(object->property("abort").toBool(), true); + QCOMPARE(object->property("getResponseHeader").toBool(), true); + QCOMPARE(object->property("getAllResponseHeaders").toBool(), true); + + delete object; +} + +// Test that XMLHttpRequest transparently redirects +void tst_xmlhttprequest::redirects() +{ + { + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirecttarget.html"); + server.serveDirectory("data"); + + QmlComponent component(&engine, TEST_FILE("redirects.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/redirect.html"); + object->setProperty("expectedText", ""); + component.completeCreate(); + + TRY_WAIT(object->property("done").toBool() == true); + QCOMPARE(object->property("dataOK").toBool(), true); + + delete object; + } + + { + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirectmissing.html"); + server.serveDirectory("data"); + + QmlComponent component(&engine, TEST_FILE("redirectError.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/redirect.html"); + object->setProperty("expectedText", ""); + component.completeCreate(); + + TRY_WAIT(object->property("done").toBool() == true); + QCOMPARE(object->property("dataOK").toBool(), true); + + delete object; + } + + { + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirect.html"); + server.serveDirectory("data"); + + QmlComponent component(&engine, TEST_FILE("redirectRecur.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/redirect.html"); + object->setProperty("expectedText", ""); + component.completeCreate(); + + for (int ii = 0; ii < 60; ++ii) { + if (object->property("done").toBool()) break; + QTest::qWait(50); + } + QVERIFY(object->property("done").toBool() == true); + + QCOMPARE(object->property("dataOK").toBool(), true); + + delete object; + } +} + +void tst_xmlhttprequest::responseXML_invalid() +{ + QmlComponent component(&engine, TEST_FILE("responseXML_invalid.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + TRY_WAIT(object->property("dataOK").toBool() == true); + + QCOMPARE(object->property("xmlNull").toBool(), true); + + delete object; +} + +// Test the Document DOM element +void tst_xmlhttprequest::document() +{ + QmlComponent component(&engine, TEST_FILE("document.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + TRY_WAIT(object->property("dataOK").toBool() == true); + + QCOMPARE(object->property("xmlTest").toBool(), true); + + delete object; +} + +// Test the Element DOM element +void tst_xmlhttprequest::element() +{ + QmlComponent component(&engine, TEST_FILE("element.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + TRY_WAIT(object->property("dataOK").toBool() == true); + + QCOMPARE(object->property("xmlTest").toBool(), true); + + delete object; +} + +// Test the Attr DOM element +void tst_xmlhttprequest::attr() +{ + QmlComponent component(&engine, TEST_FILE("attr.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + TRY_WAIT(object->property("dataOK").toBool() == true); + + QCOMPARE(object->property("xmlTest").toBool(), true); + + delete object; +} + +// Test the Text DOM element +void tst_xmlhttprequest::text() +{ + QmlComponent component(&engine, TEST_FILE("text.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + TRY_WAIT(object->property("dataOK").toBool() == true); + + QCOMPARE(object->property("xmlTest").toBool(), true); + + delete object; +} + +// Test the CDataSection DOM element +void tst_xmlhttprequest::cdata() +{ + QmlComponent component(&engine, TEST_FILE("cdata.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + TRY_WAIT(object->property("dataOK").toBool() == true); + + QCOMPARE(object->property("xmlTest").toBool(), true); + + delete object; +} + +QTEST_MAIN(tst_xmlhttprequest) + +#include "tst_qmlxmlhttprequest.moc" |