diff options
author | creis@chromium.org <creis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-25 17:29:17 +0000 |
---|---|---|
committer | creis@chromium.org <creis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-25 17:29:17 +0000 |
commit | ea7b7d8518310bca2c4a76db0d56bef494e9cb6b (patch) | |
tree | cdcd4962c1ed27e5ad3165a5a0e426382c1384e3 /chrome/browser/extensions/isolated_app_browsertest.cc | |
parent | 1499b7dd537a002bcda757cc795e92f865fa9af7 (diff) | |
download | chromium_src-ea7b7d8518310bca2c4a76db0d56bef494e9cb6b.zip chromium_src-ea7b7d8518310bca2c4a76db0d56bef494e9cb6b.tar.gz chromium_src-ea7b7d8518310bca2c4a76db0d56bef494e9cb6b.tar.bz2 |
Tighten the hosted app process model workaround to only apply to popups.
Also exclude isolated apps and fix AppProcessRedirectBack test.
BUG=128772
BUG=108853
TEST=Clicking a non-app link in a hosted or isolated app stays in process.
Review URL: https://chromiumcodereview.appspot.com/10425003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139061 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/isolated_app_browsertest.cc')
-rw-r--r-- | chrome/browser/extensions/isolated_app_browsertest.cc | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/chrome/browser/extensions/isolated_app_browsertest.cc b/chrome/browser/extensions/isolated_app_browsertest.cc index 6664eac..a08f6c9 100644 --- a/chrome/browser/extensions/isolated_app_browsertest.cc +++ b/chrome/browser/extensions/isolated_app_browsertest.cc @@ -169,3 +169,58 @@ IN_PROC_BROWSER_TEST_F(IsolatedAppTest, NoCookieIsolationWithoutApp) { EXPECT_TRUE(HasCookie(browser()->GetWebContentsAt(2), "app2=4")); EXPECT_TRUE(HasCookie(browser()->GetWebContentsAt(2), "nonAppFrame=6")); } + +// Tests that isolated apps processes do not render top-level non-app pages. +// This is true even in the case of the OAuth workaround for hosted apps, +// where non-app popups may be kept in the hosted app process. +IN_PROC_BROWSER_TEST_F(IsolatedAppTest, IsolatedAppProcessModel) { + host_resolver()->AddRule("*", "127.0.0.1"); + ASSERT_TRUE(test_server()->Start()); + + ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("isolated_apps/app1"))); + + // The app under test acts on URLs whose host is "localhost", + // so the URLs we navigate to must have host "localhost". + GURL base_url = test_server()->GetURL( + "files/extensions/isolated_apps/"); + GURL::Replacements replace_host; + std::string host_str("localhost"); // Must stay in scope with replace_host. + replace_host.SetHostStr(host_str); + base_url = base_url.ReplaceComponents(replace_host); + + // Create three tabs in the isolated app in different ways. + ui_test_utils::NavigateToURLWithDisposition( + browser(), base_url.Resolve("app1/main.html"), + CURRENT_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); + ui_test_utils::NavigateToURLWithDisposition( + browser(), base_url.Resolve("app1/main.html"), + NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); + // For the third tab, use window.open to keep it in process with an opener. + OpenWindow(browser()->GetWebContentsAt(0), + base_url.Resolve("app1/main.html"), true, NULL); + + // In a fourth tab, use window.open to a non-app URL. It should open in a + // separate process, even though this would trigger the OAuth workaround + // for hosted apps (from http://crbug.com/59285). + OpenWindow(browser()->GetWebContentsAt(0), + base_url.Resolve("non_app/main.html"), false, NULL); + + // We should now have four tabs, the first and third sharing a process. + // The second one is an independent instance in a separate process. + ASSERT_EQ(4, browser()->tab_count()); + int process_id_0 = + browser()->GetWebContentsAt(0)->GetRenderProcessHost()->GetID(); + int process_id_1 = + browser()->GetWebContentsAt(1)->GetRenderProcessHost()->GetID(); + EXPECT_NE(process_id_0, process_id_1); + EXPECT_EQ(process_id_0, + browser()->GetWebContentsAt(2)->GetRenderProcessHost()->GetID()); + EXPECT_NE(process_id_0, + browser()->GetWebContentsAt(3)->GetRenderProcessHost()->GetID()); + + // Navigating the second tab out of the app should cause a process swap. + const GURL& non_app_url(base_url.Resolve("non_app/main.html")); + NavigateInRenderer(browser()->GetWebContentsAt(1), non_app_url); + EXPECT_NE(process_id_1, + browser()->GetWebContentsAt(1)->GetRenderProcessHost()->GetID()); +} |