Commit d1a72344 authored by danakj's avatar danakj Committed by Commit Bot

web tests: Crash the browser when a (non-renderer) child process crashes

Currently only a renderer crash causes the test to fail, and a network
process crash is not noticed but is a problem! Crash the browser when
this happens in a web test so the test will fail.

R=nasko@chromium.org

Bug: 1067445
Change-Id: I070eeaa9865bbf5f23a72db35ae8a4ca181dc114
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2136112Reviewed-by: default avatarNasko Oskov <nasko@chromium.org>
Commit-Queue: danakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756550}
parent ac5b908c
......@@ -16,9 +16,11 @@
#include "base/strings/pattern.h"
#include "base/task/post_task.h"
#include "cc/base/switches.h"
#include "content/public/browser/browser_child_process_observer.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_data.h"
#include "content/public/browser/client_hints_controller_delegate.h"
#include "content/public/browser/login_delegate.h"
#include "content/public/browser/overlay_window.h"
......@@ -125,6 +127,33 @@ class BoundsMatchVideoSizeOverlayWindow : public OverlayWindow {
gfx::Size size_;
};
void CreateChildProcessCrashWatcher() {
class ChildProcessCrashWatcher : public BrowserChildProcessObserver {
public:
ChildProcessCrashWatcher() { BrowserChildProcessObserver::Add(this); }
~ChildProcessCrashWatcher() override {
BrowserChildProcessObserver::Remove(this);
}
private:
// BrowserChildProcessObserver implementation.
void BrowserChildProcessCrashed(
const ChildProcessData& data,
const ChildProcessTerminationInfo& info) override {
// Child processes should not crash in web tests.
DLOG(ERROR) << "Child process crashed with\n"
" process_type: "
<< data.process_type << "\n"
<< " name: " << data.name;
CHECK(false);
}
};
// This creates the singleton object which will now watch for crashes from
// any BrowserChildProcessHost.
static base::NoDestructor<ChildProcessCrashWatcher> watcher;
}
} // namespace
WebTestContentBrowserClient::WebTestContentBrowserClient() {
......@@ -172,9 +201,12 @@ WebTestContentBrowserClient::GetNextFakeBluetoothChooser() {
return fake_bluetooth_chooser_factory_->GetNextFakeBluetoothChooser();
}
void WebTestContentBrowserClient::RenderProcessWillLaunch(
RenderProcessHost* host) {
ShellContentBrowserClient::RenderProcessWillLaunch(host);
void WebTestContentBrowserClient::BrowserChildProcessHostCreated(
BrowserChildProcessHost* host) {
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner =
base::CreateSingleThreadTaskRunner({content::BrowserThread::UI});
ui_task_runner->PostTask(FROM_HERE,
base::BindOnce(&CreateChildProcessCrashWatcher));
}
void WebTestContentBrowserClient::ExposeInterfacesToRenderer(
......
......@@ -50,7 +50,7 @@ class WebTestContentBrowserClient : public ShellContentBrowserClient {
void ResetFakeBluetoothDelegate();
// ContentBrowserClient overrides.
void RenderProcessWillLaunch(RenderProcessHost* host) override;
void BrowserChildProcessHostCreated(BrowserChildProcessHost* host) override;
void ExposeInterfacesToRenderer(
service_manager::BinderRegistry* registry,
blink::AssociatedInterfaceRegistry* associated_registry,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment