diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2021-06-14 14:58:53 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-07-02 06:21:52 +0000 |
commit | 755806f120b7e191043dcddd4ea9e26a66d142fa (patch) | |
tree | 60265d4a928ae89a4a51150bd2f390bae09f5db1 /tests/auto/core/origins | |
parent | 0819b8321314a1dd4990dd3841d6b5e622a02076 (diff) |
Remove QRC->file special case
It was marked as to be removed for Qt6
Change-Id: I059c450aa6e5cad6d48ecdd2667abff21217d7e0
Reviewed-by: Jüri Valdmann <juri.valdmann@qt.io>
(cherry picked from commit 01f45d0b536ac2dad7493c826907ded7a76f59d6)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests/auto/core/origins')
-rw-r--r-- | tests/auto/core/origins/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/auto/core/origins/resources/websocket2.html | 23 | ||||
-rw-r--r-- | tests/auto/core/origins/tst_origins.cpp | 8 | ||||
-rw-r--r-- | tests/auto/core/origins/tst_origins.qrc | 1 |
4 files changed, 30 insertions, 3 deletions
diff --git a/tests/auto/core/origins/CMakeLists.txt b/tests/auto/core/origins/CMakeLists.txt index a044ea2ef..79b8278a7 100644 --- a/tests/auto/core/origins/CMakeLists.txt +++ b/tests/auto/core/origins/CMakeLists.txt @@ -28,6 +28,7 @@ set(tst_origins_resource_files "resources/subdir_frame1.html" "resources/viewSource.html" "resources/websocket.html" + "resources/websocket2.html" ) qt_internal_add_resource(tst_origins "tst_origins" diff --git a/tests/auto/core/origins/resources/websocket2.html b/tests/auto/core/origins/resources/websocket2.html new file mode 100644 index 000000000..7365143de --- /dev/null +++ b/tests/auto/core/origins/resources/websocket2.html @@ -0,0 +1,23 @@ +<!DOCTYPE html> +<html> + <head> + <title>WebSocket</title> + <script src="../qtwebchannel/qwebchannel.js"></script> + <script> + var result; + new QWebChannel(qt.webChannelTransport, channel => { + const ws = new WebSocket(channel.objects.echoServer.url); + ws.addEventListener("open", event => { + ws.send("ok"); + }); + ws.addEventListener("message", event => { + result = event.data; + }); + ws.addEventListener("close", event => { + result = event.code; + }); + }) + </script> + </head> + <body></body> +</html> diff --git a/tests/auto/core/origins/tst_origins.cpp b/tests/auto/core/origins/tst_origins.cpp index a34404a7e..1aeb3628a 100644 --- a/tests/auto/core/origins/tst_origins.cpp +++ b/tests/auto/core/origins/tst_origins.cpp @@ -185,6 +185,8 @@ private: } QString pathPrefix = QDir(QT_TESTCASE_SOURCEDIR).canonicalPath(); + if (url.path().startsWith("/qtwebchannel/")) + pathPrefix = QSL(":"); QString pathSuffix = url.path(); QFile *file = new QFile(pathPrefix + pathSuffix, job); if (!file->open(QIODevice::ReadOnly)) { @@ -676,7 +678,7 @@ void tst_Origins::mixedXHR_data() << QString("sendXHR('file:" + QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() + "/resources/mixedXHR.txt')") - << QVariant(QString("ok")); + << QVariant(QString("error")); QTest::newRow("qrc->qrc") << QString("qrc:/resources/mixedXHR.html") << QString("sendXHR('qrc:/resources/mixedXHR.txt')") << QVariant(QString("ok")); @@ -783,11 +785,11 @@ void tst_Origins::webSocket() QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("ok"))); // Unregistered schemes can also open WebSockets (since Chromium 71) - QVERIFY(verifyLoad(QSL("tst:/resources/websocket.html"))); + QVERIFY(verifyLoad(QSL("tst:/resources/websocket2.html"))); QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("ok"))); // Even an insecure registered scheme can open WebSockets. - QVERIFY(verifyLoad(QSL("PathSyntax:/resources/websocket.html"))); + QVERIFY(verifyLoad(QSL("PathSyntax:/resources/websocket2.html"))); QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("ok"))); } #endif diff --git a/tests/auto/core/origins/tst_origins.qrc b/tests/auto/core/origins/tst_origins.qrc index fcf54aaea..ae5245378 100644 --- a/tests/auto/core/origins/tst_origins.qrc +++ b/tests/auto/core/origins/tst_origins.qrc @@ -18,5 +18,6 @@ <file>resources/subdir_frame1.html</file> <file>resources/viewSource.html</file> <file>resources/websocket.html</file> + <file>resources/websocket2.html</file> </qresource> </RCC> |