summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/declarative/qml/qmlxmlhttprequest.cpp11
-rw-r--r--tests/auto/declarative/xmlhttprequest/data/text.qml56
-rw-r--r--tests/auto/declarative/xmlhttprequest/data/text.xml1
-rw-r--r--tests/auto/declarative/xmlhttprequest/tst_xmlhttprequest.cpp14
4 files changed, 75 insertions, 7 deletions
diff --git a/src/declarative/qml/qmlxmlhttprequest.cpp b/src/declarative/qml/qmlxmlhttprequest.cpp
index a6cdfb1..1e9ad50 100644
--- a/src/declarative/qml/qmlxmlhttprequest.cpp
+++ b/src/declarative/qml/qmlxmlhttprequest.cpp
@@ -465,12 +465,11 @@ QScriptValue Node::create(QScriptEngine *engine, NodeImpl *data)
case NodeImpl::Entity:
case NodeImpl::EntityReference:
case NodeImpl::Notation:
+ case NodeImpl::ProcessingInstruction:
+ return QScriptValue();
case NodeImpl::CDATA:
instance.setPrototype(CDATA::prototype(engine));
break;
- case NodeImpl::ProcessingInstruction:
- instance.setPrototype(Node::prototype(engine));
- break;
case NodeImpl::Text:
instance.setPrototype(Text::prototype(engine));
break;
@@ -556,8 +555,7 @@ QScriptValue Text::isElementContentWhitespace(QScriptContext *context, QScriptEn
Node node = qscriptvalue_cast<Node>(context->thisObject());
if (node.isNull()) return engine->undefinedValue();
- // ### implement
- return QScriptValue(false);
+ return node.d->data.trimmed().isEmpty();
}
QScriptValue Text::wholeText(QScriptContext *context, QScriptEngine *engine)
@@ -565,8 +563,7 @@ QScriptValue Text::wholeText(QScriptContext *context, QScriptEngine *engine)
Node node = qscriptvalue_cast<Node>(context->thisObject());
if (node.isNull()) return engine->undefinedValue();
- // ### implement
- return QScriptValue(QString());
+ return node.d->data;
}
QScriptValue Text::prototype(QScriptEngine *engine)
diff --git a/tests/auto/declarative/xmlhttprequest/data/text.qml b/tests/auto/declarative/xmlhttprequest/data/text.qml
new file mode 100644
index 0000000..b64f80b
--- /dev/null
+++ b/tests/auto/declarative/xmlhttprequest/data/text.qml
@@ -0,0 +1,56 @@
+import Qt 4.6
+
+Object {
+ property bool xmlTest: false
+ property bool dataOK: false
+
+ Script {
+ function checkText(text, whitespacetext)
+ {
+ if (text.wholeText != "Hello world!")
+ return;
+
+ if (text.isElementContentWhitespace != false)
+ return;
+
+ if (whitespacetext.wholeText != " ")
+ 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/xmlhttprequest/data/text.xml b/tests/auto/declarative/xmlhttprequest/data/text.xml
new file mode 100644
index 0000000..e741688
--- /dev/null
+++ b/tests/auto/declarative/xmlhttprequest/data/text.xml
@@ -0,0 +1 @@
+<root><item>Hello world!</item><item> </item></root>
diff --git a/tests/auto/declarative/xmlhttprequest/tst_xmlhttprequest.cpp b/tests/auto/declarative/xmlhttprequest/tst_xmlhttprequest.cpp
index 0af7b18..cf1ffd3 100644
--- a/tests/auto/declarative/xmlhttprequest/tst_xmlhttprequest.cpp
+++ b/tests/auto/declarative/xmlhttprequest/tst_xmlhttprequest.cpp
@@ -88,6 +88,7 @@ private slots:
void document();
void element();
void attr();
+ void text();
// Crashes
// void outstanding_request_at_shutdown();
@@ -1017,6 +1018,19 @@ void tst_xmlhttprequest::attr()
delete object;
}
+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;
+}
+
QTEST_MAIN(tst_xmlhttprequest)
#include "tst_xmlhttprequest.moc"