summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-06-20 13:38:11 +0200
committerLiang Qi <liang.qi@qt.io>2016-06-20 18:27:44 +0200
commit25ccef35eb19fd656eba2a7abe5419972ed28552 (patch)
treee0c92532c3c70135d0a547675414e95d21a66822
parent3398abfc1b5b789d11592aada0b5860e36a50041 (diff)
parente91f09947b55dda8a13b2aeb0963836dee2ece8d (diff)
Merge remote-tracking branch 'origin/5.7' into dev
Conflicts: src/3rdparty src/core/permission_manager_qt.cpp src/core/renderer/web_channel_ipc_transport.cpp src/core/renderer/web_channel_ipc_transport.h Change-Id: I25fd8ed7c433dadce44d8ac1e39f86e211ec25f0
-rw-r--r--LICENSE.GPLv32
-rw-r--r--LICENSE.LGPL32
m---------src/3rdparty0
-rw-r--r--src/core/api/core_api.pro2
-rw-r--r--src/core/config/linux.pri2
-rw-r--r--src/core/core_module.pro23
-rw-r--r--src/core/gyp_run.pro2
-rw-r--r--src/core/permission_manager_qt.cpp9
-rw-r--r--src/core/render_widget_host_view_qt.cpp76
-rw-r--r--src/core/render_widget_host_view_qt.h1
-rw-r--r--src/core/renderer/web_channel_ipc_transport.cpp12
-rw-r--r--src/core/renderer/web_channel_ipc_transport.h2
-rw-r--r--src/core/resource_bundle_qt.cpp2
-rw-r--r--src/core/web_contents_adapter_client.h1
-rw-r--r--src/core/web_event_factory.cpp6
-rw-r--r--src/webengine/api/qquickwebengineprofile.h2
-rw-r--r--src/webengine/api/qquickwebengineview.cpp6
-rw-r--r--src/webengine/api/qquickwebengineview_p.h4
-rw-r--r--src/webengine/api/qquickwebengineview_p_p.h3
-rw-r--r--src/webengine/doc/src/qtwebengine-overview.qdoc4
-rw-r--r--src/webengine/plugin/plugins.qmltypes1
-rw-r--r--src/webengine/ui_delegates_manager.cpp27
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp6
-rw-r--r--src/webenginewidgets/api/qwebenginepage_p.h1
-rw-r--r--src/webenginewidgets/api/qwebenginesettings.h19
-rw-r--r--src/webenginewidgets/doc/src/qtwebkitportingguide.qdoc10
-rw-r--r--src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h2
-rw-r--r--tests/auto/quick/qmltests/data/TestWebEngineView.qml2
-rw-r--r--tests/auto/quick/qmltests/data/test4.html11
-rw-r--r--tests/auto/quick/qmltests/data/tst_filePicker.qml18
-rw-r--r--tests/auto/quick/qmltests/data/tst_scrollPosition.qml81
-rw-r--r--tests/auto/quick/qmltests/qmltests.pro1
-rw-r--r--tests/auto/widgets/qwebenginepage/BLACKLIST3
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp36
-rw-r--r--tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp25
35 files changed, 317 insertions, 87 deletions
diff --git a/LICENSE.GPLv3 b/LICENSE.GPLv3
index 4e49b122a..71c4ad49c 100644
--- a/LICENSE.GPLv3
+++ b/LICENSE.GPLv3
@@ -3,7 +3,7 @@
The Qt Toolkit is Copyright (C) 2015 The Qt Company Ltd.
Contact: http://www.qt.io/licensing/
- You may use, distribute and copy the Qt GUI Toolkit under the terms of
+ You may use, distribute and copy the Qt Toolkit under the terms of
GNU Lesser General Public License version 3. That license references
the General Public License version 3, that is displayed below. Other
portions of the Qt Toolkit may be licensed directly under this license.
diff --git a/LICENSE.LGPL3 b/LICENSE.LGPL3
index 26d0bf16f..1f78e0508 100644
--- a/LICENSE.LGPL3
+++ b/LICENSE.LGPL3
@@ -3,7 +3,7 @@
The Qt Toolkit is Copyright (C) 2015 The Qt Company Ltd.
Contact: http://www.qt.io/licensing/
- You may use, distribute and copy the Qt GUI Toolkit under the terms of
+ You may use, distribute and copy the Qt Toolkit under the terms of
GNU Lesser General Public License version 3, which is displayed below.
This license makes reference to the version 3 of the GNU General
Public License, which you can find in the LICENSE.GPLv3 file.
diff --git a/src/3rdparty b/src/3rdparty
-Subproject bb91a70e24ac49fd21c1d7c8c91a216961da1e2
+Subproject ac04c03fc89dbd789fd575b0cf38e7082fbe81a
diff --git a/src/core/api/core_api.pro b/src/core/api/core_api.pro
index a9f5adaba..6e2d606b2 100644
--- a/src/core/api/core_api.pro
+++ b/src/core/api/core_api.pro
@@ -15,7 +15,7 @@ CONFIG -= create_prl
# Copy this logic from qt_module.prf so that the intermediate library can be
# created to the same rules as the final module linking in core_module.pro.
!host_build:if(win32|mac):!macx-xcode {
- contains(QT_CONFIG, simulator_and_device): CONFIG += iphonesimulator_and_iphoneos
+ contains(QT_CONFIG, simulator_and_device): CONFIG += simulator_and_device
contains(QT_CONFIG, debug_and_release):CONFIG += debug_and_release
contains(QT_CONFIG, build_all):CONFIG += build_all
}
diff --git a/src/core/config/linux.pri b/src/core/config/linux.pri
index fcbdbe27a..a71d36c53 100644
--- a/src/core/config/linux.pri
+++ b/src/core/config/linux.pri
@@ -33,6 +33,8 @@ use?(nss) {
use_openssl_certs=1
}
+gcc:!clang: greaterThan(QT_GCC_MAJOR_VERSION, 5): GYP_CONFIG += v8_no_delete_null_pointer_checks=1
+
contains(QT_CONFIG, system-zlib): use?(system_minizip): GYP_CONFIG += use_system_zlib=1
contains(QT_CONFIG, system-png): GYP_CONFIG += use_system_libpng=1
contains(QT_CONFIG, system-jpeg): GYP_CONFIG += use_system_libjpeg=1
diff --git a/src/core/core_module.pro b/src/core/core_module.pro
index 702b92441..20b719547 100644
--- a/src/core/core_module.pro
+++ b/src/core/core_module.pro
@@ -89,29 +89,10 @@ icu.files = $$OUT_PWD/$$getConfigDir()/icudtl.dat
#
!use?(system_icu) {
- icudt2build.input = icu.files
- icudt2build.output = $$[QT_INSTALL_DATA/get]/resources/${QMAKE_FILE_BASE}${QMAKE_FILE_EXT}
- icudt2build.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT}
- icudt2build.name = COPY ${QMAKE_FILE_IN}
- icudt2build.CONFIG = no_link no_clean target_predeps
- QMAKE_EXTRA_COMPILERS += icudt2build
+ COPIES += icu
}
- resources2build.input = resources.files
- resources2build.output = $$[QT_INSTALL_DATA/get]/resources/${QMAKE_FILE_BASE}${QMAKE_FILE_EXT}
- resources2build.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT}
- resources2build.name = COPY ${QMAKE_FILE_IN}
- resources2build.CONFIG = no_link no_clean target_predeps
-
- QMAKE_EXTRA_COMPILERS += resources2build
-
- locales2build.input = locales.files
- locales2build.output = $$[QT_INSTALL_DATA/get]/translations/qtwebengine_locales/${QMAKE_FILE_BASE}${QMAKE_FILE_EXT}
- locales2build.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT}
- locales2build.name = COPY ${QMAKE_FILE_IN}
- locales2build.CONFIG = no_link no_clean target_predeps
-
- QMAKE_EXTRA_COMPILERS += locales2build
+ COPIES += resources locales
}
}
diff --git a/src/core/gyp_run.pro b/src/core/gyp_run.pro
index 35b85b4c7..a1b33e258 100644
--- a/src/core/gyp_run.pro
+++ b/src/core/gyp_run.pro
@@ -34,7 +34,7 @@ force_debug_info {
# Copy this logic from qt_module.prf so that ninja can run according
# to the same rules as the final module linking in core_module.pro.
!host_build:if(win32|mac):!macx-xcode {
- contains(QT_CONFIG, simulator_and_device): CONFIG += iphonesimulator_and_iphoneos
+ contains(QT_CONFIG, simulator_and_device): CONFIG += simulator_and_device
contains(QT_CONFIG, debug_and_release):CONFIG += debug_and_release
contains(QT_CONFIG, build_all):CONFIG += build_all
}
diff --git a/src/core/permission_manager_qt.cpp b/src/core/permission_manager_qt.cpp
index 1be276306..f76f100e6 100644
--- a/src/core/permission_manager_qt.cpp
+++ b/src/core/permission_manager_qt.cpp
@@ -55,14 +55,16 @@ BrowserContextAdapter::PermissionType toQt(content::PermissionType type)
switch (type) {
case content::PermissionType::GEOLOCATION:
return BrowserContextAdapter::GeolocationPermission;
+ case content::PermissionType::AUDIO_CAPTURE:
+ return BrowserContextAdapter::AudioCapturePermission;
+ case content::PermissionType::VIDEO_CAPTURE:
+ return BrowserContextAdapter::VideoCapturePermission;
case content::PermissionType::NOTIFICATIONS:
case content::PermissionType::MIDI_SYSEX:
case content::PermissionType::PUSH_MESSAGING:
case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER:
case content::PermissionType::MIDI:
case content::PermissionType::DURABLE_STORAGE:
- case content::PermissionType::AUDIO_CAPTURE:
- case content::PermissionType::VIDEO_CAPTURE:
case content::PermissionType::BACKGROUND_SYNC:
case content::PermissionType::NUM:
break;
@@ -116,6 +118,9 @@ int PermissionManagerQt::RequestPermission(content::PermissionType permission,
callback.Run(blink::mojom::PermissionStatus::DENIED);
return kNoPendingOperation;
}
+ // Audio and video-capture should not come this way currently
+ Q_ASSERT(permissionType != BrowserContextAdapter::AudioCapturePermission
+ && permissionType != BrowserContextAdapter::VideoCapturePermission);
content::WebContents *webContents = frameHost->GetRenderViewHost()->GetDelegate()->GetAsWebContents();
WebContentsDelegateQt* contentsDelegate = static_cast<WebContentsDelegateQt*>(webContents->GetDelegate());
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp
index d6f88f74f..91e503e6f 100644
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -71,6 +71,10 @@
#include "ui/events/gesture_detection/motion_event.h"
#include "ui/gfx/geometry/size_conversions.h"
+#if defined(USE_AURA)
+#include "ui/base/cursor/cursors_aura.h"
+#endif
+
#include <QEvent>
#include <QFocusEvent>
#include <QGuiApplication>
@@ -249,6 +253,7 @@ RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost* widget
RenderWidgetHostViewQt::~RenderWidgetHostViewQt()
{
+ QObject::disconnect(m_adapterClientDestroyedConnection);
#ifndef QT_NO_ACCESSIBILITY
QAccessible::removeActivationObserver(this);
#endif // QT_NO_ACCESSIBILITY
@@ -264,6 +269,10 @@ void RenderWidgetHostViewQt::setAdapterClient(WebContentsAdapterClient *adapterC
Q_ASSERT(!m_adapterClient);
m_adapterClient = adapterClient;
+ QObject::disconnect(m_adapterClientDestroyedConnection);
+ m_adapterClientDestroyedConnection = QObject::connect(adapterClient->holdingQObject(),
+ &QObject::destroyed, [this] {
+ m_adapterClient = nullptr; });
if (m_initPending)
InitAsChild(0);
}
@@ -430,7 +439,10 @@ void RenderWidgetHostViewQt::UpdateCursor(const content::WebCursor &webCursor)
{
content::WebCursor::CursorInfo cursorInfo;
webCursor.GetCursorInfo(&cursorInfo);
- Qt::CursorShape shape;
+ Qt::CursorShape shape = Qt::ArrowCursor;
+#if defined(USE_AURA)
+ int auraType = -1;
+#endif
switch (cursorInfo.type) {
case blink::WebCursorInfo::TypePointer:
shape = Qt::ArrowCursor;
@@ -488,17 +500,42 @@ void RenderWidgetHostViewQt::UpdateCursor(const content::WebCursor &webCursor)
case blink::WebCursorInfo::TypeMove:
shape = Qt::SizeAllCursor;
break;
+ case blink::WebCursorInfo::TypeProgress:
+ shape = Qt::BusyCursor;
+ break;
+#if defined(USE_AURA)
case blink::WebCursorInfo::TypeVerticalText:
+ auraType = ui::kCursorVerticalText;
+ break;
case blink::WebCursorInfo::TypeCell:
+ auraType = ui::kCursorCell;
+ break;
case blink::WebCursorInfo::TypeContextMenu:
+ auraType = ui::kCursorContextMenu;
+ break;
case blink::WebCursorInfo::TypeAlias:
- case blink::WebCursorInfo::TypeProgress:
+ auraType = ui::kCursorAlias;
+ break;
case blink::WebCursorInfo::TypeCopy:
+ auraType = ui::kCursorCopy;
+ break;
case blink::WebCursorInfo::TypeZoomIn:
+ auraType = ui::kCursorZoomIn;
+ break;
case blink::WebCursorInfo::TypeZoomOut:
- // FIXME: Load from the resource bundle.
- shape = Qt::ArrowCursor;
+ auraType = ui::kCursorZoomOut;
+ break;
+#else
+ case blink::WebCursorInfo::TypeVerticalText:
+ case blink::WebCursorInfo::TypeCell:
+ case blink::WebCursorInfo::TypeContextMenu:
+ case blink::WebCursorInfo::TypeAlias:
+ case blink::WebCursorInfo::TypeCopy:
+ case blink::WebCursorInfo::TypeZoomIn:
+ case blink::WebCursorInfo::TypeZoomOut:
+ // FIXME: Support on OS X
break;
+#endif
case blink::WebCursorInfo::TypeNoDrop:
case blink::WebCursorInfo::TypeNotAllowed:
shape = Qt::ForbiddenCursor;
@@ -515,16 +552,21 @@ void RenderWidgetHostViewQt::UpdateCursor(const content::WebCursor &webCursor)
case blink::WebCursorInfo::TypeCustom:
if (cursorInfo.custom_image.colorType() == SkColorType::kN32_SkColorType) {
QImage cursor = toQImage(cursorInfo.custom_image, QImage::Format_ARGB32);
- m_delegate->updateCursor(QCursor(QPixmap::fromImage(cursor)));
+ m_delegate->updateCursor(QCursor(QPixmap::fromImage(cursor), cursorInfo.hotspot.x(), cursorInfo.hotspot.y()));
return;
}
- // Use arrow cursor as fallback in case the Chromium implementation changes.
- shape = Qt::ArrowCursor;
break;
- default:
- Q_UNREACHABLE();
- shape = Qt::ArrowCursor;
}
+#if defined(USE_AURA)
+ if (auraType > 0) {
+ SkBitmap bitmap;
+ gfx::Point hotspot;
+ if (ui::GetCursorBitmap(auraType, &bitmap, &hotspot)) {
+ m_delegate->updateCursor(QCursor(QPixmap::fromImage(toQImage(bitmap)), hotspot.x(), hotspot.y()));
+ return;
+ }
+ }
+#endif
m_delegate->updateCursor(QCursor(shape));
}
@@ -870,7 +912,21 @@ bool RenderWidgetHostViewQt::IsPopup() const
void RenderWidgetHostViewQt::handleMouseEvent(QMouseEvent* event)
{
+ // Don't forward mouse events synthesized by the system, which are caused by genuine touch
+ // events. Chromium would then process for e.g. a mouse click handler twice, once due to the
+ // system synthesized mouse event, and another time due to a touch-to-gesture-to-mouse
+ // transformation done by Chromium.
+ if (event->source() == Qt::MouseEventSynthesizedBySystem)
+ return;
+
blink::WebMouseEvent webEvent = WebEventFactory::toWebMouseEvent(event, dpiScale());
+ if ((webEvent.type == blink::WebInputEvent::MouseDown || webEvent.type == blink::WebInputEvent::MouseUp)
+ && webEvent.button == blink::WebMouseEvent::ButtonNone) {
+ // Blink can only handle the 3 main mouse-buttons and may assert when processing mouse-down for no button.
+ return;
+ }
+
+
if (event->type() == QMouseEvent::MouseButtonPress) {
if (event->button() != m_clickHelper.lastPressButton
|| (event->timestamp() - m_clickHelper.lastPressTimestamp > static_cast<ulong>(qGuiApp->styleHints()->mouseDoubleClickInterval()))
diff --git a/src/core/render_widget_host_view_qt.h b/src/core/render_widget_host_view_qt.h
index befc86530..a6d34fd6a 100644
--- a/src/core/render_widget_host_view_qt.h
+++ b/src/core/render_widget_host_view_qt.h
@@ -222,6 +222,7 @@ private:
bool m_didFirstVisuallyNonEmptyLayout;
uint32_t m_pendingOutputSurfaceId;
+ QMetaObject::Connection m_adapterClientDestroyedConnection;
WebContentsAdapterClient *m_adapterClient;
MultipleMouseClickHelper m_clickHelper;
diff --git a/src/core/renderer/web_channel_ipc_transport.cpp b/src/core/renderer/web_channel_ipc_transport.cpp
index f965c2cc7..3a44bb182 100644
--- a/src/core/renderer/web_channel_ipc_transport.cpp
+++ b/src/core/renderer/web_channel_ipc_transport.cpp
@@ -155,8 +155,8 @@ content::RenderView *WebChannelTransport::GetRenderView(v8::Isolate *isolate)
WebChannelIPCTransport::WebChannelIPCTransport(content::RenderView *renderView)
: content::RenderViewObserver(renderView)
, content::RenderViewObserverTracker<WebChannelIPCTransport>(renderView)
- , m_worldId(0)
, m_installed(false)
+ , m_installedWorldId(0)
{
}
@@ -166,28 +166,28 @@ void WebChannelIPCTransport::RunScriptsAtDocumentStart(content::RenderFrame *ren
// ### FIXME: we should try no even installing before
blink::WebLocalFrame *frame = render_frame->GetWebFrame();
if (m_installed && render_frame->IsMainFrame())
- WebChannelTransport::Install(frame, m_worldId);
+ WebChannelTransport::Install(frame, m_installedWorldId);
}
void WebChannelIPCTransport::installWebChannel(uint worldId)
{
- m_worldId = worldId;
- m_installed = true;
blink::WebView *webView = render_view()->GetWebView();
if (!webView)
return;
WebChannelTransport::Install(webView->mainFrame(), worldId);
+ m_installed = true;
+ m_installedWorldId = worldId;
}
void WebChannelIPCTransport::uninstallWebChannel(uint worldId)
{
- Q_ASSERT(worldId = m_worldId);
- m_installed = false;
+ Q_ASSERT(worldId = m_installedWorldId);
blink::WebView *webView = render_view()->GetWebView();
if (!webView)
return;
WebChannelTransport::Uninstall(webView->mainFrame(), worldId);
+ m_installed = false;
}
void WebChannelIPCTransport::dispatchWebChannelMessage(const std::vector<char> &binaryJSON, uint worldId)
diff --git a/src/core/renderer/web_channel_ipc_transport.h b/src/core/renderer/web_channel_ipc_transport.h
index 81e64bb0f..ae3f16cac 100644
--- a/src/core/renderer/web_channel_ipc_transport.h
+++ b/src/core/renderer/web_channel_ipc_transport.h
@@ -69,8 +69,8 @@ private:
void uninstallWebChannel(uint worldId);
virtual bool OnMessageReceived(const IPC::Message &message) Q_DECL_OVERRIDE;
- uint m_worldId;
bool m_installed;
+ uint m_installedWorldId;
};
} // namespace
diff --git a/src/core/resource_bundle_qt.cpp b/src/core/resource_bundle_qt.cpp
index 5872e778a..ba25cc543 100644
--- a/src/core/resource_bundle_qt.cpp
+++ b/src/core/resource_bundle_qt.cpp
@@ -50,7 +50,7 @@ void ResourceBundle::LoadCommonResources()
AddDataPackFromPath(WebEngineLibraryInfo::getPath(QT_RESOURCES_PAK), SCALE_FACTOR_NONE);
AddDataPackFromPath(WebEngineLibraryInfo::getPath(QT_RESOURCES_100P_PAK), SCALE_FACTOR_100P);
AddDataPackFromPath(WebEngineLibraryInfo::getPath(QT_RESOURCES_200P_PAK), SCALE_FACTOR_200P);
- AddDataPackFromPath(WebEngineLibraryInfo::getPath(QT_RESOURCES_DEVTOOLS_PAK), SCALE_FACTOR_NONE);
+ AddOptionalDataPackFromPath(WebEngineLibraryInfo::getPath(QT_RESOURCES_DEVTOOLS_PAK), SCALE_FACTOR_NONE);
}
gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id)
diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h
index c50f38b38..7be9ca7b9 100644
--- a/src/core/web_contents_adapter_client.h
+++ b/src/core/web_contents_adapter_client.h
@@ -258,6 +258,7 @@ public:
virtual void startDragging(const content::DropData &dropData, Qt::DropActions allowedActions,
const QPixmap &pixmap, const QPoint &offset) = 0;
virtual bool isEnabled() const = 0;
+ virtual const QObject *holdingQObject() const = 0;
virtual QSharedPointer<BrowserContextAdapter> browserContextAdapter() = 0;
virtual WebContentsAdapter* webContentsAdapter() = 0;
diff --git a/src/core/web_event_factory.cpp b/src/core/web_event_factory.cpp
index fddafd1d3..505a684eb 100644
--- a/src/core/web_event_factory.cpp
+++ b/src/core/web_event_factory.cpp
@@ -486,11 +486,11 @@ static inline double currentTimeForEvent(const QInputEvent* event)
static WebMouseEvent::Button mouseButtonForEvent(QMouseEvent *event)
{
- if (event->button() == Qt::LeftButton || (event->buttons() & Qt::LeftButton))
+ if (event->button() == Qt::LeftButton)
return WebMouseEvent::ButtonLeft;
- else if (event->button() == Qt::RightButton || (event->buttons() & Qt::RightButton))
+ else if (event->button() == Qt::RightButton)
return WebMouseEvent::ButtonRight;
- else if (event->button() == Qt::MidButton || (event->buttons() & Qt::MidButton))
+ else if (event->button() == Qt::MidButton)
return WebMouseEvent::ButtonMiddle;
return WebMouseEvent::ButtonNone;
}
diff --git a/src/webengine/api/qquickwebengineprofile.h b/src/webengine/api/qquickwebengineprofile.h
index 9240132b2..dc5aa7df8 100644
--- a/src/webengine/api/qquickwebengineprofile.h
+++ b/src/webengine/api/qquickwebengineprofile.h
@@ -127,7 +127,7 @@ public:
void removeUrlSchemeHandler(QWebEngineUrlSchemeHandler *);
void removeAllUrlSchemeHandlers();
- void clearHttpCache();
+ Q_REVISION(2) Q_INVOKABLE void clearHttpCache();
static QQuickWebEngineProfile *defaultProfile();
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index 59b5d17db..ac25cd4d2 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -670,6 +670,12 @@ WebEngineSettings *QQuickWebEngineViewPrivate::webEngineSettings() const
return m_settings->d_ptr.data();
}
+const QObject *QQuickWebEngineViewPrivate::holdingQObject() const
+{
+ Q_Q(const QQuickWebEngineView);
+ return q;
+}
+
void QQuickWebEngineViewPrivate::setDevicePixelRatio(qreal devicePixelRatio)
{
Q_Q(QQuickWebEngineView);
diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h
index b72f79f30..b9555d2d9 100644
--- a/src/webengine/api/qquickwebengineview_p.h
+++ b/src/webengine/api/qquickwebengineview_p.h
@@ -503,8 +503,8 @@ Q_SIGNALS:
Q_REVISION(3) void webChannelWorldChanged(uint);
protected:
- void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
- void itemChange(ItemChange, const ItemChangeData &);
+ void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
+ void itemChange(ItemChange, const ItemChangeData &) Q_DECL_OVERRIDE;
void dragEnterEvent(QDragEnterEvent *e) Q_DECL_OVERRIDE;
void dragLeaveEvent(QDragLeaveEvent *e) Q_DECL_OVERRIDE;
void dragMoveEvent(QDragMoveEvent *e) Q_DECL_OVERRIDE;
diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h
index 909763614..1b5198110 100644
--- a/src/webengine/api/qquickwebengineview_p_p.h
+++ b/src/webengine/api/qquickwebengineview_p_p.h
@@ -175,7 +175,7 @@ public:
virtual QObject *accessibilityParentObject() Q_DECL_OVERRIDE;
#endif // QT_NO_ACCESSIBILITY
virtual QtWebEngineCore::WebEngineSettings *webEngineSettings() const Q_DECL_OVERRIDE;
- virtual void allowCertificateError(const QSharedPointer<CertificateErrorController> &errorController);
+ virtual void allowCertificateError(const QSharedPointer<CertificateErrorController> &errorController) Q_DECL_OVERRIDE;
virtual void runGeolocationPermissionRequest(QUrl const&) Q_DECL_OVERRIDE;
virtual void showValidationMessage(const QRect &anchor, const QString &mainText, const QString &subText) Q_DECL_OVERRIDE;
virtual void hideValidationMessage() Q_DECL_OVERRIDE;
@@ -188,6 +188,7 @@ public:
void startDragging(const content::DropData &dropData, Qt::DropActions allowedActions,
const QPixmap &pixmap, const QPoint &offset) Q_DECL_OVERRIDE;
virtual bool isEnabled() const Q_DECL_OVERRIDE;
+ const QObject *holdingQObject() const Q_DECL_OVERRIDE;
virtual QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContextAdapter() Q_DECL_OVERRIDE;
QtWebEngineCore::WebContentsAdapter *webContentsAdapter() Q_DECL_OVERRIDE;
diff --git a/src/webengine/doc/src/qtwebengine-overview.qdoc b/src/webengine/doc/src/qtwebengine-overview.qdoc
index 7ae3afaf4..064dfb44b 100644
--- a/src/webengine/doc/src/qtwebengine-overview.qdoc
+++ b/src/webengine/doc/src/qtwebengine-overview.qdoc
@@ -104,8 +104,8 @@
\l{https://chromium.googlesource.com/chromium/src/+/master/docs/chromium_browser_vs_google_chrome.md}{overview}
that is part of the documentation in the \l {Chromium Project} upstream source tree.
- This version of Qt WebEngine is based on Chromium snapshot version 45.0.2554.101, with
- additional security fixes from the 46, 47 and 48 branches of the \l {Chromium Project}.
+ This version of Qt WebEngine is based on Chromium version 45.0.2554.101, with
+ additional security fixes from newer versions.
\section2 Qt WebEngine Process
diff --git a/src/webengine/plugin/plugins.qmltypes b/src/webengine/plugin/plugins.qmltypes
index fa35b141e..23ba77235 100644
--- a/src/webengine/plugin/plugins.qmltypes
+++ b/src/webengine/plugin/plugins.qmltypes
@@ -225,6 +225,7 @@ Module {
name: "downloadFinished"
Parameter { name: "download"; type: "QQuickWebEngineDownloadItem"; isPointer: true }
}
+ Method { name: "clearHttpCache"; revision: 2 }
}
Component {
name: "QQuickWebEngineScript"
diff --git a/src/webengine/ui_delegates_manager.cpp b/src/webengine/ui_delegates_manager.cpp
index a82ed0f2e..6ff12b53f 100644
--- a/src/webengine/ui_delegates_manager.cpp
+++ b/src/webengine/ui_delegates_manager.cpp
@@ -209,7 +209,7 @@ void UIDelegatesManager::addMenuSeparator(QObject *menu)
QObject *UIDelegatesManager::addMenu(QObject *parentMenu, const QString &title, const QPoint& pos)
{
-
+ Q_ASSERT(parentMenu);
if (!ensureComponentLoaded(Menu))
return 0;
QQmlContext *context = qmlContext(m_view);
@@ -222,18 +222,18 @@ QObject *UIDelegatesManager::addMenu(QObject *parentMenu, const QString &title,
QQmlProperty(menu, QStringLiteral("title")).write(title);
if (!pos.isNull())
QQmlProperty(menu, QStringLiteral("pos")).write(pos);
- if (!parentMenu) {
- QQmlProperty doneSignal(menu, QStringLiteral("onDone"));
- static int deleteLaterIndex = menu->metaObject()->indexOfSlot("deleteLater()");
- if (doneSignal.isSignalProperty())
- QObject::connect(menu, doneSignal.method(), menu, menu->metaObject()->method(deleteLaterIndex));
- } else {
- menu->setParent(parentMenu);
- QQmlListReference entries(parentMenu, defaultPropertyName(parentMenu), qmlEngine(m_view));
- if (entries.isValid())
- entries.append(menu);
- }
+ menu->setParent(parentMenu);
+
+ QQmlProperty doneSignal(menu, QStringLiteral("onDone"));
+ static int deleteLaterIndex = menu->metaObject()->indexOfSlot("deleteLater()");
+ CHECK_QML_SIGNAL_PROPERTY(doneSignal, menuComponent->url());
+ QObject::connect(menu, doneSignal.method(), menu, menu->metaObject()->method(deleteLaterIndex));
+
+ QQmlListReference entries(parentMenu, defaultPropertyName(parentMenu), qmlEngine(m_view));
+ if (entries.isValid())
+ entries.append(menu);
+
menuComponent->completeCreate();
return menu;
}
@@ -401,9 +401,12 @@ void UIDelegatesManager::showDialog(QSharedPointer<AuthenticationDialogControlle
CHECK_QML_SIGNAL_PROPERTY(rejectSignal, authenticationDialogComponent->url());
static int acceptIndex = dialogController->metaObject()->indexOfSlot("accept(QString,QString)");
+ static int deleteLaterIndex = authenticationDialog->metaObject()->indexOfSlot("deleteLater()");
QObject::connect(authenticationDialog, acceptSignal.method(), dialogController.data(), dialogController->metaObject()->method(acceptIndex));
+ QObject::connect(authenticationDialog, acceptSignal.method(), authenticationDialog, authenticationDialog->metaObject()->method(deleteLaterIndex));
static int rejectIndex = dialogController->metaObject()->indexOfSlot("reject()");
QObject::connect(authenticationDialog, rejectSignal.method(), dialogController.data(), dialogController->metaObject()->method(rejectIndex));
+ QObject::connect(authenticationDialog, rejectSignal.method(), authenticationDialog, authenticationDialog->metaObject()->method(deleteLaterIndex));
authenticationDialogComponent->completeCreate();
QMetaObject::invokeMethod(authenticationDialog, "open");
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index 8a9f04860..63fb6eb44 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -494,6 +494,12 @@ WebContentsAdapter *QWebEnginePagePrivate::webContentsAdapter()
return adapter.data();
}
+const QObject *QWebEnginePagePrivate::holdingQObject() const
+{
+ Q_Q(const QWebEnginePage);
+ return q;
+}
+
QWebEnginePage::QWebEnginePage(QObject* parent)
: QObject(parent)
, d_ptr(new QWebEnginePagePrivate())
diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h
index 26ef80e9a..c0b1b9a4e 100644
--- a/src/webenginewidgets/api/qwebenginepage_p.h
+++ b/src/webenginewidgets/api/qwebenginepage_p.h
@@ -136,6 +136,7 @@ public:
void startDragging(const content::DropData &dropData, Qt::DropActions allowedActions,
const QPixmap &pixmap, const QPoint &offset) Q_DECL_OVERRIDE;
virtual bool isEnabled() const Q_DECL_OVERRIDE;
+ const QObject *holdingQObject() const Q_DECL_OVERRIDE;
virtual QSharedPointer<QtWebEngineCore::BrowserContextAdapter> browserContextAdapter() Q_DECL_OVERRIDE;
QtWebEngineCore::WebContentsAdapter *webContentsAdapter() Q_DECL_OVERRIDE;
diff --git a/src/webenginewidgets/api/qwebenginesettings.h b/src/webenginewidgets/api/qwebenginesettings.h
index 0ba728c94..8eda50ee2 100644
--- a/src/webenginewidgets/api/qwebenginesettings.h
+++ b/src/webenginewidgets/api/qwebenginesettings.h
@@ -5,7 +5,7 @@
**
** This file is part of the QtWebEngine module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** $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
@@ -14,13 +14,24 @@
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
diff --git a/src/webenginewidgets/doc/src/qtwebkitportingguide.qdoc b/src/webenginewidgets/doc/src/qtwebkitportingguide.qdoc
index 89d7cfb0c..f652b1d5f 100644
--- a/src/webenginewidgets/doc/src/qtwebkitportingguide.qdoc
+++ b/src/webenginewidgets/doc/src/qtwebkitportingguide.qdoc
@@ -207,7 +207,15 @@
connect(&page, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)), this, SLOT(authenticate(QNetworkReply*,QAuthenticator*)));
\endcode
- This also affects the way in which certificates are managed. For more information, see
+ \note In Qt WebEngine, the QAuthenticator must be explicitly set to null to
+ cancel authentication:
+
+ \code
+ *authenticator = QAuthenticator();
+ \endcode
+
+ Omitting the \c QNetworkAccessManager also affects the way in which
+ certificates are managed. For more information, see
\l {Managing Certificates}.
\section1 Notes About Individual Methods
diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h
index e98e06417..9fd0cdc48 100644
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h
+++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h
@@ -91,7 +91,7 @@ protected:
void initializeGL() Q_DECL_OVERRIDE;
void paintGL() Q_DECL_OVERRIDE;
- QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
+ QVariant inputMethodQuery(Qt::InputMethodQuery query) const Q_DECL_OVERRIDE;
private slots:
void onWindowPosChanged();
diff --git a/tests/auto/quick/qmltests/data/TestWebEngineView.qml b/tests/auto/quick/qmltests/data/TestWebEngineView.qml
index 34fc5fb2f..0d2a34645 100644
--- a/tests/auto/quick/qmltests/data/TestWebEngineView.qml
+++ b/tests/auto/quick/qmltests/data/TestWebEngineView.qml
@@ -28,7 +28,7 @@
import QtQuick 2.0
import QtTest 1.0
-import QtWebEngine 1.2
+import QtWebEngine 1.3
WebEngineView {
property var loadStatus: null
diff --git a/tests/auto/quick/qmltests/data/test4.html b/tests/auto/quick/qmltests/data/test4.html
index 8f75af606..142b53668 100644
--- a/tests/auto/quick/qmltests/data/test4.html
+++ b/tests/auto/quick/qmltests/data/test4.html
@@ -12,6 +12,17 @@
<meta name="viewport" content="initial-scale=2.0"/>
</head>
<body>
+ <button onclick="scrollWin()", id="scroll">Click me to scroll!</button><br><br>
+
+ <script>
+ window.onload = function() {
+ document.getElementById("scroll").focus();
+ }
+
+ function scrollWin() {
+ window.scrollTo(0, 600);
+ }
+ </script>
<div id="content">
bla00<br/>
bla01<br/>
diff --git a/tests/auto/quick/qmltests/data/tst_filePicker.qml b/tests/auto/quick/qmltests/data/tst_filePicker.qml
index 117141935..4e74af733 100644
--- a/tests/auto/quick/qmltests/data/tst_filePicker.qml
+++ b/tests/auto/quick/qmltests/data/tst_filePicker.qml
@@ -68,10 +68,8 @@ TestWebEngineView {
FilePickerParams.selectedFilesUrl.push(Qt.resolvedUrl("test1.html"))
keyPress(Qt.Key_Enter) // Focus is on the button. Open FileDialog.
- wait(100) // The ui delegate is invoked asynchronously
- verify(FilePickerParams.filePickerOpened)
- titleSpy.wait()
- compare(webEngineView.title, "test1.html")
+ tryCompare(FilePickerParams, "filePickerOpened", true)
+ tryCompare(webEngineView, "title", "test1.html")
}
function test_acceptMultipleFilesSelection() {
@@ -83,10 +81,8 @@ TestWebEngineView {
FilePickerParams.selectedFilesUrl.push(Qt.resolvedUrl("test2.html"))
keyPress(Qt.Key_Enter) // Focus is on the button. Open FileDialog.
- wait(100)
- verify(FilePickerParams.filePickerOpened)
- titleSpy.wait()
- compare(webEngineView.title, "test1.html,test2.html")
+ tryCompare(FilePickerParams, "filePickerOpened", true)
+ tryCompare(webEngineView, "title", "test1.html,test2.html")
}
function test_acceptDirectory() {
@@ -97,10 +93,8 @@ TestWebEngineView {
FilePickerParams.selectedFilesUrl.push(Qt.resolvedUrl("../data"))
keyPress(Qt.Key_Enter) // Focus is on the button. Open FileDialog.
- wait(100) // The ui delegate is invoked asynchronously
- verify(FilePickerParams.filePickerOpened)
- titleSpy.wait()
- compare(webEngineView.title, "data")
+ tryCompare(FilePickerParams, "filePickerOpened", true)
+ tryCompare(webEngineView, "title", "data")
}
function test_reject() {
diff --git a/tests/auto/quick/qmltests/data/tst_scrollPosition.qml b/tests/auto/quick/qmltests/data/tst_scrollPosition.qml
new file mode 100644
index 000000000..08bb0f3b4
--- /dev/null
+++ b/tests/auto/quick/qmltests/data/tst_scrollPosition.qml
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+import QtTest 1.0
+import QtWebEngine 1.3
+
+TestWebEngineView {
+ id: webEngineView
+ width: 300
+ height: 400
+
+ property var testUrl: Qt.resolvedUrl("test4.html")
+
+ SignalSpy {
+ id: scrollPositionSpy
+ target: webEngineView
+ signalName: "onScrollPositionChanged"
+ }
+
+ TestCase {
+ name: "ScrollPosition"
+ when: windowShown
+
+ function init() {
+ webEngineView.url = Qt.resolvedUrl("about:blank");
+ verify(webEngineView.waitForLoadSucceeded());
+ }
+
+ function test_scrollPosition() {
+ webEngineView.url = testUrl;
+ verify(webEngineView.waitForLoadSucceeded());
+
+ keyPress(Qt.Key_Return); // Focus is on the scroll button.
+
+ tryCompare(scrollPositionSpy, "count", 1);
+ compare(webEngineView.scrollPosition.x, 0);
+ compare(webEngineView.scrollPosition.y, 600);
+ }
+
+ function test_scrollPositionAfterReload() {
+ webEngineView.url = testUrl;
+ verify(webEngineView.waitForLoadSucceeded());
+ tryCompare(webEngineView.scrollPosition, "y", 0);
+
+ keyPress(Qt.Key_Return); // Focus is on the scroll button.
+ scrollPositionSpy.wait();
+
+ webEngineView.reload();
+ verify(webEngineView.waitForLoadSucceeded());
+
+ tryCompare(webEngineView.scrollPosition, "x", 0);
+ tryCompare(webEngineView.scrollPosition, "y", 600);
+ }
+ }
+}
diff --git a/tests/auto/quick/qmltests/qmltests.pro b/tests/auto/quick/qmltests/qmltests.pro
index 64f7414ce..0158a7268 100644
--- a/tests/auto/quick/qmltests/qmltests.pro
+++ b/tests/auto/quick/qmltests/qmltests.pro
@@ -59,6 +59,7 @@ OTHER_FILES += \
$$PWD/data/tst_navigationRequested.qml \
$$PWD/data/tst_properties.qml \
$$PWD/data/tst_runJavaScript.qml \
+ $$PWD/data/tst_scrollPosition.qml \
$$PWD/data/tst_titleChanged.qml \
$$PWD/data/tst_unhandledKeyEventPropagation.qml \
$$PWD/data/tst_userScripts.qml \
diff --git a/tests/auto/widgets/qwebenginepage/BLACKLIST b/tests/auto/widgets/qwebenginepage/BLACKLIST
index fcd36ba83..507fb7dbd 100644
--- a/tests/auto/widgets/qwebenginepage/BLACKLIST
+++ b/tests/auto/widgets/qwebenginepage/BLACKLIST
@@ -1,2 +1,5 @@
[macCopyUnicodeToClipboard]
osx
+
+[getUserMediaRequest]
+windows
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
index b39c07fc2..2461a588b 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
@@ -236,6 +236,7 @@ private Q_SLOTS:
void toPlainTextLoadFinishedRace_data();
void toPlainTextLoadFinishedRace();
void setZoomFactor();
+ void mouseButtonTranslation();
void printToPdf();
@@ -4886,5 +4887,40 @@ void tst_QWebEnginePage::printToPdf()
QCOMPARE(failedInvalidLayoutSpy.waitForResult().length(), 0);
}
+void tst_QWebEnginePage::mouseButtonTranslation()
+{
+ QWebEngineView *view = new QWebEngineView;
+
+ QSignalSpy spy(view, SIGNAL(loadFinished(bool)));
+ view->setHtml(QStringLiteral(
+ "<html><head><script>\
+ var lastEvent = { 'button' : -1 }; \
+ function saveLastEvent(event) { console.log(event); lastEvent = event; }; \
+ </script></head>\
+ <body>\
+ <div style=\"height:600px;\" onmousedown=\"saveLastEvent(event)\">\
+ </div>\
+ </body></html>"));
+ view->show();
+ QTest::qWaitForWindowExposed(view);
+ QTRY_VERIFY(spy.count() == 1);
+
+ QVERIFY(view->focusProxy() != nullptr);
+
+ QMouseEvent evpres(QEvent::MouseButtonPress, view->rect().center(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
+ QGuiApplication::sendEvent(view->focusProxy(), &evpres);
+
+ QTRY_COMPARE(evaluateJavaScriptSync(view->page(), "lastEvent.button").toInt(), 0);
+ QCOMPARE(evaluateJavaScriptSync(view->page(), "lastEvent.buttons").toInt(), 1);
+
+ QMouseEvent evpres2(QEvent::MouseButtonPress, view->rect().center(), Qt::RightButton, Qt::LeftButton | Qt::RightButton, Qt::NoModifier);
+ QGuiApplication::sendEvent(view->focusProxy(), &evpres2);
+
+ QTRY_COMPARE(evaluateJavaScriptSync(view->page(), "lastEvent.button").toInt(), 2);
+ QCOMPARE(evaluateJavaScriptSync(view->page(), "lastEvent.buttons").toInt(), 3);
+
+ delete view;
+}
+
QTEST_MAIN(tst_QWebEnginePage)
#include "tst_qwebenginepage.moc"
diff --git a/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp b/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp
index ad10234f4..d5ecd8841 100644
--- a/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp
+++ b/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp
@@ -37,6 +37,7 @@ private Q_SLOTS:
void scriptModifications();
void webChannel_data();
void webChannel();
+ void noTransportWithoutWebChannel();
};
void tst_QWebEngineScript::domEditing()
@@ -180,13 +181,17 @@ private:
void tst_QWebEngineScript::webChannel_data()
{
QTest::addColumn<int>("worldId");
- QTest::newRow("MainWorld") << static_cast<int>(QWebEngineScript::MainWorld);
- QTest::newRow("ApplicationWorld") << static_cast<int>(QWebEngineScript::ApplicationWorld);
+ QTest::addColumn<bool>("reloadFirst");
+ QTest::newRow("MainWorld") << static_cast<int>(QWebEngineScript::MainWorld) << false;
+ QTest::newRow("ApplicationWorld") << static_cast<int>(QWebEngineScript::ApplicationWorld) << false;
+ QTest::newRow("MainWorldWithReload") << static_cast<int>(QWebEngineScript::MainWorld) << true;
+ QTest::newRow("ApplicationWorldWithReload") << static_cast<int>(QWebEngineScript::ApplicationWorld) << true;
}
void tst_QWebEngineScript::webChannel()
{
QFETCH(int, worldId);
+ QFETCH(bool, reloadFirst);
QWebEnginePage page;
TestObject testObject;
QScopedPointer<QWebChannel> channel(new QWebChannel(this));
@@ -205,6 +210,11 @@ void tst_QWebEngineScript::webChannel()
page.scripts().insert(script);
page.setHtml(QStringLiteral("<html><body></body></html>"));
waitForSignal(&page, SIGNAL(loadFinished(bool)));
+ if (reloadFirst) {
+ // Check that the transport is also reinstalled on navigation
+ page.triggerAction(QWebEnginePage::Reload);
+ waitForSignal(&page, SIGNAL(loadFinished(bool)));
+ }
page.runJavaScript(QLatin1String(
"new QWebChannel(qt.webChannelTransport,"
" function(channel) {"
@@ -218,6 +228,17 @@ void tst_QWebEngineScript::webChannel()
QCOMPARE(evaluateJavaScriptSync(&page, "qt.webChannelTransport"), QVariant(QVariant::Invalid));
}
+void tst_QWebEngineScript::noTransportWithoutWebChannel()
+{
+ QWebEnginePage page;
+ page.setHtml(QStringLiteral("<html><body></body></html>"));
+
+ QCOMPARE(evaluateJavaScriptSync(&page, "qt.webChannelTransport"), QVariant(QVariant::Invalid));
+ page.triggerAction(QWebEnginePage::Reload);
+ waitForSignal(&page, SIGNAL(loadFinished(bool)));
+ QCOMPARE(evaluateJavaScriptSync(&page, "qt.webChannelTransport"), QVariant(QVariant::Invalid));
+}
+
QTEST_MAIN(tst_QWebEngineScript)
#include "tst_qwebenginescript.moc"