summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJüri Valdmann <juri.valdmann@qt.io>2019-11-19 13:00:00 +0100
committerJüri Valdmann <juri.valdmann@qt.io>2019-11-28 08:53:02 +0100
commit9d325441635c2dd7383973f2a82c5d2e575445d1 (patch)
treecbdc99949df786356aeba1378a182a26339af582 /tests
parente72fd5136c5a7a848d9156334cf8f067eb1a1a10 (diff)
Fix renderProcessTerminated signal
With the adaptations for Chromium 76, RenderWidgetHostViewQt was changed to become a RenderProcessHostObserver with the renderProcessTerminated signal being emitted from the override of RenderProcessHostObserver::RenderProcessExited. The problem with this can be seen by setting a breakpoint on the RenderProcessGone override in RenderWidgetHostViewQt. We then get the trace: QtWebEngineCore::RenderWidgetHostViewQt::RenderProcessGone content::RenderWidgetHostImpl::RendererExited() content::RenderViewHostImpl::RenderProcessExited content::RenderProcessHostImpl::ProcessDied ProcessDied iterates over all the observers and calls RenderProcessExited. Both the RenderViewHostImpl and our RWHVQt are observers, but the RVHImpl comes first. The RVHImpl then calls RendererExited, which calls our RenderProcessGone, which does a 'delete this'. Now our RenderProcessExited override can never be called because we have already deleted our observer. Fix by moving the RenderProcessGone code to WebContentsDelegateQt and getting the exit code from WebContents::GetCrashedErrorCode. Also add test. Task-number: QTBUG-80085 Change-Id: I434744286df97a37b64722d7c15a1d4ee11c8af6 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
index 27aa7a1f7..88cdcbb96 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
@@ -225,6 +225,7 @@ private Q_SLOTS:
void editActionsWithoutSelection();
void customUserAgentInNewTab();
+ void renderProcessCrashed();
private:
static QPoint elementCenter(QWebEnginePage *page, const QString &id);
@@ -4410,6 +4411,26 @@ void tst_QWebEnginePage::customUserAgentInNewTab()
QCOMPARE(lastUserAgent, profile2.httpUserAgent().toUtf8());
}
+void tst_QWebEnginePage::renderProcessCrashed()
+{
+ using Status = QWebEnginePage::RenderProcessTerminationStatus;
+ QWebEngineProfile profile;
+ QWebEnginePage page(&profile);
+ bool done = false;
+ Status status;
+ connect(&page, &QWebEnginePage::renderProcessTerminated, [&](Status newStatus) {
+ status = newStatus;
+ done = true;
+ });
+ page.load(QUrl("chrome://crash"));
+ QTRY_VERIFY_WITH_TIMEOUT(done, 20000);
+ // The status depends on whether stack traces are enabled. With
+ // --disable-in-process-stack-traces we get an AbnormalTerminationStatus,
+ // otherwise a CrashedTerminationStatus.
+ QVERIFY(status == QWebEnginePage::CrashedTerminationStatus ||
+ status == QWebEnginePage::AbnormalTerminationStatus);
+}
+
static QByteArrayList params = {QByteArrayLiteral("--use-fake-device-for-media-stream")};
W_QTEST_MAIN(tst_QWebEnginePage, params)