From 3b04c83620a465a4f8876413c37696fbbc3a23d6 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 7 Jun 2019 11:14:00 +0200 Subject: Set custom user-agent manually on new windows Chromium forgets to set ShouldOverrideUserAgentInNewTabs(), so we need to manually set the override. Fixes: QTBUG-76249 Change-Id: Id240ee525dacec3cd8389aca058a61d3af62b00a Reviewed-by: Michal Klocek --- .../widgets/qwebenginepage/tst_qwebenginepage.cpp | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp index d73c8e80a..bfe94ba4e 100644 --- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp +++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp @@ -231,6 +231,8 @@ private Q_SLOTS: void editActionsWithInitialFocus(); void editActionsWithFocusOnIframe(); + void customUserAgentInNewTab(); + private: static QPoint elementCenter(QWebEnginePage *page, const QString &id); @@ -4594,6 +4596,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("Test")); + rr->sendResponse(); + }); + QVERIFY(server.start()); + + class Page : public QWebEnginePage { + public: + QWebEngineProfile *targetProfile = nullptr; + QScopedPointer 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("link")); + 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("link")); + 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) -- cgit v1.2.3 From fafc387a32ac4b06709c0845c7f4cfd5164c1206 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCri=20Valdmann?= Date: Wed, 3 Jul 2019 08:56:39 +0200 Subject: Bump timeout in tst_InspectorServer::openRemoteDebuggingSession Flaky on Windows 10. Change-Id: Idaf73ccaf29831010e84397ae722dbe54a2de9bb Reviewed-by: Allan Sandfeld Jensen --- tests/auto/quick/inspectorserver/tst_inspectorserver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') 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) -- cgit v1.2.3 From 9bf361eddea701a65ea2a26f3d598ec4d4a6e22c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCri=20Valdmann?= Date: Mon, 8 Jul 2019 10:01:16 +0200 Subject: Un-blacklist some passing tests Remove from the blacklist some tests which, according to Grafana, have had no failures in the last 90 days on 5.12 branch. Change-Id: I3f174c82b5644d74b70fffa3856ae79f8c9893f8 Reviewed-by: Allan Sandfeld Jensen --- tests/auto/quick/qmltests/BLACKLIST | 9 --------- tests/auto/quick/qquickwebengineview/BLACKLIST | 11 ----------- tests/auto/widgets/qwebenginepage/BLACKLIST | 3 --- tests/auto/widgets/qwebengineview/BLACKLIST | 3 --- 4 files changed, 26 deletions(-) (limited to 'tests') diff --git a/tests/auto/quick/qmltests/BLACKLIST b/tests/auto/quick/qmltests/BLACKLIST index dfafbaea4..083c15984 100644 --- a/tests/auto/quick/qmltests/BLACKLIST +++ b/tests/auto/quick/qmltests/BLACKLIST @@ -1,9 +1,3 @@ -[WebViewGeopermission::test_deniedGeolocationByUser] -osx - -[WebViewGeopermission::test_geoPermissionRequest] -osx - [WebEngineViewSingleFileUpload::test_acceptDirectory] * @@ -13,8 +7,5 @@ osx [WebEngineViewSingleFileUpload::test_acceptSingleFileSelection] * -[WebViewFindText::test_findTextInterruptedByLoad] -* - [WebEngineViewSource::test_viewSourceURL] * diff --git a/tests/auto/quick/qquickwebengineview/BLACKLIST b/tests/auto/quick/qquickwebengineview/BLACKLIST index 76cb18c1e..5f46fa47e 100644 --- a/tests/auto/quick/qquickwebengineview/BLACKLIST +++ b/tests/auto/quick/qquickwebengineview/BLACKLIST @@ -1,14 +1,3 @@ -[transparentWebEngineViews] -windows - -[inputEventForwardingDisabledWhenActiveFocusOnPressDisabled] -* - -[transparentWebEngineViews] -* - -[basicRenderingSanity] -* [javascriptClipboard:default] opensuse-leap [javascriptClipboard:canPaste] diff --git a/tests/auto/widgets/qwebenginepage/BLACKLIST b/tests/auto/widgets/qwebenginepage/BLACKLIST index 228efd61c..1453f6e95 100644 --- a/tests/auto/widgets/qwebenginepage/BLACKLIST +++ b/tests/auto/widgets/qwebenginepage/BLACKLIST @@ -10,9 +10,6 @@ osx [mouseMovementProperties] windows -[getUserMediaRequest] -windows - [getUserMediaRequestDesktopVideoManyPages] windows diff --git a/tests/auto/widgets/qwebengineview/BLACKLIST b/tests/auto/widgets/qwebengineview/BLACKLIST index 7c86a72d6..9087067f5 100644 --- a/tests/auto/widgets/qwebengineview/BLACKLIST +++ b/tests/auto/widgets/qwebengineview/BLACKLIST @@ -1,6 +1,3 @@ -[doNotSendMouseKeyboardEventsWhenDisabled] -windows - [microFocusCoordinates] osx -- cgit v1.2.3 From d35cd072c3f56aa285871a151adc30d9d81f3ea3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCri=20Valdmann?= Date: Tue, 9 Jul 2019 10:41:01 +0200 Subject: Wait for SelectAll to be enabled in tst_QWebEnginePage::findText Fixes flaky m_view->hasSelection() assertion. Change-Id: Idba17916c38ac76b8002e30bab08d7f9e1064b2a Reviewed-by: Kirill Burtsev Reviewed-by: Peter Varga --- tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp index bfe94ba4e..f27dae3c7 100644 --- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp +++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp @@ -1807,6 +1807,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); -- cgit v1.2.3