Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/utf_string_conversions.h" | 5 #include "base/utf_string_conversions.h" |
| 6 #include "chrome/browser/browser_list.h" | 6 #include "chrome/browser/browser_list.h" |
| 7 #include "chrome/browser/extensions/extension_apitest.h" | 7 #include "chrome/browser/extensions/extension_apitest.h" |
| 8 #include "chrome/browser/extensions/extension_host.h" | 8 #include "chrome/browser/extensions/extension_host.h" |
| 9 #include "chrome/browser/extensions/extension_process_manager.h" | 9 #include "chrome/browser/extensions/extension_process_manager.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 L"window.location = '" + UTF8ToWide(url.spec()) + L"';", | 54 L"window.location = '" + UTF8ToWide(url.spec()) + L"';", |
| 55 &result)); | 55 &result)); |
| 56 ASSERT_TRUE(result); | 56 ASSERT_TRUE(result); |
| 57 | 57 |
| 58 if (!contents->controller().GetLastCommittedEntry() || | 58 if (!contents->controller().GetLastCommittedEntry() || |
| 59 contents->controller().GetLastCommittedEntry()->url() != url) | 59 contents->controller().GetLastCommittedEntry()->url() != url) |
| 60 ui_test_utils::WaitForNavigation(&contents->controller()); | 60 ui_test_utils::WaitForNavigation(&contents->controller()); |
| 61 EXPECT_EQ(url, contents->controller().GetLastCommittedEntry()->url()); | 61 EXPECT_EQ(url, contents->controller().GetLastCommittedEntry()->url()); |
| 62 } | 62 } |
| 63 | 63 |
| 64 #if defined(OS_WIN) | 64 IN_PROC_BROWSER_TEST_F(AppApiTest, AppProcess) { |
| 65 // AppProcess sometimes hangs on Windows | |
| 66 // http://crbug.com/58810 | |
| 67 #define MAYBE_AppProcess DISABLED_AppProcess | |
| 68 #else | |
| 69 #define MAYBE_AppProcess AppProcess | |
| 70 #endif | |
| 71 IN_PROC_BROWSER_TEST_F(AppApiTest, MAYBE_AppProcess) { | |
| 72 CommandLine::ForCurrentProcess()->AppendSwitch( | 65 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 73 switches::kDisablePopupBlocking); | 66 switches::kDisablePopupBlocking); |
| 74 | 67 |
| 75 host_resolver()->AddRule("*", "127.0.0.1"); | 68 host_resolver()->AddRule("*", "127.0.0.1"); |
| 76 ASSERT_TRUE(test_server()->Start()); | 69 ASSERT_TRUE(test_server()->Start()); |
| 77 | 70 |
| 78 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app_process"))); | 71 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app_process"))); |
| 79 | 72 |
| 80 // Open two tabs in the app, one outside it. | 73 // Open two tabs in the app, one outside it. |
| 81 GURL base_url = test_server()->GetURL( | 74 GURL base_url = test_server()->GetURL( |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 NavigateTabHelper(browser()->GetTabContentsAt(6), app_url); | 131 NavigateTabHelper(browser()->GetTabContentsAt(6), app_url); |
| 139 EXPECT_EQ(host->process(), | 132 EXPECT_EQ(host->process(), |
| 140 browser()->GetTabContentsAt(6)->render_view_host()->process()); | 133 browser()->GetTabContentsAt(6)->render_view_host()->process()); |
| 141 bool windowOpenerValid = false; | 134 bool windowOpenerValid = false; |
| 142 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 135 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 143 browser()->GetTabContentsAt(6)->render_view_host(), L"", | 136 browser()->GetTabContentsAt(6)->render_view_host(), L"", |
| 144 L"window.domAutomationController.send(window.opener != null)", | 137 L"window.domAutomationController.send(window.opener != null)", |
| 145 &windowOpenerValid)); | 138 &windowOpenerValid)); |
| 146 ASSERT_TRUE(windowOpenerValid); | 139 ASSERT_TRUE(windowOpenerValid); |
| 147 } | 140 } |
| 141 | |
| 142 // Tests that app process switching works properly in the following scenario: | |
| 143 // 1. navigate to a page1 in the app | |
| 144 // 2. page1 redirects to a page2 outside the app extent | |
|
Charlie Reis
2011/01/05 00:57:25
Maybe add "(i.e., /server-redirect)" to make it cl
Matt Perry
2011/01/05 01:14:47
Done.
| |
| 145 // 3. page2 redirects back to a page in the app | |
| 146 // The final navigation should end up in the app process. | |
| 147 // See http://crbug.com/61757 | |
| 148 IN_PROC_BROWSER_TEST_F(AppApiTest, AppProcessRedirectBack) { | |
| 149 CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 150 switches::kDisablePopupBlocking); | |
| 151 | |
| 152 host_resolver()->AddRule("*", "127.0.0.1"); | |
| 153 ASSERT_TRUE(test_server()->Start()); | |
| 154 | |
| 155 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app_process"))); | |
| 156 | |
| 157 // Open two tabs in the app, one outside it. | |
|
Charlie Reis
2011/01/05 00:57:25
Copy/paste bug. (There's no third tab outside the
Matt Perry
2011/01/05 01:14:47
Done.
| |
| 158 GURL base_url = test_server()->GetURL( | |
| 159 "files/extensions/api_test/app_process/"); | |
| 160 | |
| 161 // The app under test acts on URLs whose host is "localhost", | |
| 162 // so the URLs we navigate to must have host "localhost". | |
| 163 GURL::Replacements replace_host; | |
| 164 std::string host_str("localhost"); // must stay in scope with replace_host | |
| 165 replace_host.SetHostStr(host_str); | |
| 166 base_url = base_url.ReplaceComponents(replace_host); | |
| 167 | |
| 168 browser()->NewTab(); | |
| 169 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html")); | |
| 170 browser()->NewTab(); | |
| 171 ui_test_utils::NavigateToURL(browser(), | |
| 172 base_url.Resolve("path1/redirect.html")); | |
| 173 | |
| 174 NavigationController& controller = | |
| 175 browser()->GetSelectedTabContents()->controller(); | |
| 176 while (controller.GetActiveEntry()->url().path().find("empty.html") == | |
|
Charlie Reis
2011/01/05 00:57:25
"empty.html" is in the redirect URL, too. Could w
Matt Perry
2011/01/05 01:14:47
Good catch! Done.
| |
| 177 std::string::npos) { | |
| 178 ui_test_utils::WaitForNavigation(&controller); | |
| 179 } | |
| 180 | |
| 181 // 3 tabs, including the initial about:blank. The last 2 should be the same | |
| 182 // process. | |
| 183 ASSERT_EQ(3, browser()->tab_count()); | |
| 184 RenderViewHost* host = browser()->GetTabContentsAt(1)->render_view_host(); | |
| 185 EXPECT_EQ(host->process(), | |
| 186 browser()->GetTabContentsAt(2)->render_view_host()->process()); | |
| 187 } | |
| OLD | NEW |