summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/origins/tst_origins.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/origins/tst_origins.cpp')
-rw-r--r--tests/auto/widgets/origins/tst_origins.cpp98
1 files changed, 64 insertions, 34 deletions
diff --git a/tests/auto/widgets/origins/tst_origins.cpp b/tests/auto/widgets/origins/tst_origins.cpp
index e3927f763..c24fbede4 100644
--- a/tests/auto/widgets/origins/tst_origins.cpp
+++ b/tests/auto/widgets/origins/tst_origins.cpp
@@ -217,6 +217,7 @@ private Q_SLOTS:
void subdirWithoutAccess();
void mixedSchemes();
void mixedSchemesWithCsp();
+ void mixedXHR_data();
void mixedXHR();
#if defined(WEBSOCKETS)
void webSocket();
@@ -609,43 +610,72 @@ void tst_Origins::mixedSchemesWithCsp()
// Cross-origin XMLHttpRequests can only be made to CORS-enabled schemes. These
// include the builtin schemes http, https, data, and chrome, as well as custom
// schemes with the CorsEnabled flag.
-void tst_Origins::mixedXHR()
+void tst_Origins::mixedXHR_data()
{
- QVERIFY(verifyLoad(QSL("file:" THIS_DIR "resources/mixedXHR.html")));
- eval(QSL("sendXHR('file:" THIS_DIR "resources/mixedXHR.txt')"));
- QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("ok")));
- eval(QSL("sendXHR('qrc:/resources/mixedXHR.txt')"));
- QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("error")));
- eval(QSL("sendXHR('tst:/resources/mixedXHR.txt')"));
- QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("error")));
- eval(QSL("sendXHR('data:,ok')"));
- QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("ok")));
- eval(QSL("sendXHR('cors:/resources/mixedXHR.txt')"));
- QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("ok")));
+ QTest::addColumn<QString>("url");
+ QTest::addColumn<QString>("command");
+ QTest::addColumn<QVariant>("result");
+ QTest::newRow("file->file") << QString("file:" THIS_DIR "resources/mixedXHR.html")
+ << QString("sendXHR('file:" THIS_DIR "resources/mixedXHR.txt')")
+ << QVariant(QString("ok"));
+ QTest::newRow("file->qrc") << QString("file:" THIS_DIR "resources/mixedXHR.html")
+ << QString("sendXHR('qrc:/resources/mixedXHR.txt')")
+ << QVariant(QString("error"));
+ QTest::newRow("file->tst") << QString("file:" THIS_DIR "resources/mixedXHR.html")
+ << QString("sendXHR('tst:/resources/mixedXHR.txt')")
+ << QVariant(QString("error"));
+ QTest::newRow("file->data") << QString("file:" THIS_DIR "resources/mixedXHR.html")
+ << QString("sendXHR('data:,ok')")
+ << QVariant(QString("ok"));
+ QTest::newRow("file->cors") << QString("file:" THIS_DIR "resources/mixedXHR.html")
+ << QString("sendXHR('cors:/resources/mixedXHR.txt')")
+ << QVariant(QString("ok"));
+
+ QTest::newRow("qrc->file") << QString("qrc:/resources/mixedXHR.html")
+ << QString("sendXHR('file:" THIS_DIR "resources/mixedXHR.txt')")
+ << QVariant(QString("ok"));
+ QTest::newRow("qrc->qrc") << QString("qrc:/resources/mixedXHR.html")
+ << QString("sendXHR('qrc:/resources/mixedXHR.txt')")
+ << QVariant(QString("ok"));
+ QTest::newRow("qrc->tst") << QString("qrc:/resources/mixedXHR.html")
+ << QString("sendXHR('tst:/resources/mixedXHR.txt')")
+ << QVariant(QString("error"));
+ QTest::newRow("qrc->data") << QString("qrc:/resources/mixedXHR.html")
+ << QString("sendXHR('data:,ok')")
+ << QVariant(QString("ok"));
+ QTest::newRow("qrc->cors") << QString("qrc:/resources/mixedXHR.html")
+ << QString("sendXHR('cors:/resources/mixedXHR.txt')")
+ << QVariant(QString("ok"));
+
+
+ QTest::newRow("tst->file") << QString("tst:/resources/mixedXHR.html")
+ << QString("sendXHR('file:" THIS_DIR "resources/mixedXHR.txt')")
+ << QVariant(QString("error"));
+ QTest::newRow("tst->qrc") << QString("tst:/resources/mixedXHR.html")
+ << QString("sendXHR('qrc:/resources/mixedXHR.txt')")
+ << QVariant(QString("error"));
+ QTest::newRow("tst->tst") << QString("tst:/resources/mixedXHR.html")
+ << QString("sendXHR('tst:/resources/mixedXHR.txt')")
+ << QVariant(QString("ok"));
+ QTest::newRow("tst->data") << QString("tst:/resources/mixedXHR.html")
+ << QString("sendXHR('data:,ok')")
+ << QVariant(QString("ok"));
+ QTest::newRow("tst->cors") << QString("tst:/resources/mixedXHR.html")
+ << QString("sendXHR('cors:/resources/mixedXHR.txt')")
+ << QVariant(QString("ok"));
- QVERIFY(verifyLoad(QSL("qrc:/resources/mixedXHR.html")));
- eval(QSL("sendXHR('file:" THIS_DIR "resources/mixedXHR.txt')"));
- QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("ok")));
- eval(QSL("sendXHR('qrc:/resources/mixedXHR.txt')"));
- QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("ok")));
- eval(QSL("sendXHR('tst:/resources/mixedXHR.txt')"));
- QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("error")));
- eval(QSL("sendXHR('data:,ok')"));
- QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("ok")));
- eval(QSL("sendXHR('cors:/resources/mixedXHR.txt')"));
- QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("ok")));
+}
- QVERIFY(verifyLoad(QSL("tst:/resources/mixedXHR.html")));
- eval(QSL("sendXHR('file:" THIS_DIR "resources/mixedXHR.txt')"));
- QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("error")));
- eval(QSL("sendXHR('qrc:/resources/mixedXHR.txt')"));
- QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("error")));
- eval(QSL("sendXHR('tst:/resources/mixedXHR.txt')"));
- QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("ok")));
- eval(QSL("sendXHR('data:,ok')"));
- QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("ok")));
- eval(QSL("sendXHR('cors:/resources/mixedXHR.txt')"));
- QTRY_COMPARE(eval(QSL("result")), QVariant(QSL("ok")));
+
+void tst_Origins::mixedXHR()
+{
+ QFETCH(QString, url);
+ QFETCH(QString, command);
+ QFETCH(QVariant, result);
+
+ QVERIFY(verifyLoad(url));
+ eval(command);
+ QTRY_COMPARE(eval(QString("result")), result);
}
#if defined(WEBSOCKETS)