diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2018-03-28 16:49:19 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2018-04-09 13:42:24 +0000 |
commit | 51b73e0bb68812d78315af032546750d04656c02 (patch) | |
tree | b9d5c063af458ed62786cc95d89c132543dbeb3f /tests/auto/qml/qqmlxmlhttprequest/data | |
parent | ccad6b577016c8a0986f56b2656471896b5817ea (diff) |
Fix XMLHttpRequest when used with QQmlEngine::evaluate
Our XHR implementation insists on a valid QQmlContext when processing
callbacks. This is to protect against callbacks being triggered after
dynamic QML contexts such as delegates have been destroyed.
Unfortunately those checks are too strict and make it impossible to use
XHR from within plain JS scripts (where v4->callingQmlContext() will
return a null pointer).
Dispatching the callbacks in functions that are directly called from
QML/JS is safe and something we can do unconditionally. This applies to
the callbacks triggered from abort() and open() for example.
When we're called from QNetworkAccessManager we should enforce the
continued existence of a QML context only if it was present at send()
time.
Task-number: QTBUG-67337
Change-Id: I8235f6ef407adc3eaeeff4eee72238ba6750afb2
Reviewed-by: Michael Brasser <michael.brasser@live.com>
Reviewed-by: Valery Kotov <vkotov@luxoft.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlxmlhttprequest/data')
-rw-r--r-- | tests/auto/qml/qqmlxmlhttprequest/data/noqmlcontext.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/noqmlcontext.js b/tests/auto/qml/qqmlxmlhttprequest/data/noqmlcontext.js new file mode 100644 index 0000000000..adb7269310 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/noqmlcontext.js @@ -0,0 +1,11 @@ +(function(url, resultCollector) { + var x = new XMLHttpRequest; + x.open("GET", url); + x.setRequestHeader("Accept-Language","en-US"); + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + resultCollector.responseText = x.responseText + } + } + x.send() +}) |