summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2019-07-10 10:31:31 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2019-07-11 16:23:56 +0200
commit59cccabf1dce66304b0ed7d5e66305dd35b7f29c (patch)
tree5539faab39cbb372a1530b115e9b9dc1e09492ae
parent4746bb904bf6841137d5b50357bf79c852bf5d06 (diff)
parenta4cef2531fc29d874cec9613e2d2ad7ccd5ad937 (diff)
Merge "Merge remote-tracking branch 'origin/5.12' into 5.13"
-rw-r--r--src/core/api/qtwebenginecoreglobal.cpp2
-rw-r--r--src/core/core_module.pro14
-rw-r--r--src/core/web_contents_delegate_qt.cpp5
-rw-r--r--src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp12
-rw-r--r--tests/auto/quick/inspectorserver/tst_inspectorserver.cpp2
-rw-r--r--tests/auto/quick/qmltests/BLACKLIST9
-rw-r--r--tests/auto/quick/qquickwebengineview/BLACKLIST12
-rw-r--r--tests/auto/widgets/qwebenginepage/BLACKLIST3
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp66
-rw-r--r--tests/auto/widgets/qwebengineview/BLACKLIST3
10 files changed, 86 insertions, 42 deletions
diff --git a/src/core/api/qtwebenginecoreglobal.cpp b/src/core/api/qtwebenginecoreglobal.cpp
index ad52d09ad..25d0bd3be 100644
--- a/src/core/api/qtwebenginecoreglobal.cpp
+++ b/src/core/api/qtwebenginecoreglobal.cpp
@@ -80,6 +80,8 @@ static QOpenGLContext *shareContext;
static void deleteShareContext()
{
+ if (qt_gl_global_share_context() == shareContext)
+ qt_gl_set_global_share_context(nullptr);
delete shareContext;
shareContext = 0;
}
diff --git a/src/core/core_module.pro b/src/core/core_module.pro
index 02aa6ac38..b220af4a5 100644
--- a/src/core/core_module.pro
+++ b/src/core/core_module.pro
@@ -42,11 +42,15 @@ LIBS_PRIVATE += $$NINJA_LIB_DIRS $$NINJA_LIBS
unix:qtConfig(webengine-noexecstack): \
QMAKE_LFLAGS += -Wl,-z,noexecstack
linux {
- QMAKE_LFLAGS += -Wl,--gc-sections -Wl,-O1 -Wl,-z,now
- # Embedded address sanitizer symbols are undefined and are picked up by the dynamic link loader
- # at runtime. Thus we do not to pass the linker flag below, because the linker would complain
- # about the undefined sanitizer symbols.
- !sanitizer: QMAKE_LFLAGS += -Wl,-z,defs
+ # add chromium flags
+ for(flag, NINJA_LFLAGS) {
+ # filter out some flags
+ !contains(flag, .*noexecstack$): \
+ !contains(flag, .*as-needed$): \
+ !contains(flag, ^-B.*): \
+ !contains(flag, ^-fuse-ld.*): \
+ QMAKE_LFLAGS += $$flag
+ }
} else {
QMAKE_LFLAGS += $$NINJA_LFLAGS
}
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
index c8fac0d54..f260a17b9 100644
--- a/src/core/web_contents_delegate_qt.cpp
+++ b/src/core/web_contents_delegate_qt.cpp
@@ -232,6 +232,11 @@ void WebContentsDelegateQt::AddNewContents(content::WebContents* source, std::un
{
Q_UNUSED(source)
QSharedPointer<WebContentsAdapter> newAdapter = createWindow(std::move(new_contents), disposition, initial_pos, user_gesture);
+ // Chromium can forget to pass user-agent override settings to new windows (see QTBUG-61774 and QTBUG-76249),
+ // so set it here. Note the actual value doesn't really matter here. Only the second value does, but we try
+ // to give the correct user-agent anyway.
+ if (newAdapter)
+ newAdapter->webContents()->SetUserAgentOverride(newAdapter->profileAdapter()->httpUserAgent().toStdString(), true);
if (newAdapter && !newAdapter->isInitialized())
newAdapter->loadDefault();
if (was_blocked)
diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
index 817d6e408..88eb9843b 100644
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
+++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
@@ -77,14 +77,6 @@ protected:
{
m_client->forwardEvent(event);
}
- void keyPressEvent(QKeyEvent *event) override
- {
- m_client->forwardEvent(event);
- }
- void keyReleaseEvent(QKeyEvent *event) override
- {
- m_client->forwardEvent(event);
- }
void inputMethodEvent(QInputMethodEvent *event) override
{
m_client->forwardEvent(event);
@@ -479,7 +471,7 @@ bool RenderWidgetHostViewQtDelegateWidget::event(QEvent *event)
// where we can simply ignore the DblClick event.
QMouseEvent *dblClick = static_cast<QMouseEvent *>(event);
QMouseEvent press(QEvent::MouseButtonPress, dblClick->localPos(), dblClick->windowPos(), dblClick->screenPos(),
- dblClick->button(), dblClick->buttons(), dblClick->modifiers());
+ dblClick->button(), dblClick->buttons(), dblClick->modifiers(), dblClick->source());
press.setTimestamp(dblClick->timestamp());
handled = m_client->forwardEvent(&press);
} else
@@ -487,6 +479,8 @@ bool RenderWidgetHostViewQtDelegateWidget::event(QEvent *event)
if (!handled)
return QQuickWidget::event(event);
+ // Most events are accepted by default, but tablet events are not:
+ event->accept();
return true;
}
diff --git a/tests/auto/quick/inspectorserver/tst_inspectorserver.cpp b/tests/auto/quick/inspectorserver/tst_inspectorserver.cpp
index 8e23e86e8..922c7769e 100644
--- a/tests/auto/quick/inspectorserver/tst_inspectorserver.cpp
+++ b/tests/auto/quick/inspectorserver/tst_inspectorserver.cpp
@@ -167,7 +167,7 @@ void tst_InspectorServer::openRemoteDebuggingSession()
// - The page list didn't return a valid inspector URL
// - Or the front-end couldn't be loaded through the inspector HTTP server
// - Or the web socket connection couldn't be established between the front-end and the page through the inspector server
- QTRY_VERIFY(inspectorWebView->title().startsWith("DevTools -"));
+ QTRY_VERIFY_WITH_TIMEOUT(inspectorWebView->title().startsWith("DevTools -"), 20000);
}
QTEST_MAIN(tst_InspectorServer)
diff --git a/tests/auto/quick/qmltests/BLACKLIST b/tests/auto/quick/qmltests/BLACKLIST
index 957911c3b..46bc65923 100644
--- a/tests/auto/quick/qmltests/BLACKLIST
+++ b/tests/auto/quick/qmltests/BLACKLIST
@@ -1,11 +1,2 @@
-[WebViewGeopermission::test_deniedGeolocationByUser]
-osx
-
-[WebViewGeopermission::test_geoPermissionRequest]
-osx
-
-[WebViewFindText::test_findTextInterruptedByLoad]
-*
-
[WebEngineViewSource::test_viewSourceURL]
*
diff --git a/tests/auto/quick/qquickwebengineview/BLACKLIST b/tests/auto/quick/qquickwebengineview/BLACKLIST
index 166a6894e..49c5332ff 100644
--- a/tests/auto/quick/qquickwebengineview/BLACKLIST
+++ b/tests/auto/quick/qquickwebengineview/BLACKLIST
@@ -1,15 +1,3 @@
-[transparentWebEngineViews]
-windows
-
-[inputEventForwardingDisabledWhenActiveFocusOnPressDisabled]
-*
-
-[transparentWebEngineViews]
-*
-
-[basicRenderingSanity]
-*
-
[javascriptClipboard:default]
opensuse-leap
diff --git a/tests/auto/widgets/qwebenginepage/BLACKLIST b/tests/auto/widgets/qwebenginepage/BLACKLIST
index e6d50da39..2000b0260 100644
--- a/tests/auto/widgets/qwebenginepage/BLACKLIST
+++ b/tests/auto/widgets/qwebenginepage/BLACKLIST
@@ -4,9 +4,6 @@ osx
[mouseMovementProperties]
windows
-[getUserMediaRequest]
-windows
-
[getUserMediaRequestDesktopVideoManyPages]
windows
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
index 8ad11ec75..0fa38f9ef 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
@@ -206,6 +206,8 @@ private Q_SLOTS:
void editActionsWithInitialFocus();
void editActionsWithFocusOnIframe();
+ void customUserAgentInNewTab();
+
private:
static QPoint elementCenter(QWebEnginePage *page, const QString &id);
@@ -918,6 +920,7 @@ void tst_QWebEnginePage::findText()
QTRY_COMPARE(loadSpy.count(), 1);
// Select whole page contents.
+ QTRY_VERIFY(m_view->page()->action(QWebEnginePage::SelectAll)->isEnabled());
m_view->page()->triggerAction(QWebEnginePage::SelectAll);
QTRY_COMPARE(m_view->hasSelection(), true);
@@ -3492,6 +3495,69 @@ void tst_QWebEnginePage::editActionsWithFocusOnIframe()
QCOMPARE(page->selectedText(), QStringLiteral("inner"));
}
+void tst_QWebEnginePage::customUserAgentInNewTab()
+{
+ HttpServer server;
+ QByteArray lastUserAgent;
+ connect(&server, &HttpServer::newRequest, [&](HttpReqRep *rr) {
+ QCOMPARE(rr->requestMethod(), "GET");
+ lastUserAgent = rr->requestHeader("user-agent");
+ rr->setResponseBody(QByteArrayLiteral("<html><body>Test</body></html>"));
+ rr->sendResponse();
+ });
+ QVERIFY(server.start());
+
+ class Page : public QWebEnginePage {
+ public:
+ QWebEngineProfile *targetProfile = nullptr;
+ QScopedPointer<QWebEnginePage> newPage;
+ Page(QWebEngineProfile *profile) : QWebEnginePage(profile) {}
+ private:
+ QWebEnginePage *createWindow(WebWindowType) override
+ {
+ newPage.reset(new QWebEnginePage(targetProfile ? targetProfile : profile(), nullptr));
+ return newPage.data();
+ }
+ };
+ QWebEngineProfile profile1, profile2;
+ profile1.setHttpUserAgent(QStringLiteral("custom 1"));
+ profile2.setHttpUserAgent(QStringLiteral("custom 2"));
+ Page page(&profile1);
+ QWebEngineView view;
+ view.resize(500, 500);
+ view.setPage(&page);
+ view.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+ QSignalSpy spy(&page, &QWebEnginePage::loadFinished);
+
+ // First check we can get the user-agent passed through normally
+ page.setHtml(QString("<html><body><a id='link' target='_blank' href='") +
+ server.url("/test1").toEncoded() +
+ QString("'>link</a></body></html>"));
+ QTRY_COMPARE(spy.count(), 1);
+ QVERIFY(spy.takeFirst().value(0).toBool());
+ QCOMPARE(evaluateJavaScriptSync(&page, QStringLiteral("navigator.userAgent")).toString(), profile1.httpUserAgent());
+ QTest::mouseClick(view.focusProxy(), Qt::LeftButton, 0, elementCenter(&page, "link"));
+ QTRY_VERIFY(page.newPage);
+ QTRY_VERIFY(!lastUserAgent.isEmpty());
+ QCOMPARE(lastUserAgent, profile1.httpUserAgent().toUtf8());
+
+ // Now check we can get the new user-agent of the profile
+ page.newPage.reset();
+ page.targetProfile = &profile2;
+ spy.clear();
+ lastUserAgent = { };
+ page.setHtml(QString("<html><body><a id='link' target='_blank' href='") +
+ server.url("/test2").toEncoded() +
+ QString("'>link</a></body></html>"));
+ QTRY_COMPARE(spy.count(), 1);
+ QVERIFY(spy.takeFirst().value(0).toBool());
+ QTest::mouseClick(view.focusProxy(), Qt::LeftButton, 0, elementCenter(&page, "link"));
+ QTRY_VERIFY(page.newPage);
+ QTRY_VERIFY(!lastUserAgent.isEmpty());
+ QCOMPARE(lastUserAgent, profile2.httpUserAgent().toUtf8());
+}
+
static QByteArrayList params = {QByteArrayLiteral("--use-fake-device-for-media-stream")};
W_QTEST_MAIN(tst_QWebEnginePage, params)
diff --git a/tests/auto/widgets/qwebengineview/BLACKLIST b/tests/auto/widgets/qwebengineview/BLACKLIST
index 9a574a687..21a876c88 100644
--- a/tests/auto/widgets/qwebengineview/BLACKLIST
+++ b/tests/auto/widgets/qwebengineview/BLACKLIST
@@ -1,6 +1,3 @@
-[doNotSendMouseKeyboardEventsWhenDisabled]
-windows
-
[microFocusCoordinates]
osx