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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "base/test/histogram_tester.h" | 8 #include "base/test/histogram_tester.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "content/browser/compositor/test/no_transport_image_transport_factory.h
" | 10 #include "content/browser/compositor/test/no_transport_image_transport_factory.h
" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "content/public/browser/notification_source.h" | 24 #include "content/public/browser/notification_source.h" |
25 #include "content/public/browser/notification_types.h" | 25 #include "content/public/browser/notification_types.h" |
26 #include "content/public/browser/render_process_host.h" | 26 #include "content/public/browser/render_process_host.h" |
27 #include "content/public/browser/render_widget_host_iterator.h" | 27 #include "content/public/browser/render_widget_host_iterator.h" |
28 #include "content/public/browser/web_contents_delegate.h" | 28 #include "content/public/browser/web_contents_delegate.h" |
29 #include "content/public/browser/web_contents_observer.h" | 29 #include "content/public/browser/web_contents_observer.h" |
30 #include "content/public/browser/web_ui_controller.h" | 30 #include "content/public/browser/web_ui_controller.h" |
31 #include "content/public/common/bindings_policy.h" | 31 #include "content/public/common/bindings_policy.h" |
32 #include "content/public/common/content_switches.h" | 32 #include "content/public/common/content_switches.h" |
33 #include "content/public/common/javascript_message_type.h" | 33 #include "content/public/common/javascript_message_type.h" |
| 34 #include "content/public/common/site_isolation_policy.h" |
34 #include "content/public/common/url_constants.h" | 35 #include "content/public/common/url_constants.h" |
35 #include "content/public/common/url_utils.h" | 36 #include "content/public/common/url_utils.h" |
36 #include "content/public/test/browser_test_utils.h" | 37 #include "content/public/test/browser_test_utils.h" |
37 #include "content/public/test/mock_render_process_host.h" | 38 #include "content/public/test/mock_render_process_host.h" |
38 #include "content/public/test/test_notification_tracker.h" | 39 #include "content/public/test/test_notification_tracker.h" |
39 #include "content/test/test_content_browser_client.h" | 40 #include "content/test/test_content_browser_client.h" |
40 #include "content/test/test_content_client.h" | 41 #include "content/test/test_content_client.h" |
41 #include "content/test/test_render_frame_host.h" | 42 #include "content/test/test_render_frame_host.h" |
42 #include "content/test/test_render_view_host.h" | 43 #include "content/test/test_render_view_host.h" |
43 #include "content/test/test_web_contents.h" | 44 #include "content/test/test_web_contents.h" |
(...skipping 1985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2029 } else { | 2030 } else { |
2030 EXPECT_FALSE(rfh_deleted_observer.deleted()); | 2031 EXPECT_FALSE(rfh_deleted_observer.deleted()); |
2031 } | 2032 } |
2032 } | 2033 } |
2033 } | 2034 } |
2034 | 2035 |
2035 // Test that a pending RenderFrameHost in a non-root frame tree node is properly | 2036 // Test that a pending RenderFrameHost in a non-root frame tree node is properly |
2036 // deleted when the node is detached. Motivated by http://crbug.com/441357 and | 2037 // deleted when the node is detached. Motivated by http://crbug.com/441357 and |
2037 // http://crbug.com/444955. | 2038 // http://crbug.com/444955. |
2038 TEST_F(RenderFrameHostManagerTest, DetachPendingChild) { | 2039 TEST_F(RenderFrameHostManagerTest, DetachPendingChild) { |
2039 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 2040 SiteIsolationPolicy::IsolateAllSitesForTesting( |
2040 switches::kSitePerProcess); | 2041 base::CommandLine::ForCurrentProcess()); |
2041 | 2042 |
2042 const GURL kUrlA("http://www.google.com/"); | 2043 const GURL kUrlA("http://www.google.com/"); |
2043 const GURL kUrlB("http://webkit.org/"); | 2044 const GURL kUrlB("http://webkit.org/"); |
2044 | 2045 |
2045 // Create a page with two child frames. | 2046 // Create a page with two child frames. |
2046 contents()->NavigateAndCommit(kUrlA); | 2047 contents()->NavigateAndCommit(kUrlA); |
2047 contents()->GetMainFrame()->OnCreateChildFrame( | 2048 contents()->GetMainFrame()->OnCreateChildFrame( |
2048 contents()->GetMainFrame()->GetProcess()->GetNextRoutingID(), | 2049 contents()->GetMainFrame()->GetProcess()->GetNextRoutingID(), |
2049 blink::WebTreeScopeType::Document, "frame_name", | 2050 blink::WebTreeScopeType::Document, "frame_name", |
2050 blink::WebSandboxFlags::None); | 2051 blink::WebSandboxFlags::None); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2153 root_manager->GetRenderFrameProxyHost(site_instance.get())) | 2154 root_manager->GetRenderFrameProxyHost(site_instance.get())) |
2154 << "Proxies should have been cleaned up"; | 2155 << "Proxies should have been cleaned up"; |
2155 EXPECT_TRUE(site_instance->HasOneRef()) | 2156 EXPECT_TRUE(site_instance->HasOneRef()) |
2156 << "This SiteInstance should be destroyable now."; | 2157 << "This SiteInstance should be destroyable now."; |
2157 } | 2158 } |
2158 | 2159 |
2159 // Two tabs in the same process crash. The first tab is reloaded, and the second | 2160 // Two tabs in the same process crash. The first tab is reloaded, and the second |
2160 // tab navigates away without reloading. The second tab's navigation shouldn't | 2161 // tab navigates away without reloading. The second tab's navigation shouldn't |
2161 // mess with the first tab's content. Motivated by http://crbug.com/473714. | 2162 // mess with the first tab's content. Motivated by http://crbug.com/473714. |
2162 TEST_F(RenderFrameHostManagerTest, TwoTabsCrashOneReloadsOneLeaves) { | 2163 TEST_F(RenderFrameHostManagerTest, TwoTabsCrashOneReloadsOneLeaves) { |
2163 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 2164 SiteIsolationPolicy::IsolateAllSitesForTesting( |
2164 switches::kSitePerProcess); | 2165 base::CommandLine::ForCurrentProcess()); |
2165 | 2166 |
2166 const GURL kUrl1("http://www.google.com/"); | 2167 const GURL kUrl1("http://www.google.com/"); |
2167 const GURL kUrl2("http://webkit.org/"); | 2168 const GURL kUrl2("http://webkit.org/"); |
2168 const GURL kUrl3("http://whatwg.org/"); | 2169 const GURL kUrl3("http://whatwg.org/"); |
2169 | 2170 |
2170 // |contents1| and |contents2| navigate to the same page and then crash. | 2171 // |contents1| and |contents2| navigate to the same page and then crash. |
2171 TestWebContents* contents1 = contents(); | 2172 TestWebContents* contents1 = contents(); |
2172 scoped_ptr<TestWebContents> contents2( | 2173 scoped_ptr<TestWebContents> contents2( |
2173 TestWebContents::Create(browser_context(), contents1->GetSiteInstance())); | 2174 TestWebContents::Create(browser_context(), contents1->GetSiteInstance())); |
2174 contents1->NavigateAndCommit(kUrl1); | 2175 contents1->NavigateAndCommit(kUrl1); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2215 EXPECT_FALSE(contents2->GetMainFrame()->IsRenderFrameLive()); | 2216 EXPECT_FALSE(contents2->GetMainFrame()->IsRenderFrameLive()); |
2216 contents2->NavigateAndCommit(kUrl3); | 2217 contents2->NavigateAndCommit(kUrl3); |
2217 EXPECT_TRUE(contents2->GetMainFrame()->IsRenderFrameLive()); | 2218 EXPECT_TRUE(contents2->GetMainFrame()->IsRenderFrameLive()); |
2218 EXPECT_NE(nullptr, | 2219 EXPECT_NE(nullptr, |
2219 iframe->GetRenderFrameProxyHost(contents1->GetSiteInstance())); | 2220 iframe->GetRenderFrameProxyHost(contents1->GetSiteInstance())); |
2220 EXPECT_EQ(nullptr, | 2221 EXPECT_EQ(nullptr, |
2221 iframe->GetRenderFrameProxyHost(contents2->GetSiteInstance())); | 2222 iframe->GetRenderFrameProxyHost(contents2->GetSiteInstance())); |
2222 } | 2223 } |
2223 | 2224 |
2224 } // namespace content | 2225 } // namespace content |
OLD | NEW |