Chromium Code Reviews| 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 NavigateToURL(shell(), | |
| 2126 embedded_test_server()->GetURL("a.com", "/title1.html")); | |
|
nasko
2015/10/15 23:18:26
I missed to add EXPECT_TRUE on all calls to Naviga
alexmos
2015/10/16 00:49:15
Thanks! Note to self: I should get back to http:/
| |
| 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()); | |
|
alexmos
2015/10/15 22:52:38
nit: Is the cast to *Impl necessary? Seems the rv
nasko
2015/10/15 23:18:26
I either have to cast here or cast the call to Get
alexmos
2015/10/16 00:49:15
I thought Send() was public since RenderViewHost i
| |
| 2139 RenderViewHostImpl* rvh = new_web_contents->GetRenderViewHost(); | |
| 2140 | |
| 2141 // Navigate the popup to a different site, so the |rvh| is swapped out. | |
| 2142 NavigateToURL(new_shell, | |
| 2143 embedded_test_server()->GetURL("b.com", "/title2.html")); | |
| 2144 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | |
| 2145 new_shell->web_contents()->GetSiteInstance()); | |
|
alexmos
2015/10/15 22:52:38
nit: is it also worth checking that rvh now corres
nasko
2015/10/15 23:18:26
Why not! Now I really need to cast the WebContents
| |
| 2146 | |
| 2147 // Setup a process observer to ensure there is no crash and send the IPC | |
| 2148 // message. | |
| 2149 RenderProcessHostWatcher watcher( | |
| 2150 rvh->GetProcess(), RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); | |
| 2151 rvh->Send(new InputMsg_SetFocus(rvh->GetRoutingID(), true)); | |
| 2152 | |
| 2153 // The test must wait for a process to exit, but if the IPC message is | |
| 2154 // properly ignored, there will be no crash. Therefore, navigate the | |
| 2155 // original window to the same site as the popup, which will just exit the | |
| 2156 // process cleanly. | |
| 2157 NavigateToURL(shell(), | |
| 2158 embedded_test_server()->GetURL("b.com", "/title3.html")); | |
| 2159 watcher.Wait(); | |
| 2160 EXPECT_TRUE(watcher.did_exit_normally()); | |
| 2161 } | |
| 2162 | |
| 2118 } // namespace content | 2163 } // namespace content |
| OLD | NEW |