diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-01-18 12:59:54 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-01-18 13:02:22 +0100 |
commit | c2447a308882ba3691d66b2c28df197f571518c7 (patch) | |
tree | c6535d8e038a517f06ddbef9fee649412555b8ae /tests/auto/widgets | |
parent | b63a932bbe1eb2bdf2584e44378ac3fab243320c (diff) | |
parent | 42c6033724e2b5a54702d626c57806e53f163c62 (diff) |
Merge remote-tracking branch 'origin/5.8' into dev
Change-Id: If16bfc6f0fbfd0040e13a8a3cbaa113fda10f387
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r-- | tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp | 33 | ||||
-rw-r--r-- | tests/auto/widgets/tests.pri | 3 |
2 files changed, 15 insertions, 21 deletions
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp index d7fff3a66..5467ce39e 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() diff --git a/tests/auto/widgets/tests.pri b/tests/auto/widgets/tests.pri index 14074cd08..d77cd5af5 100644 --- a/tests/auto/widgets/tests.pri +++ b/tests/auto/widgets/tests.pri @@ -13,7 +13,8 @@ RESOURCES += ../resources/tests.qrc exists($$_PRO_FILE_PWD_/$${TARGET}.qrc): RESOURCES += $${TARGET}.qrc QT += testlib network webenginewidgets widgets quick quickwidgets -macx: CONFIG -= app_bundle # This define is used by some tests to look up resources in the source tree DEFINES += TESTS_SOURCE_DIR=\\\"$$PWD/\\\" + +include(../embed_info_plist.pri) |