summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSzabolcs David <davidsz@inf.u-szeged.hu>2016-12-14 03:27:32 -0800
committerSzabolcs David <davidsz@inf.u-szeged.hu>2017-01-15 00:34:59 +0000
commit51d5737fa45b62ff9fc769cdb8d3a238dbe9d1cb (patch)
tree348b44dd8b89279b470110085936db98c4fa3654 /tests
parentceff67e0bab4d34c5b791d1f1b1d43c7a4e44d84 (diff)
Unskip tst_QWebEnginePage::setHtmlWithStylesheetResource
Task-number: QTBUG-51572 Change-Id: Ie8e7e5ef38f88ae91d892b703cd9702b2637daa2 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp33
1 files changed, 13 insertions, 20 deletions
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
index 287af511f..821ab4757 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
@@ -3989,16 +3989,10 @@ void tst_QWebEnginePage::setHtmlWithImageResource()
void tst_QWebEnginePage::setHtmlWithStylesheetResource()
{
-#if !defined(QWEBENGINEELEMENT)
- QSKIP("QWEBENGINEELEMENT");
-#else
- // 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 be able to download the local stylesheet.
-
const char* htmlData =
"<html>"
"<head>"
- "<link rel='stylesheet' href='qrc:/style.css' type='text/css' />"
+ "<link rel='stylesheet' href='qrc:/resources/style.css' type='text/css' />"
"</head>"
"<body>"
"<p id='idP'>some text</p>"
@@ -4006,22 +4000,21 @@ void tst_QWebEnginePage::setHtmlWithStylesheetResource()
"</html>";
QLatin1String html(htmlData);
QWebEnginePage page;
- QWebEngineElement webElement;
-
- page.setHtml(html, QUrl(QLatin1String("qrc:///file")));
QSignalSpy spyFinished(&page, &QWebEnginePage::loadFinished);
- QVERIFY(spyFinished.wait(200));
- webElement = page.documentElement().findFirst("p");
- QCOMPARE(webElement.styleProperty("color", QWebEngineElement::CascadedStyle), QLatin1String("red"));
- // Now we test the opposite: without a baseUrl as a local file, we cannot request local resources.
+ // We allow access to qrc resources from any security origin, including local and anonymous
+ page.setHtml(html, QUrl("file:///path/to/file"));
+ QVERIFY(spyFinished.wait());
+ QCOMPARE(evaluateJavaScriptSync(&page, "window.getComputedStyle(document.getElementById('idP')).color").toString(), QString("rgb(255, 0, 0)"));
+
+ page.setHtml(html, QUrl(QLatin1String("qrc:/")));
+ QVERIFY(spyFinished.wait());
+ QCOMPARE(evaluateJavaScriptSync(&page, "window.getComputedStyle(document.getElementById('idP')).color").toString(), QString("rgb(255, 0, 0)"));
- page.setHtml(html, QUrl(QLatin1String("http://www.example.com/")));
- QVERIFY(spyFinished.wait(200));
- webElement = page.documentElement().findFirst("p");
- QEXPECT_FAIL("", "https://bugs.webkit.org/show_bug.cgi?id=118659", Continue);
- QCOMPARE(webElement.styleProperty("color", QWebEngineElement::CascadedStyle), QString());
-#endif
+ // Now we test the opposite: without a baseUrl as a local file, we can still request qrc resources.
+ page.setHtml(html);
+ QVERIFY(spyFinished.wait());
+ QCOMPARE(evaluateJavaScriptSync(&page, "window.getComputedStyle(document.getElementById('idP')).color").toString(), QString("rgb(255, 0, 0)"));
}
void tst_QWebEnginePage::setHtmlWithBaseURL()