diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2018-07-18 12:22:47 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2018-07-18 16:30:36 +0000 |
commit | 1c2242e610b44eb305f66803dff978186c063f91 (patch) | |
tree | 652559fe503ec9b195e260f524c5d34488f94dfc /tests/auto/qml/qqmlxmlhttprequest | |
parent | 7661a4197ca7967db0913f888295bb332519fbcc (diff) |
Add support for onload/onloadend/onerror callbacks in XHR
Those functions are supposed to be called after readystatechanged, with
onloadend coming last.
Task-number: QTBUG-67337
Change-Id: I946cd3c7edbe762c1b66345ec8649562d2246d34
Reviewed-by: Michael Brasser <michael.brasser@live.com>
Diffstat (limited to 'tests/auto/qml/qqmlxmlhttprequest')
-rw-r--r-- | tests/auto/qml/qqmlxmlhttprequest/data/status.qml | 13 | ||||
-rw-r--r-- | tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp | 3 |
2 files changed, 16 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/status.qml b/tests/auto/qml/qqmlxmlhttprequest/data/status.qml index 22c45c099d..94908f63c0 100644 --- a/tests/auto/qml/qqmlxmlhttprequest/data/status.qml +++ b/tests/auto/qml/qqmlxmlhttprequest/data/status.qml @@ -11,6 +11,9 @@ QtObject { property bool headersReceived: false property bool loading: false property bool done: false + property bool onloadCalled: false + property bool onerrorCalled: false + property bool onloadendCalled: false property bool resetException: false @@ -62,6 +65,16 @@ QtObject { } } + x.onload = function() { + // test also that it was called after onreadystatechanged(DONE) + onloadCalled = (done === true) && (onerrorCalled === false); + } + x.onloadend = function() { + onloadendCalled = (done === true) && (onloadCalled === true || onerrorCalled === true); + } + x.onerror = function() { + onerrorCalled = (done === true) && (onloadCalled === false); + } x.send() diff --git a/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp b/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp index ecce6515ed..6cf80ccfdb 100644 --- a/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp +++ b/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp @@ -917,6 +917,9 @@ void tst_qqmlxmlhttprequest::status() QCOMPARE(object->property("loading").toBool(), true); QCOMPARE(object->property("done").toBool(), true); QCOMPARE(object->property("resetException").toBool(), true); + QCOMPARE(object->property("onloadCalled").toBool(), true); + QCOMPARE(object->property("onloadendCalled").toBool(), true); + QCOMPARE(object->property("onerrorCalled").toBool(), false); } void tst_qqmlxmlhttprequest::status_data() |