summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSzabolcs David <davidsz@inf.u-szeged.hu>2014-05-06 02:04:08 -0700
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-05-08 15:31:02 +0200
commit9648528ad6fbd66eeaae3189173a7d7b47b935ce (patch)
tree8d420f17d0be7077517e5e257adfe98773ab41f3
parent388a71d66f31df999dc9259d4eb156c497ad5247 (diff)
Add test_baseUrlAfterLoadHtml QML test case
Remove unreachableUrl support from WebContentsAdapter::setContent, because this argument behaves exactly the same as baseUrl. Change-Id: I36f92b99b7045c6d3b831481bb04d51a0e05772f Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
-rw-r--r--src/core/web_contents_adapter.cpp4
-rw-r--r--src/core/web_contents_adapter.h2
-rw-r--r--src/webengine/api/qquickwebengineview.cpp4
-rw-r--r--src/webengine/api/qquickwebengineview_p.h2
-rw-r--r--src/webengine/doc/src/qquickwebengineview_lgpl.qdoc6
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp2
-rw-r--r--tests/auto/quick/publicapi/tst_publicapi.cpp1
-rw-r--r--tests/auto/quick/qmltests/data/tst_desktopBehaviorLoadHtml.qml100
-rw-r--r--tests/auto/quick/qmltests/data/tst_loadUrl.qml2
-rw-r--r--tests/auto/quick/qmltests/qmltests.pro1
10 files changed, 110 insertions, 14 deletions
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index 11b5f7cc..3ea5e416 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -438,7 +438,7 @@ void WebContentsAdapter::load(const QUrl &url)
d->webContents->GetView()->Focus();
}
-void WebContentsAdapter::setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl, const QUrl &unreachableUrl)
+void WebContentsAdapter::setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl)
{
Q_D(WebContentsAdapter);
QByteArray encodedData = data.toPercentEncoding();
@@ -450,7 +450,7 @@ void WebContentsAdapter::setContent(const QByteArray &data, const QString &mimeT
content::NavigationController::LoadURLParams params((GURL(urlString)));
params.load_type = content::NavigationController::LOAD_TYPE_DATA;
params.base_url_for_data_url = toGurl(baseUrl);
- params.virtual_url_for_data_url = unreachableUrl.isEmpty() ? GURL(content::kAboutBlankURL) : toGurl(unreachableUrl);
+ params.virtual_url_for_data_url = baseUrl.isEmpty() ? GURL(content::kAboutBlankURL) : toGurl(baseUrl);
params.can_load_local_resources = true;
d->webContents->GetController().LoadURLWithParams(params);
}
diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h
index b6984933..371be5d9 100644
--- a/src/core/web_contents_adapter.h
+++ b/src/core/web_contents_adapter.h
@@ -69,7 +69,7 @@ public:
void stop();
void reload();
void load(const QUrl&);
- void setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl, const QUrl &unreachableUrl);
+ void setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl);
QUrl activeUrl() const;
QUrl requestedUrl() const;
QString pageTitle() const;
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index e124f900..fa7243b2 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -432,10 +432,10 @@ QUrl QQuickWebEngineView::icon() const
return d->icon;
}
-void QQuickWebEngineView::loadHtml(const QString &html, const QUrl &baseUrl, const QUrl &unreachableUrl)
+void QQuickWebEngineView::loadHtml(const QString &html, const QUrl &baseUrl)
{
Q_D(QQuickWebEngineView);
- d->adapter->setContent(html.toUtf8(), QStringLiteral("text/html;charset=UTF-8"), baseUrl, unreachableUrl);
+ d->adapter->setContent(html.toUtf8(), QStringLiteral("text/html;charset=UTF-8"), baseUrl);
}
void QQuickWebEngineView::goBack()
diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h
index 5c239784..92cf1f53 100644
--- a/src/webengine/api/qquickwebengineview_p.h
+++ b/src/webengine/api/qquickwebengineview_p.h
@@ -112,7 +112,7 @@ public:
};
public Q_SLOTS:
- void loadHtml(const QString &html, const QUrl &baseUrl = QUrl(), const QUrl &unreachableUrl = QUrl());
+ void loadHtml(const QString &html, const QUrl &baseUrl = QUrl());
void goBack();
void goForward();
void reload();
diff --git a/src/webengine/doc/src/qquickwebengineview_lgpl.qdoc b/src/webengine/doc/src/qquickwebengineview_lgpl.qdoc
index a36f318f..91aef712 100644
--- a/src/webengine/doc/src/qquickwebengineview_lgpl.qdoc
+++ b/src/webengine/doc/src/qquickwebengineview_lgpl.qdoc
@@ -179,7 +179,7 @@
*/
/*!
- \qmlmethod void WebEngineView::loadHtml(string html, url baseUrl, url unreachableUrl)
+ \qmlmethod void WebEngineView::loadHtml(string html, url baseUrl)
\brief Loads the specified \a html as the content of the web view.
(This method offers a lower-level alternative to the \c{url} property,
@@ -191,10 +191,6 @@
and that was the base url, then an image referenced with the relative url \c diagram.png
would be looked for at \c{http://www.example.com/documents/diagram.png}.
- If an \a unreachableUrl is passed it is used as the url for the loaded
- content. This is typically used to display error pages for a failed
- load.
-
\sa WebEngineView::url
*/
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index 0006cbd4..2abfa4de 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -763,7 +763,7 @@ void QWebEnginePage::setHtml(const QString &html, const QUrl &baseUrl)
void QWebEnginePage::setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl)
{
Q_D(QWebEnginePage);
- d->adapter->setContent(data, mimeType, baseUrl, baseUrl);
+ d->adapter->setContent(data, mimeType, baseUrl);
}
QString QWebEnginePage::title() const
diff --git a/tests/auto/quick/publicapi/tst_publicapi.cpp b/tests/auto/quick/publicapi/tst_publicapi.cpp
index 507493e3..5cafc2bc 100644
--- a/tests/auto/quick/publicapi/tst_publicapi.cpp
+++ b/tests/auto/quick/publicapi/tst_publicapi.cpp
@@ -99,7 +99,6 @@ static QStringList expectedAPI = QStringList()
<< "QQuickWebEngineView.iconChanged() --> void"
<< "QQuickWebEngineView.linkHovered(QUrl) --> void"
<< "QQuickWebEngineView.navigationRequested(QQuickWebEngineNavigationRequest*) --> void"
- << "QQuickWebEngineView.loadHtml(QString,QUrl,QUrl) --> void"
<< "QQuickWebEngineView.loadHtml(QString,QUrl) --> void"
<< "QQuickWebEngineView.loadHtml(QString) --> void"
<< "QQuickWebEngineView.goBack() --> void"
diff --git a/tests/auto/quick/qmltests/data/tst_desktopBehaviorLoadHtml.qml b/tests/auto/quick/qmltests/data/tst_desktopBehaviorLoadHtml.qml
new file mode 100644
index 00000000..7b086044
--- /dev/null
+++ b/tests/auto/quick/qmltests/data/tst_desktopBehaviorLoadHtml.qml
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtTest 1.0
+import QtWebEngine 1.0
+
+TestWebEngineView {
+ id: webEngineView
+ width: 200
+ height: 400
+ focus: true
+
+ property string lastUrl
+
+ SignalSpy {
+ id: linkHoveredSpy
+ target: webEngineView
+ signalName: "linkHovered"
+ }
+
+ onLinkHovered: {
+ webEngineView.lastUrl = hoveredUrl
+ }
+
+ TestCase {
+ name: "DesktopWebEngineViewLoadHtml"
+
+ // Delayed windowShown to workaround problems with Qt5 in debug mode.
+ when: false
+ Timer {
+ running: parent.windowShown
+ repeat: false
+ interval: 1
+ onTriggered: parent.when = true
+ }
+
+ function init() {
+ webEngineView.lastUrl = ""
+ linkHoveredSpy.clear()
+ }
+
+ function test_baseUrlAfterLoadHtml() {
+ linkHoveredSpy.clear()
+ compare(linkHoveredSpy.count, 0)
+ mouseMove(webEngineView, 150, 300)
+ webEngineView.loadHtml("<html><head><title>Test page with huge link area</title></head><body><a title=\"A title\" href=\"test1.html\"><img width=200 height=200></a></body></html>", "http://www.example.foo.com")
+ verify(webEngineView.waitForLoadSucceeded())
+
+ // We get a linkHovered signal with empty hoveredUrl after page load
+ linkHoveredSpy.wait()
+ compare(linkHoveredSpy.count, 1)
+ compare(webEngineView.lastUrl, "")
+
+ compare(webEngineView.url, "http://www.example.foo.com/")
+ mouseMove(webEngineView, 100, 100)
+ linkHoveredSpy.wait()
+ compare(linkHoveredSpy.count, 2)
+ compare(webEngineView.lastUrl, "http://www.example.foo.com/test1.html")
+ }
+ }
+}
diff --git a/tests/auto/quick/qmltests/data/tst_loadUrl.qml b/tests/auto/quick/qmltests/data/tst_loadUrl.qml
index 796e7416..be7ede62 100644
--- a/tests/auto/quick/qmltests/data/tst_loadUrl.qml
+++ b/tests/auto/quick/qmltests/data/tst_loadUrl.qml
@@ -126,7 +126,7 @@ TestWebEngineView {
if (loadRequest.status == WebEngineView.LoadFailedStatus) {
compare(webEngineView.url, bogusSite)
compare(loadRequest.url, bogusSite)
- webEngineView.loadHtml("load failed", bogusSite, bogusSite)
+ webEngineView.loadHtml("load failed", bogusSite)
}
}
webEngineView.loadingChanged.connect(handleLoadFailed)
diff --git a/tests/auto/quick/qmltests/qmltests.pro b/tests/auto/quick/qmltests/qmltests.pro
index 23a2cbc5..b2661552 100644
--- a/tests/auto/quick/qmltests/qmltests.pro
+++ b/tests/auto/quick/qmltests/qmltests.pro
@@ -16,6 +16,7 @@ OTHER_FILES += \
$$PWD/data/small-favicon.png \
$$PWD/data/test1.html \
$$PWD/data/test3.html \
+ $$PWD/data/tst_desktopBehaviorLoadHtml.qml \
$$PWD/data/tst_favIconLoad.qml \
$$PWD/data/tst_linkHovered.qml \
$$PWD/data/tst_loadFail.qml \