summaryrefslogtreecommitdiffstats
path: root/tests/auto/core/origins
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/core/origins')
-rw-r--r--tests/auto/core/origins/CMakeLists.txt1
-rw-r--r--tests/auto/core/origins/resources/websocket2.html23
-rw-r--r--tests/auto/core/origins/tst_origins.cpp8
-rw-r--r--tests/auto/core/origins/tst_origins.qrc1
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>