Commit 61ee2a54 authored by Kevin McNee's avatar Kevin McNee Committed by Commit Bot

Have |CrashTab| test function produce abnormal termination on Windows

|CrashTab| uses 0 as the exit code which makes the process appear to
have terminated normally. The exit code passed to
|RenderProcessHost::Shutdown| is only actually used on Windows, so this
still appeared as a crash on other platforms.

We now specify a non-zero exit code, so that callers of |CrashTab|
observe a crash on Windows.

Bug: None
Change-Id: Iaafca2aeed50612ad0de01d06f65183e11d63783
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2303988
Commit-Queue: Kevin McNee <mcnee@chromium.org>
Reviewed-by: default avatarNasko Oskov <nasko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#790192}
parent 1a4d5eca
......@@ -1894,24 +1894,6 @@ IN_PROC_BROWSER_TEST_F(PortalBrowserTest,
activated_observer.result());
}
namespace {
void CrashContents(WebContentsImpl* contents) {
#if defined(OS_WIN)
// TODO(mcnee): |CrashTab| on windows makes it look like the process
// terminated normally. For now we crash it properly here.
RenderProcessHost* rph = contents->GetMainFrame()->GetProcess();
RenderProcessHostWatcher watcher(
rph, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT);
EXPECT_TRUE(rph->Shutdown(RESULT_CODE_KILLED));
watcher.Wait();
EXPECT_FALSE(watcher.did_exit_normally());
#else
CrashTab(contents);
#endif
EXPECT_TRUE(contents->IsCrashed());
}
} // namespace
IN_PROC_BROWSER_TEST_F(PortalBrowserTest, RejectActivationOfCrashedPages) {
GURL main_url(embedded_test_server()->GetURL("portal.test", "/title1.html"));
ASSERT_TRUE(NavigateToURL(shell(), main_url));
......@@ -1922,7 +1904,7 @@ IN_PROC_BROWSER_TEST_F(PortalBrowserTest, RejectActivationOfCrashedPages) {
GURL portal_url(embedded_test_server()->GetURL("a.com", "/title1.html"));
Portal* portal = CreatePortalToUrl(web_contents_impl, portal_url);
WebContentsImpl* portal_contents = portal->GetPortalContents();
CrashContents(portal_contents);
CrashTab(portal_contents);
PortalActivatedObserver activated_observer(portal);
EXPECT_TRUE(
......@@ -1941,7 +1923,7 @@ IN_PROC_BROWSER_TEST_F(PortalBrowserTest, ActivatePreviouslyCrashedPortal) {
GURL portal_url(embedded_test_server()->GetURL("a.com", "/title1.html"));
Portal* portal = CreatePortalToUrl(web_contents_impl, portal_url);
WebContentsImpl* portal_contents = portal->GetPortalContents();
CrashContents(portal_contents);
CrashTab(portal_contents);
TestNavigationObserver navigation_observer(portal_contents);
EXPECT_TRUE(ExecJs(
......
......@@ -763,8 +763,10 @@ void CrashTab(WebContents* web_contents) {
RenderProcessHost* rph = web_contents->GetMainFrame()->GetProcess();
RenderProcessHostWatcher watcher(
rph, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT);
rph->Shutdown(0);
EXPECT_TRUE(rph->Shutdown(RESULT_CODE_KILLED));
watcher.Wait();
EXPECT_FALSE(watcher.did_exit_normally());
EXPECT_TRUE(web_contents->IsCrashed());
}
void PwnCommitIPC(WebContents* web_contents,
......
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