OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extensions/extension_apitest.h" | 6 #include "chrome/browser/extensions/extension_apitest.h" |
7 #include "chrome/browser/extensions/extension_host.h" | 7 #include "chrome/browser/extensions/extension_host.h" |
8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
9 #include "chrome/browser/extensions/process_map.h" | 9 #include "chrome/browser/extensions/process_map.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
244 // Opening tabs with window.open should keep the page in the opener's process. | 244 // Opening tabs with window.open should keep the page in the opener's process. |
245 ASSERT_EQ(1u, BrowserList::GetBrowserCount(browser()->profile())); | 245 ASSERT_EQ(1u, BrowserList::GetBrowserCount(browser()->profile())); |
246 WindowOpenHelper(browser(), host1, | 246 WindowOpenHelper(browser(), host1, |
247 base_url.Resolve("path1/empty.html"), true); | 247 base_url.Resolve("path1/empty.html"), true); |
248 LOG(INFO) << "WindowOpenHelper 1."; | 248 LOG(INFO) << "WindowOpenHelper 1."; |
249 WindowOpenHelper(browser(), host2, | 249 WindowOpenHelper(browser(), host2, |
250 base_url.Resolve("path2/empty.html"), true); | 250 base_url.Resolve("path2/empty.html"), true); |
251 LOG(INFO) << "End of test."; | 251 LOG(INFO) << "End of test."; |
252 } | 252 } |
253 | 253 |
254 // Tests that bookmark apps do not use the app process model and are treated | |
255 // like normal web pages instead. http://crbug.com/104636. | |
256 // TODO(creis): This test is disabled until we have a way to load a bookmark | |
257 // app in browser_tests. See http://crbug.com/104649. | |
Aaron Boodman
2011/11/18 18:19:52
These days it should be easier. I believe that the
Charlie Reis
2011/11/18 19:45:42
Ah, that's good to hear. I'll try for that in a f
| |
258 IN_PROC_BROWSER_TEST_F(AppApiTest, DISABLED_BookmarkAppGetsNormalProcess) { | |
259 CommandLine::ForCurrentProcess()->AppendSwitch( | |
260 switches::kDisablePopupBlocking); | |
261 | |
262 extensions::ProcessMap* process_map = | |
263 browser()->profile()->GetExtensionService()->process_map(); | |
264 | |
265 host_resolver()->AddRule("*", "127.0.0.1"); | |
266 ASSERT_TRUE(test_server()->Start()); | |
267 | |
268 // TODO(creis): We need a way to load an app in a test as a bookmark app. | |
269 // Until then, from_bookmark() will return false and this test will fail. | |
270 const Extension* extension = | |
271 LoadExtension(test_data_dir_.AppendASCII("app_process")); | |
272 ASSERT_TRUE(extension); | |
273 EXPECT_TRUE(extension->from_bookmark()); | |
274 GURL base_url = GetTestBaseURL("app_process"); | |
275 | |
276 // Test both opening a URL in a new tab, and opening a tab and then navigating | |
277 // it. Either way, bookmark app tabs should be considered normal processes | |
278 // with no elevated privileges and no WebUI bindings. | |
279 ui_test_utils::NavigateToURLWithDisposition( | |
280 browser(), base_url.Resolve("path1/empty.html"), NEW_FOREGROUND_TAB, | |
281 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | |
282 EXPECT_FALSE(process_map->Contains( | |
283 browser()->GetTabContentsAt(1)->render_view_host()->process()->id())); | |
284 EXPECT_FALSE(browser()->GetTabContentsAt(1)->web_ui()); | |
285 | |
286 ui_test_utils::WindowedNotificationObserver tab_added_observer( | |
287 content::NOTIFICATION_TAB_ADDED, | |
288 content::NotificationService::AllSources()); | |
289 browser()->NewTab(); | |
290 tab_added_observer.Wait(); | |
291 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path2/empty.html")); | |
292 EXPECT_FALSE(process_map->Contains( | |
293 browser()->GetTabContentsAt(2)->render_view_host()->process()->id())); | |
294 EXPECT_FALSE(browser()->GetTabContentsAt(2)->web_ui()); | |
295 | |
296 // We should have opened 2 new bookmark app tabs. Including the original blank | |
297 // tab, we now have 3 tabs. Because normal pages use the | |
298 // process-per-site-instance model, each should be in its own process. | |
299 ASSERT_EQ(3, browser()->tab_count()); | |
300 RenderViewHost* host = browser()->GetTabContentsAt(1)->render_view_host(); | |
301 EXPECT_NE(host->process(), | |
302 browser()->GetTabContentsAt(2)->render_view_host()->process()); | |
303 | |
304 // Now let's do the same using window.open. The same should happen. | |
305 ASSERT_EQ(1u, BrowserList::GetBrowserCount(browser()->profile())); | |
306 WindowOpenHelper(browser(), host, | |
307 base_url.Resolve("path1/empty.html"), true); | |
308 WindowOpenHelper(browser(), host, | |
309 base_url.Resolve("path2/empty.html"), true); | |
310 | |
311 // Now let's have a tab navigate out of and back into the app's web | |
312 // extent. Neither navigation should switch processes. | |
313 const GURL& app_url(base_url.Resolve("path1/empty.html")); | |
314 const GURL& non_app_url(base_url.Resolve("path3/empty.html")); | |
315 RenderViewHost* host2 = browser()->GetTabContentsAt(2)->render_view_host(); | |
316 NavigateTabHelper(browser()->GetTabContentsAt(2), non_app_url); | |
317 EXPECT_EQ(host2->process(), | |
318 browser()->GetTabContentsAt(2)->render_view_host()->process()); | |
319 NavigateTabHelper(browser()->GetTabContentsAt(2), app_url); | |
320 EXPECT_EQ(host2->process(), | |
321 browser()->GetTabContentsAt(2)->render_view_host()->process()); | |
322 } | |
323 | |
254 // Tests that app process switching works properly in the following scenario: | 324 // Tests that app process switching works properly in the following scenario: |
255 // 1. navigate to a page1 in the app | 325 // 1. navigate to a page1 in the app |
256 // 2. page1 redirects to a page2 outside the app extent (ie, "/server-redirect") | 326 // 2. page1 redirects to a page2 outside the app extent (ie, "/server-redirect") |
257 // 3. page2 redirects back to a page in the app | 327 // 3. page2 redirects back to a page in the app |
258 // The final navigation should end up in the app process. | 328 // The final navigation should end up in the app process. |
259 // See http://crbug.com/61757 | 329 // See http://crbug.com/61757 |
260 IN_PROC_BROWSER_TEST_F(AppApiTest, AppProcessRedirectBack) { | 330 IN_PROC_BROWSER_TEST_F(AppApiTest, AppProcessRedirectBack) { |
261 CommandLine::ForCurrentProcess()->AppendSwitch( | 331 CommandLine::ForCurrentProcess()->AppendSwitch( |
262 switches::kDisablePopupBlocking); | 332 switches::kDisablePopupBlocking); |
263 | 333 |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
514 content::Source<NavigationController>( | 584 content::Source<NavigationController>( |
515 &browser()->GetSelectedTabContentsWrapper()->controller())); | 585 &browser()->GetSelectedTabContentsWrapper()->controller())); |
516 browser()->Reload(CURRENT_TAB); | 586 browser()->Reload(CURRENT_TAB); |
517 observer.Wait(); | 587 observer.Wait(); |
518 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 588 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
519 contents->render_view_host(), L"", | 589 contents->render_view_host(), L"", |
520 L"window.domAutomationController.send(chrome.app.isInstalled)", | 590 L"window.domAutomationController.send(chrome.app.isInstalled)", |
521 &is_installed)); | 591 &is_installed)); |
522 ASSERT_TRUE(is_installed); | 592 ASSERT_TRUE(is_installed); |
523 } | 593 } |
OLD | NEW |