summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-06-09 14:28:54 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2016-06-10 18:28:22 +0000
commit6f3a9cd4af80a4b48d876a6377677e6d891bfc55 (patch)
tree756d95721a588669d2a58e36667384adc82c8df7 /tests
parent13347dc471d76e7563781b76d6020c52dd2cc152 (diff)
Fix tst_QWebEnginePage::setHtmlWithImageResource test
We have changed qrc resources so that they can be accessed from any security origin. To have a test of local resources we would need a file URL. Task-number: QTBUG-53153 Change-Id: I22b730f07785eacd365e3ec591f5dcbd09b6fc84 Reviewed-by: Alexandru Croitor <alexandru.croitor@theqtcompany.com> Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/qwebenginepage/BLACKLIST3
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp16
2 files changed, 8 insertions, 11 deletions
diff --git a/tests/auto/widgets/qwebenginepage/BLACKLIST b/tests/auto/widgets/qwebenginepage/BLACKLIST
index ddfba2612..91858f299 100644
--- a/tests/auto/widgets/qwebenginepage/BLACKLIST
+++ b/tests/auto/widgets/qwebenginepage/BLACKLIST
@@ -3,6 +3,3 @@
[macCopyUnicodeToClipboard]
osx
-
-[setHtmlWithImageResource]
-*
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
index 75d186bba..f8012c1df 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
@@ -3948,26 +3948,26 @@ void tst_QWebEnginePage::setHtml()
void tst_QWebEnginePage::setHtmlWithImageResource()
{
- // By default, only security origins of local files can load local resources.
- // So we should specify baseUrl to be a local file in order to get a proper origin and load the local image.
+ // We allow access to qrc resources from any security origin, including local and anonymous
QLatin1String html("<html><body><p>hello world</p><img src='qrc:/resources/image.png'/></body></html>");
QWebEnginePage page;
- page.setHtml(html, QUrl(QLatin1String("file:///path/to/file")));
- waitForSignal(&page, SIGNAL(loadFinished(bool)));
+ QSignalSpy spy(&page, SIGNAL(loadFinished(bool)));
+ page.setHtml(html, QUrl("file:///path/to/file"));
+ QTRY_COMPARE(spy.count(), 1);
QCOMPARE(evaluateJavaScriptSync(&page, "document.images.length").toInt(), 1);
QCOMPARE(evaluateJavaScriptSync(&page, "document.images[0].width").toInt(), 128);
QCOMPARE(evaluateJavaScriptSync(&page, "document.images[0].height").toInt(), 128);
- // Now we test the opposite: without a baseUrl as a local file, we cannot request local resources.
+ // Now we test the opposite: without a baseUrl as a local file, we can still request qrc resources.
page.setHtml(html);
- waitForSignal(&page, SIGNAL(loadFinished(bool)));
+ QTRY_COMPARE(spy.count(), 2);
QCOMPARE(evaluateJavaScriptSync(&page, "document.images.length").toInt(), 1);
- QCOMPARE(evaluateJavaScriptSync(&page, "document.images[0].width").toInt(), 0);
- QCOMPARE(evaluateJavaScriptSync(&page, "document.images[0].height").toInt(), 0);
+ QCOMPARE(evaluateJavaScriptSync(&page, "document.images[0].width").toInt(), 128);
+ QCOMPARE(evaluateJavaScriptSync(&page, "document.images[0].height").toInt(), 128);
}
void tst_QWebEnginePage::setHtmlWithStylesheetResource()