|
27 | 27 | ****************************************************************************/
|
28 | 28 |
|
29 | 29 | #include "../util.h"
|
| 30 | +#include "httpserver.h" |
30 | 31 |
|
31 | 32 | #include <QtCore/qfile.h>
|
32 | 33 | #include <QtTest/QtTest>
|
@@ -215,6 +216,8 @@ private Q_SLOTS:
|
215 | 216 | void jsUrlOrigin();
|
216 | 217 | void subdirWithAccess();
|
217 | 218 | void subdirWithoutAccess();
|
| 219 | + void fileAccessRemoteUrl_data(); |
| 220 | + void fileAccessRemoteUrl(); |
218 | 221 | void mixedSchemes();
|
219 | 222 | void mixedSchemesWithCsp();
|
220 | 223 | void mixedXHR_data();
|
@@ -497,6 +500,31 @@ void tst_Origins::subdirWithoutAccess()
|
497 | 500 | QCOMPARE(eval(QSL("msg[1]")), QVariant(QSL("world")));
|
498 | 501 | }
|
499 | 502 |
|
| 503 | +void tst_Origins::fileAccessRemoteUrl_data() |
| 504 | +{ |
| 505 | + QTest::addColumn<bool>("EnableAccess"); |
| 506 | + QTest::addRow("enabled") << true; |
| 507 | + QTest::addRow("disabled") << false; |
| 508 | +} |
| 509 | + |
| 510 | +void tst_Origins::fileAccessRemoteUrl() |
| 511 | +{ |
| 512 | + QFETCH(bool, EnableAccess); |
| 513 | + |
| 514 | + HttpServer server; |
| 515 | + server.setResourceDirs({ THIS_DIR "resources" }); |
| 516 | + QVERIFY(server.start()); |
| 517 | + |
| 518 | + ScopedAttribute sa(m_page->settings(), QWebEngineSettings::LocalContentCanAccessRemoteUrls, EnableAccess); |
| 519 | + if (!EnableAccess) |
| 520 | + QTest::ignoreMessage(QtSystemMsg, QRegularExpression(QSL("blocked by CORS policy"))); |
| 521 | + |
| 522 | + QVERIFY(verifyLoad(QSL("file:" THIS_DIR "resources/mixedXHR.html"))); |
| 523 | + |
| 524 | + eval("sendXHR('" + server.url("/mixedXHR.txt").toString() + "')"); |
| 525 | + QTRY_COMPARE(eval("result"), (EnableAccess ? QString("ok") : QString("error"))); |
| 526 | +} |
| 527 | + |
500 | 528 | // Load the main page over one scheme with an iframe over another scheme.
|
501 | 529 | //
|
502 | 530 | // For file and qrc schemes, the iframe should load but it should not be
|
|
0 commit comments