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

Side by Side Diff: content/browser/frame_host/render_frame_host_manager_browsertest.cc

Issue 1413863006: Change BrowsingInstance when changing WebUI type. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix nits. Created 5 years, 1 month 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
« no previous file with comments | « content/browser/frame_host/render_frame_host_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_controller_factory_registry.h"
21 #include "content/browser/webui/web_ui_impl.h" 22 #include "content/browser/webui/web_ui_impl.h"
22 #include "content/common/content_constants_internal.h" 23 #include "content/common/content_constants_internal.h"
23 #include "content/common/input_messages.h" 24 #include "content/common/input_messages.h"
24 #include "content/common/site_isolation_policy.h" 25 #include "content/common/site_isolation_policy.h"
25 #include "content/public/browser/navigation_controller.h" 26 #include "content/public/browser/navigation_controller.h"
26 #include "content/public/browser/navigation_entry.h" 27 #include "content/public/browser/navigation_entry.h"
27 #include "content/public/browser/render_process_host.h" 28 #include "content/public/browser/render_process_host.h"
28 #include "content/public/browser/resource_dispatcher_host.h" 29 #include "content/public/browser/resource_dispatcher_host.h"
29 #include "content/public/browser/web_contents.h" 30 #include "content/public/browser/web_contents.h"
30 #include "content/public/browser/web_contents_observer.h" 31 #include "content/public/browser/web_contents_observer.h"
(...skipping 1604 matching lines...) Expand 10 before | Expand all | Expand 10 after
1635 // Navigate to url1 and check bindings. 1636 // Navigate to url1 and check bindings.
1636 NavigateToURL(new_shell, url1); 1637 NavigateToURL(new_shell, url1);
1637 // The navigation should have used the first SiteInstance, otherwise 1638 // The navigation should have used the first SiteInstance, otherwise
1638 // |initial_rvh| did not have a chance to be used. 1639 // |initial_rvh| did not have a chance to be used.
1639 EXPECT_EQ(new_web_contents->GetSiteInstance(), site_instance1); 1640 EXPECT_EQ(new_web_contents->GetSiteInstance(), site_instance1);
1640 EXPECT_EQ(BINDINGS_POLICY_WEB_UI, 1641 EXPECT_EQ(BINDINGS_POLICY_WEB_UI,
1641 new_web_contents->GetRenderViewHost()->GetEnabledBindings()); 1642 new_web_contents->GetRenderViewHost()->GetEnabledBindings());
1642 } 1643 }
1643 1644
1644 // crbug.com/424526 1645 // crbug.com/424526
1645 // The test loads a WebUI page in rocess-per-tab mode, then navigates to a blank 1646 // The test loads a WebUI page in process-per-tab mode, then navigates to a
1646 // page and then to a regular page. The bug reproduces if blank page is visited 1647 // blank page and then to a regular page. The bug reproduces if blank page is
1647 // in between WebUI and regular page. 1648 // visited in between WebUI and regular page.
1648 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, 1649 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest,
1649 ForceSwapAfterWebUIBindings) { 1650 ForceSwapAfterWebUIBindings) {
1650 base::CommandLine::ForCurrentProcess()->AppendSwitch( 1651 base::CommandLine::ForCurrentProcess()->AppendSwitch(
1651 switches::kProcessPerTab); 1652 switches::kProcessPerTab);
1652 StartEmbeddedServer(); 1653 StartEmbeddedServer();
1653 1654
1654 const GURL web_ui_url(std::string(kChromeUIScheme) + "://" + 1655 const GURL web_ui_url(std::string(kChromeUIScheme) + "://" +
1655 std::string(kChromeUIGpuHost)); 1656 std::string(kChromeUIGpuHost));
1656 NavigateToURL(shell(), web_ui_url); 1657 EXPECT_TRUE(NavigateToURL(shell(), web_ui_url));
1657 EXPECT_TRUE(ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( 1658 EXPECT_TRUE(ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings(
1658 shell()->web_contents()->GetRenderProcessHost()->GetID())); 1659 shell()->web_contents()->GetRenderProcessHost()->GetID()));
1659 1660
1660 NavigateToURL(shell(), GURL(url::kAboutBlankURL)); 1661 // Capture the SiteInstance before navigating to about:blank to ensure
1662 // it doesn't change.
1663 scoped_refptr<SiteInstance> orig_site_instance(
1664 shell()->web_contents()->GetSiteInstance());
1665
1666 EXPECT_TRUE(NavigateToURL(shell(), GURL(url::kAboutBlankURL)));
1667 EXPECT_EQ(orig_site_instance, shell()->web_contents()->GetSiteInstance());
1661 1668
1662 GURL regular_page_url(embedded_test_server()->GetURL("/title2.html")); 1669 GURL regular_page_url(embedded_test_server()->GetURL("/title2.html"));
1663 NavigateToURL(shell(), regular_page_url); 1670 EXPECT_TRUE(NavigateToURL(shell(), regular_page_url));
1664 EXPECT_FALSE(ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( 1671 EXPECT_FALSE(ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings(
1665 shell()->web_contents()->GetRenderProcessHost()->GetID())); 1672 shell()->web_contents()->GetRenderProcessHost()->GetID()));
1666 } 1673 }
1667 1674
1668 class FileChooserDelegate : public WebContentsDelegate { 1675 class FileChooserDelegate : public WebContentsDelegate {
1669 public: 1676 public:
1670 FileChooserDelegate(const base::FilePath& file) 1677 FileChooserDelegate(const base::FilePath& file)
1671 : file_(file), file_chosen_(false) {} 1678 : file_(file), file_chosen_(false) {}
1672 1679
1673 void RunFileChooser(WebContents* web_contents, 1680 void RunFileChooser(WebContents* web_contents,
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
2157 // properly ignored, there will be no crash. Therefore, navigate the 2164 // 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 2165 // original window to the same site as the popup, which will just exit the
2159 // process cleanly. 2166 // process cleanly.
2160 EXPECT_TRUE(NavigateToURL( 2167 EXPECT_TRUE(NavigateToURL(
2161 shell(), embedded_test_server()->GetURL("b.com", "/title3.html"))); 2168 shell(), embedded_test_server()->GetURL("b.com", "/title3.html")));
2162 watcher.Wait(); 2169 watcher.Wait();
2163 EXPECT_TRUE(watcher.did_exit_normally()); 2170 EXPECT_TRUE(watcher.did_exit_normally());
2164 } 2171 }
2165 2172
2166 } // namespace content 2173 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698