Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(182)

Side by Side Diff: content/browser/site_per_process_browsertest.cc

Issue 1886413002: Always swap with a replacement proxy in OnSwapOut. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/site_per_process_browsertest.h" 5 #include "content/browser/site_per_process_browsertest.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 13 matching lines...) Expand all
24 #include "content/browser/frame_host/frame_tree.h" 24 #include "content/browser/frame_host/frame_tree.h"
25 #include "content/browser/frame_host/navigator.h" 25 #include "content/browser/frame_host/navigator.h"
26 #include "content/browser/frame_host/render_frame_proxy_host.h" 26 #include "content/browser/frame_host/render_frame_proxy_host.h"
27 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" 27 #include "content/browser/frame_host/render_widget_host_view_child_frame.h"
28 #include "content/browser/gpu/compositor_util.h" 28 #include "content/browser/gpu/compositor_util.h"
29 #include "content/browser/loader/resource_dispatcher_host_impl.h" 29 #include "content/browser/loader/resource_dispatcher_host_impl.h"
30 #include "content/browser/renderer_host/input/synthetic_tap_gesture.h" 30 #include "content/browser/renderer_host/input/synthetic_tap_gesture.h"
31 #include "content/browser/renderer_host/render_view_host_impl.h" 31 #include "content/browser/renderer_host/render_view_host_impl.h"
32 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" 32 #include "content/browser/renderer_host/render_widget_host_input_event_router.h"
33 #include "content/browser/renderer_host/render_widget_host_view_aura.h" 33 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
34 #include "content/common/child_process_messages.h"
34 #include "content/common/frame_messages.h" 35 #include "content/common/frame_messages.h"
35 #include "content/common/input/synthetic_tap_gesture_params.h" 36 #include "content/common/input/synthetic_tap_gesture_params.h"
37 #include "content/common/input_messages.h"
36 #include "content/common/view_messages.h" 38 #include "content/common/view_messages.h"
37 #include "content/public/browser/cert_store.h" 39 #include "content/public/browser/cert_store.h"
38 #include "content/public/browser/notification_observer.h" 40 #include "content/public/browser/notification_observer.h"
39 #include "content/public/browser/notification_service.h" 41 #include "content/public/browser/notification_service.h"
40 #include "content/public/browser/notification_types.h" 42 #include "content/public/browser/notification_types.h"
41 #include "content/public/browser/resource_dispatcher_host.h" 43 #include "content/public/browser/resource_dispatcher_host.h"
42 #include "content/public/common/browser_side_navigation_policy.h" 44 #include "content/public/common/browser_side_navigation_policy.h"
43 #include "content/public/common/content_switches.h" 45 #include "content/public/common/content_switches.h"
44 #include "content/public/common/url_constants.h" 46 #include "content/public/common/url_constants.h"
45 #include "content/public/test/browser_test_utils.h" 47 #include "content/public/test/browser_test_utils.h"
(...skipping 6360 matching lines...) Expand 10 before | Expand all | Expand 10 after
6406 RenderWidgetHostImpl* root_rwh = 6408 RenderWidgetHostImpl* root_rwh =
6407 root->current_frame_host()->GetRenderWidgetHost(); 6409 root->current_frame_host()->GetRenderWidgetHost();
6408 press_tab_and_wait_for_state_change(root_rwh); 6410 press_tab_and_wait_for_state_change(root_rwh);
6409 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, contents->GetTextInputState()->type); 6411 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, contents->GetTextInputState()->type);
6410 6412
6411 // Crash the tab renderer and observer the input state going back to none. 6413 // Crash the tab renderer and observer the input state going back to none.
6412 RenderProcessHost* host_process = root_rwh->GetProcess(); 6414 RenderProcessHost* host_process = root_rwh->GetProcess();
6413 crash_renderer_and_wait_for_input_state_none(host_process); 6415 crash_renderer_and_wait_for_input_state_none(host_process);
6414 } 6416 }
6415 6417
6418 // Helper class to wait for a ChildProcessHostMsg_ShutdownRequest message to
6419 // arrive.
6420 class ShutdownRequestMessageFilter : public BrowserMessageFilter {
6421 public:
6422 ShutdownRequestMessageFilter()
6423 : BrowserMessageFilter(ChildProcessMsgStart),
6424 message_loop_runner_(new MessageLoopRunner) {}
6425
6426 bool OnMessageReceived(const IPC::Message& message) override {
6427 if (message.type() == ChildProcessHostMsg_ShutdownRequest::ID) {
6428 content::BrowserThread::PostTask(
6429 content::BrowserThread::UI, FROM_HERE,
6430 base::Bind(&ShutdownRequestMessageFilter::OnShutdownRequest, this));
6431 }
6432 return false;
6433 }
6434
6435 void OnShutdownRequest() { message_loop_runner_->Quit(); }
6436
6437 void Wait() { message_loop_runner_->Run(); }
6438
6439 private:
6440 ~ShutdownRequestMessageFilter() override {}
6441
6442 scoped_refptr<MessageLoopRunner> message_loop_runner_;
6443
6444 DISALLOW_COPY_AND_ASSIGN(ShutdownRequestMessageFilter);
6445 };
6446
6447 // Test for https://crbug.com/568836. From an A-embed-B page, navigate the
6448 // subframe from B to A. This cleans up the process for B, but the test delays
6449 // the browser side from killing the B process right away. This allows the
6450 // B process to process two ViewMsg_Close messages sent to the subframe's
6451 // RenderWidget and RenderView, in that order. In the bug, the latter crashed
nasko 2016/04/18 21:24:26 nit: "and the RenderView".
alexmos 2016/04/22 05:09:34 Done. (I used "and to the RenderView".)
6452 // while detaching the subframe's LocalFrame (triggered as part of closing the
6453 // RenderView), because this tried to access the subframe's WebFrameWidget
6454 // (from RenderFrameImpl::didChangeSelection), which had already been cleared
6455 // by the former.
6456 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
6457 CloseSubframeWidgetAndViewOnProcessExit) {
6458 GURL main_url(embedded_test_server()->GetURL(
6459 "a.com", "/cross_site_iframe_factory.html?a(b)"));
6460 EXPECT_TRUE(NavigateToURL(shell(), main_url));
6461
6462 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
6463 ->GetFrameTree()
6464 ->root();
6465
6466 // "Select all" in the subframe. The bug only happens if there's a selection
6467 // change, which triggers the path through didChangeSelection.
6468 root->child_at(0)->current_frame_host()->Send(new InputMsg_SelectAll(
6469 root->child_at(0)->current_frame_host()->GetRoutingID()));
6470
6471 // Prevent b.com process from terminating right away once the subframe
6472 // navigates away from b.com below. This is necessary so that the renderer
6473 // process has time to process the closings of RenderWidget and RenderView,
6474 // which is where the original bug was triggered. Incrementing worker
6475 // RefCount will cause RenderProcessHostImpl::Cleanup to forego process
6476 // termination.
6477 RenderProcessHost* subframe_process =
6478 root->child_at(0)->current_frame_host()->GetProcess();
6479 subframe_process->IncrementWorkerRefCount();
6480
6481 // Navigate the subframe away from b.com. Since this is the last active
6482 // frame in the b.com process, this causes the RenderWidget and RenderView to
6483 // be closed. If this succeeds without crashing, the renderer will release
6484 // the process and send a ChildProcessHostMsg_ShutdownRequest to the browser
6485 // process to ask whether it's ok to terminate. Thus, wait for this message
6486 // to ensure that the RenderView and widget were closed without crashing.
6487 scoped_refptr<ShutdownRequestMessageFilter> filter =
6488 new ShutdownRequestMessageFilter();
6489 subframe_process->AddFilter(filter.get());
6490 NavigateFrameToURL(root->child_at(0),
6491 embedded_test_server()->GetURL("a.com", "/title1.html"));
6492 filter->Wait();
6493
6494 subframe_process->DecrementWorkerRefCount();
nasko 2016/04/18 21:24:26 Do we care to wait for process termination at all?
alexmos 2016/04/22 05:09:34 Correct, we don't need to wait for process termina
6495 }
6496
6416 } // namespace content 6497 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/render_frame_impl.cc » ('j') | content/renderer/render_frame_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698