OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <set> | 5 #include <set> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "base/thread_task_runner_handle.h" | 14 #include "base/thread_task_runner_handle.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "content/browser/child_process_security_policy_impl.h" | 16 #include "content/browser/child_process_security_policy_impl.h" |
17 #include "content/browser/frame_host/render_frame_proxy_host.h" | 17 #include "content/browser/frame_host/render_frame_proxy_host.h" |
18 #include "content/browser/renderer_host/render_view_host_impl.h" | 18 #include "content/browser/renderer_host/render_view_host_impl.h" |
19 #include "content/browser/site_instance_impl.h" | 19 #include "content/browser/site_instance_impl.h" |
20 #include "content/browser/web_contents/web_contents_impl.h" | 20 #include "content/browser/web_contents/web_contents_impl.h" |
21 #include "content/browser/webui/web_ui_impl.h" | 21 #include "content/browser/webui/web_ui_impl.h" |
22 #include "content/common/content_constants_internal.h" | 22 #include "content/common/content_constants_internal.h" |
| 23 #include "content/common/input_messages.h" |
23 #include "content/common/site_isolation_policy.h" | 24 #include "content/common/site_isolation_policy.h" |
24 #include "content/public/browser/navigation_controller.h" | 25 #include "content/public/browser/navigation_controller.h" |
25 #include "content/public/browser/navigation_entry.h" | 26 #include "content/public/browser/navigation_entry.h" |
26 #include "content/public/browser/render_process_host.h" | 27 #include "content/public/browser/render_process_host.h" |
27 #include "content/public/browser/resource_dispatcher_host.h" | 28 #include "content/public/browser/resource_dispatcher_host.h" |
28 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
29 #include "content/public/browser/web_contents_observer.h" | 30 #include "content/public/browser/web_contents_observer.h" |
30 #include "content/public/common/bindings_policy.h" | 31 #include "content/public/common/bindings_policy.h" |
31 #include "content/public/common/content_switches.h" | 32 #include "content/public/common/content_switches.h" |
32 #include "content/public/common/file_chooser_file_info.h" | 33 #include "content/public/common/file_chooser_file_info.h" |
(...skipping 2075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2108 new_shell->LoadURL(same_site_url); | 2109 new_shell->LoadURL(same_site_url); |
2109 | 2110 |
2110 // Going back in history should work and the test should not crash. | 2111 // Going back in history should work and the test should not crash. |
2111 TestNavigationObserver back_nav_load_observer(new_shell->web_contents()); | 2112 TestNavigationObserver back_nav_load_observer(new_shell->web_contents()); |
2112 new_shell->web_contents()->GetController().GoBack(); | 2113 new_shell->web_contents()->GetController().GoBack(); |
2113 back_nav_load_observer.Wait(); | 2114 back_nav_load_observer.Wait(); |
2114 | 2115 |
2115 ResourceDispatcherHost::Get()->SetDelegate(nullptr); | 2116 ResourceDispatcherHost::Get()->SetDelegate(nullptr); |
2116 } | 2117 } |
2117 | 2118 |
| 2119 // Tests that InputMsg type IPCs are ignored by swapped out RenderViews. It |
| 2120 // uses the SetFocus IPC, as RenderView has a CHECK to ensure that condition |
| 2121 // never happens. |
| 2122 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, |
| 2123 InputMsgToSwappedOutRVHIsIgnored) { |
| 2124 StartEmbeddedServer(); |
| 2125 EXPECT_TRUE(NavigateToURL( |
| 2126 shell(), embedded_test_server()->GetURL("a.com", "/title1.html"))); |
| 2127 |
| 2128 // Open a popup to navigate cross-process. |
| 2129 Shell* new_shell = |
| 2130 OpenPopup(shell()->web_contents(), GURL(url::kAboutBlankURL), "foo"); |
| 2131 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(), |
| 2132 new_shell->web_contents()->GetSiteInstance()); |
| 2133 |
| 2134 // Keep a pointer to the RenderViewHost, which will be in swapped out |
| 2135 // state after navigating cross-process. This is how this test is causing |
| 2136 // a swapped out RenderView to receive InputMsg IPC message. |
| 2137 WebContentsImpl* new_web_contents = |
| 2138 static_cast<WebContentsImpl*>(new_shell->web_contents()); |
| 2139 FrameTreeNode* new_root = new_web_contents->GetFrameTree()->root(); |
| 2140 RenderViewHostImpl* rvh = new_web_contents->GetRenderViewHost(); |
| 2141 |
| 2142 // Navigate the popup to a different site, so the |rvh| is swapped out. |
| 2143 EXPECT_TRUE(NavigateToURL( |
| 2144 new_shell, embedded_test_server()->GetURL("b.com", "/title2.html"))); |
| 2145 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
| 2146 new_shell->web_contents()->GetSiteInstance()); |
| 2147 EXPECT_EQ(rvh, new_root->render_manager()->GetSwappedOutRenderViewHost( |
| 2148 shell()->web_contents()->GetSiteInstance())); |
| 2149 |
| 2150 // Setup a process observer to ensure there is no crash and send the IPC |
| 2151 // message. |
| 2152 RenderProcessHostWatcher watcher( |
| 2153 rvh->GetProcess(), RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); |
| 2154 rvh->Send(new InputMsg_SetFocus(rvh->GetRoutingID(), true)); |
| 2155 |
| 2156 // The test must wait for a process to exit, but if the IPC message is |
| 2157 // properly ignored, there will be no crash. Therefore, navigate the |
| 2158 // original window to the same site as the popup, which will just exit the |
| 2159 // process cleanly. |
| 2160 EXPECT_TRUE(NavigateToURL( |
| 2161 shell(), embedded_test_server()->GetURL("b.com", "/title3.html"))); |
| 2162 watcher.Wait(); |
| 2163 EXPECT_TRUE(watcher.did_exit_normally()); |
| 2164 } |
| 2165 |
2118 } // namespace content | 2166 } // namespace content |
OLD | NEW |