From 6f3a9cd4af80a4b48d876a6377677e6d891bfc55 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 9 Jun 2016 14:28:54 +0200 Subject: Fix tst_QWebEnginePage::setHtmlWithImageResource test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Michael BrĂ¼ning --- tests/auto/widgets/qwebenginepage/BLACKLIST | 3 --- tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp | 16 ++++++++-------- 2 files changed, 8 insertions(+), 11 deletions(-) (limited to 'tests/auto') 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("

hello world

"); 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() -- cgit v1.2.3