summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPeter Varga <pvarga@inf.u-szeged.hu>2018-02-07 17:05:37 +0100
committerPeter Varga <pvarga@inf.u-szeged.hu>2018-02-21 14:51:19 +0000
commit732d09331c1e4efa51501aae9bcd6924eecdd5c3 (patch)
tree2376a15e9a7f91f91087f9681e09f4ce2c6961ca /tests
parent5983f75003dde37b5429b126149b3bcc6c02d4dc (diff)
Expose actual URL for data URLs instead of the virtual URL in the API
Chromium considers the actual URL as "scary" therefore prefers to pass a simpler URL via the WebContents::GetVisibleURL() content API function. For data URLs, use the actual URL instead to keep their anchor information. Task-number: QTBUG-64972 Change-Id: I74db3e5dd22a728656a58e50a4e3fba93b82dae2 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qmltests/data/tst_loadHtml.qml20
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp18
2 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/quick/qmltests/data/tst_loadHtml.qml b/tests/auto/quick/qmltests/data/tst_loadHtml.qml
index f814822dc..73b6139e2 100644
--- a/tests/auto/quick/qmltests/data/tst_loadHtml.qml
+++ b/tests/auto/quick/qmltests/data/tst_loadHtml.qml
@@ -35,8 +35,15 @@ TestWebEngineView {
width: 200
height: 400
+ SignalSpy {
+ id: urlChangedSpy
+ target: webEngineView
+ signalName: "urlChanged"
+ }
+
TestCase {
name: "WebEngineViewLoadHtml"
+ when: windowShown
function test_loadProgressAfterLoadHtml() {
compare(webEngineView.loadProgress, 0)
@@ -44,5 +51,18 @@ TestWebEngineView {
verify(webEngineView.waitForLoadSucceeded())
compare(webEngineView.loadProgress, 100)
}
+
+ function test_dataURLFragment() {
+ webEngineView.loadHtml("<html><body>" +
+ "<a id='link' href='#anchor'>anchor</a>" +
+ "</body></html>");
+ verify(webEngineView.waitForLoadSucceeded());
+
+ urlChangedSpy.clear();
+ var center = getElementCenter("link");
+ mouseClick(webEngineView, center.x, center.y);
+ urlChangedSpy.wait();
+ compare(webEngineView.url.toString().split("#")[1], "anchor");
+ }
}
}
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
index fbed89dd3..8fc52be60 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
@@ -214,6 +214,7 @@ private Q_SLOTS:
void proxyConfigWithUnexpectedHostPortPair();
void registerProtocolHandler_data();
void registerProtocolHandler();
+ void dataURLFragment();
private:
static QPoint elementCenter(QWebEnginePage *page, const QString &id);
@@ -4267,6 +4268,23 @@ void tst_QWebEnginePage::registerProtocolHandler()
QCOMPARE(loadSpy.takeFirst().value(0).toBool(), permission);
}
+void tst_QWebEnginePage::dataURLFragment()
+{
+ m_view->resize(800, 600);
+ m_view->show();
+ QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool)));
+
+ m_page->setHtml("<html><body>"
+ "<a id='link' href='#anchor'>anchor</a>"
+ "</body></html>");
+ QTRY_COMPARE(loadFinishedSpy.count(), 1);
+
+ QSignalSpy urlChangedSpy(m_page, SIGNAL(urlChanged(QUrl)));
+ QTest::mouseClick(m_view->focusProxy(), Qt::LeftButton, 0, elementCenter(m_page, "link"));
+ QVERIFY(urlChangedSpy.wait());
+ QCOMPARE(m_page->url().fragment(), QStringLiteral("anchor"));
+}
+
static QByteArrayList params = {QByteArrayLiteral("--use-fake-device-for-media-stream")};
W_QTEST_MAIN(tst_QWebEnginePage, params)