Commit 3374c120 authored by Rakina Zata Amni's avatar Rakina Zata Amni Committed by Commit Bot

TestRunner changes to allow RenderView change in the same process

When ProactivelySwapBrowsingInstance is turned on with the level set to
CrossSiteReuseProcess (see crrev.com/c/2043521), renderer-initiated
navigations might trigger a BrowsingInstance swap which leads to a
RenderView swap, etc, with a possibility of the current renderer process
getting reused. Some parts of the TestRunner code does not expect this
(they expect the main window RenderView change always go hand-in-hand
with RenderProcess change, and that we always restart with a clean state
after those navigations), so we are updating it.

Bug: 977562
Change-Id: I469d28b2553b1a7d4e8025c30c3a5593267cb42a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2094480
Commit-Queue: Rakina Zata Amni <rakina@chromium.org>
Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
Reviewed-by: default avatarŁukasz Anforowicz <lukasza@chromium.org>
Cr-Commit-Position: refs/heads/master@{#751564}
parent e3d309c6
...@@ -435,6 +435,7 @@ bool BlinkTestController::PrepareForWebTest(const TestInfo& test_info) { ...@@ -435,6 +435,7 @@ bool BlinkTestController::PrepareForWebTest(const TestInfo& test_info) {
render_process_host_observer_.RemoveAll(); render_process_host_observer_.RemoveAll();
all_observed_render_process_hosts_.clear(); all_observed_render_process_hosts_.clear();
main_window_render_process_hosts_.clear(); main_window_render_process_hosts_.clear();
main_window_render_view_hosts_.clear();
accumulated_web_test_runtime_flags_changes_.Clear(); accumulated_web_test_runtime_flags_changes_.Clear();
blink_test_control_map_.clear(); blink_test_control_map_.clear();
web_test_control_map_.clear(); web_test_control_map_.clear();
...@@ -1003,6 +1004,7 @@ void BlinkTestController::DiscardMainWindow() { ...@@ -1003,6 +1004,7 @@ void BlinkTestController::DiscardMainWindow() {
void BlinkTestController::HandleNewRenderFrameHost(RenderFrameHost* frame) { void BlinkTestController::HandleNewRenderFrameHost(RenderFrameHost* frame) {
RenderProcessHost* process_host = frame->GetProcess(); RenderProcessHost* process_host = frame->GetProcess();
RenderViewHost* view_host = frame->GetRenderViewHost();
bool main_window = bool main_window =
WebContents::FromRenderFrameHost(frame) == main_window_->web_contents(); WebContents::FromRenderFrameHost(frame) == main_window_->web_contents();
...@@ -1013,9 +1015,19 @@ void BlinkTestController::HandleNewRenderFrameHost(RenderFrameHost* frame) { ...@@ -1013,9 +1015,19 @@ void BlinkTestController::HandleNewRenderFrameHost(RenderFrameHost* frame) {
current_pid_ = process.Pid(); current_pid_ = process.Pid();
} }
// Is this the 1st time this renderer contains parts of the main test window? // If this the first time this renderer contains parts of the main test
// window, we need to make sure that it gets configured correctly (including
// letting it know that it's part of the main test window).
// We consider the renderer as new when we see either a new RenderProcessHost
// or a new RenderViewHost, as it is possible that a new renderer (with a new
// RenderViewHost) reuses a renderer process, and it's also possible that we
// reuse RenderViewHosts (in some fetch tests).
// TODO(rakina): Understand the fetch tests to figure out if it's possible to
// remove RenderProcessHost tracking here.
if (main_window && if (main_window &&
!base::Contains(main_window_render_process_hosts_, process_host)) { (!base::Contains(main_window_render_view_hosts_, view_host) ||
!base::Contains(main_window_render_process_hosts_, process_host))) {
main_window_render_view_hosts_.insert(view_host);
main_window_render_process_hosts_.insert(process_host); main_window_render_process_hosts_.insert(process_host);
// Make sure the new renderer process_host has a test configuration shared // Make sure the new renderer process_host has a test configuration shared
......
...@@ -327,6 +327,7 @@ class BlinkTestController : public WebContentsObserver, ...@@ -327,6 +327,7 @@ class BlinkTestController : public WebContentsObserver,
render_process_host_observer_{this}; render_process_host_observer_{this};
std::set<RenderProcessHost*> all_observed_render_process_hosts_; std::set<RenderProcessHost*> all_observed_render_process_hosts_;
std::set<RenderProcessHost*> main_window_render_process_hosts_; std::set<RenderProcessHost*> main_window_render_process_hosts_;
std::set<RenderViewHost*> main_window_render_view_hosts_;
// Changes reported by OnWebTestRuntimeFlagsChanged that have accumulated // Changes reported by OnWebTestRuntimeFlagsChanged that have accumulated
// since PrepareForWebTest (i.e. changes that need to be send to a fresh // since PrepareForWebTest (i.e. changes that need to be send to a fresh
......
...@@ -1817,9 +1817,10 @@ void TestRunner::AddLoadingFrame(blink::WebFrame* frame) { ...@@ -1817,9 +1817,10 @@ void TestRunner::AddLoadingFrame(blink::WebFrame* frame) {
} }
void TestRunner::RemoveLoadingFrame(blink::WebFrame* frame) { void TestRunner::RemoveLoadingFrame(blink::WebFrame* frame) {
if (!IsFramePartOfMainTestWindow(frame)) // Note that unlike AddLoadingFrame, we don't check if |frame| is part of the
return; // current main test window or not, because in some cases we might have
// marked the new page as the current main test window before we removed all
// the loading frames of the old main test window from |loading_frames_|.
if (!base::Contains(loading_frames_, frame)) if (!base::Contains(loading_frames_, frame))
return; return;
......
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