| 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/frame_host/cross_site_transferring_request.h" | 10 #include "content/browser/frame_host/cross_site_transferring_request.h" |
| (...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 934 } | 934 } |
| 935 | 935 |
| 936 // Tests WebUI creation. | 936 // Tests WebUI creation. |
| 937 TEST_F(RenderFrameHostManagerTest, WebUI) { | 937 TEST_F(RenderFrameHostManagerTest, WebUI) { |
| 938 set_should_create_webui(true); | 938 set_should_create_webui(true); |
| 939 SiteInstance* instance = SiteInstance::Create(browser_context()); | 939 SiteInstance* instance = SiteInstance::Create(browser_context()); |
| 940 | 940 |
| 941 scoped_ptr<TestWebContents> web_contents( | 941 scoped_ptr<TestWebContents> web_contents( |
| 942 TestWebContents::Create(browser_context(), instance)); | 942 TestWebContents::Create(browser_context(), instance)); |
| 943 RenderFrameHostManager* manager = web_contents->GetRenderManagerForTesting(); | 943 RenderFrameHostManager* manager = web_contents->GetRenderManagerForTesting(); |
| 944 RenderFrameHostImpl* initial_rfh = manager->current_frame_host(); |
| 944 | 945 |
| 945 EXPECT_FALSE(manager->current_host()->IsRenderViewLive()); | 946 EXPECT_FALSE(manager->current_host()->IsRenderViewLive()); |
| 947 EXPECT_FALSE(manager->web_ui()); |
| 948 EXPECT_TRUE(initial_rfh); |
| 946 | 949 |
| 947 const GURL kUrl("chrome://foo"); | 950 const GURL kUrl("chrome://foo"); |
| 948 NavigationEntryImpl entry(NULL /* instance */, -1 /* page_id */, kUrl, | 951 NavigationEntryImpl entry(NULL /* instance */, -1 /* page_id */, kUrl, |
| 949 Referrer(), base::string16() /* title */, | 952 Referrer(), base::string16() /* title */, |
| 950 ui::PAGE_TRANSITION_TYPED, | 953 ui::PAGE_TRANSITION_TYPED, |
| 951 false /* is_renderer_init */); | 954 false /* is_renderer_init */); |
| 952 RenderFrameHostImpl* host = GetFrameHostForNavigation(manager, entry); | 955 RenderFrameHostImpl* host = GetFrameHostForNavigation(manager, entry); |
| 953 | 956 |
| 954 // We commit the pending RenderFrameHost immediately because the previous | 957 // We commit the pending RenderFrameHost immediately because the previous |
| 955 // RenderFrameHost was not live. We test a case where it is live in | 958 // RenderFrameHost was not live. We test a case where it is live in |
| 956 // WebUIInNewTab. | 959 // WebUIInNewTab. |
| 957 EXPECT_TRUE(host); | 960 EXPECT_TRUE(host); |
| 961 EXPECT_NE(initial_rfh, host); |
| 958 EXPECT_EQ(host, manager->current_frame_host()); | 962 EXPECT_EQ(host, manager->current_frame_host()); |
| 959 EXPECT_FALSE(GetPendingFrameHost(manager)); | 963 EXPECT_FALSE(GetPendingFrameHost(manager)); |
| 960 | 964 |
| 961 // It's important that the site instance get set on the Web UI page as soon | 965 // It's important that the site instance get set on the Web UI page as soon |
| 962 // as the navigation starts, rather than lazily after it commits, so we don't | 966 // as the navigation starts, rather than lazily after it commits, so we don't |
| 963 // try to re-use the SiteInstance/process for non Web UI things that may | 967 // try to re-use the SiteInstance/process for non Web UI things that may |
| 964 // get loaded in between. | 968 // get loaded in between. |
| 965 EXPECT_TRUE(host->GetSiteInstance()->HasSite()); | 969 EXPECT_TRUE(host->GetSiteInstance()->HasSite()); |
| 966 EXPECT_EQ(kUrl, host->GetSiteInstance()->GetSiteURL()); | 970 EXPECT_EQ(kUrl, host->GetSiteInstance()->GetSiteURL()); |
| 967 | 971 |
| 968 // The Web UI is committed immediately because the RenderViewHost has not been | 972 // The Web UI is committed immediately because the RenderViewHost has not been |
| 969 // used yet. UpdateStateForNavigate() took the short cut path. | 973 // used yet. UpdateStateForNavigate() took the short cut path. |
| 970 EXPECT_FALSE(manager->pending_web_ui()); | 974 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 975 switches::kEnableBrowserSideNavigation)) { |
| 976 EXPECT_FALSE(manager->speculative_web_ui()); |
| 977 } else { |
| 978 EXPECT_FALSE(manager->pending_web_ui()); |
| 979 } |
| 971 EXPECT_TRUE(manager->web_ui()); | 980 EXPECT_TRUE(manager->web_ui()); |
| 972 | 981 |
| 973 // Commit. | 982 // Commit. |
| 974 manager->DidNavigateFrame(host, true); | 983 manager->DidNavigateFrame(host, true); |
| 975 EXPECT_TRUE( | 984 EXPECT_TRUE( |
| 976 host->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); | 985 host->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); |
| 977 } | 986 } |
| 978 | 987 |
| 979 // Tests that we can open a WebUI link in a new tab from a WebUI page and still | 988 // Tests that we can open a WebUI link in a new tab from a WebUI page and still |
| 980 // grant the correct bindings. http://crbug.com/189101. | 989 // grant the correct bindings. http://crbug.com/189101. |
| (...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1881 #if 0 | 1890 #if 0 |
| 1882 // TODO(nick): Currently a proxy to the removed frame lingers in the parent. | 1891 // TODO(nick): Currently a proxy to the removed frame lingers in the parent. |
| 1883 // Enable this assert below once the proxies to the subframe are correctly | 1892 // Enable this assert below once the proxies to the subframe are correctly |
| 1884 // cleaned up after detach. http://crbug.com/444955. | 1893 // cleaned up after detach. http://crbug.com/444955. |
| 1885 ASSERT_TRUE(site_instance->HasOneRef()) | 1894 ASSERT_TRUE(site_instance->HasOneRef()) |
| 1886 << "This SiteInstance should be destroyable now."; | 1895 << "This SiteInstance should be destroyable now."; |
| 1887 #endif | 1896 #endif |
| 1888 } | 1897 } |
| 1889 | 1898 |
| 1890 } // namespace content | 1899 } // namespace content |
| OLD | NEW |