| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 // Open two tabs in the app, one outside it. | 98 // Open two tabs in the app, one outside it. |
| 99 GURL base_url = GetTestBaseURL("app_process"); | 99 GURL base_url = GetTestBaseURL("app_process"); |
| 100 | 100 |
| 101 // Test both opening a URL in a new tab, and opening a tab and then navigating | 101 // Test both opening a URL in a new tab, and opening a tab and then navigating |
| 102 // it. Either way, app tabs should be considered extension processes, but | 102 // it. Either way, app tabs should be considered extension processes, but |
| 103 // they have no elevated privileges and thus should not have WebUI bindings. | 103 // they have no elevated privileges and thus should not have WebUI bindings. |
| 104 ui_test_utils::NavigateToURLWithDisposition( | 104 ui_test_utils::NavigateToURLWithDisposition( |
| 105 browser(), base_url.Resolve("path1/empty.html"), NEW_FOREGROUND_TAB, | 105 browser(), base_url.Resolve("path1/empty.html"), NEW_FOREGROUND_TAB, |
| 106 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 106 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 107 EXPECT_TRUE(process_map->Contains( | 107 EXPECT_TRUE(process_map->Contains( |
| 108 browser()->GetTabContentsAt(1)->render_view_host()->process()->id())); | 108 browser()->GetTabContentsAt(1)->render_view_host()->process()->GetID())); |
| 109 EXPECT_FALSE(browser()->GetTabContentsAt(1)->web_ui()); | 109 EXPECT_FALSE(browser()->GetTabContentsAt(1)->web_ui()); |
| 110 LOG(INFO) << "Nav 1."; | 110 LOG(INFO) << "Nav 1."; |
| 111 | 111 |
| 112 ui_test_utils::NavigateToURLWithDisposition( | 112 ui_test_utils::NavigateToURLWithDisposition( |
| 113 browser(), base_url.Resolve("path2/empty.html"), NEW_FOREGROUND_TAB, | 113 browser(), base_url.Resolve("path2/empty.html"), NEW_FOREGROUND_TAB, |
| 114 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 114 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 115 EXPECT_TRUE(process_map->Contains( | 115 EXPECT_TRUE(process_map->Contains( |
| 116 browser()->GetTabContentsAt(2)->render_view_host()->process()->id())); | 116 browser()->GetTabContentsAt(2)->render_view_host()->process()->GetID())); |
| 117 EXPECT_FALSE(browser()->GetTabContentsAt(2)->web_ui()); | 117 EXPECT_FALSE(browser()->GetTabContentsAt(2)->web_ui()); |
| 118 LOG(INFO) << "Nav 2."; | 118 LOG(INFO) << "Nav 2."; |
| 119 | 119 |
| 120 ui_test_utils::WindowedNotificationObserver tab_added_observer( | 120 ui_test_utils::WindowedNotificationObserver tab_added_observer( |
| 121 content::NOTIFICATION_TAB_ADDED, | 121 content::NOTIFICATION_TAB_ADDED, |
| 122 content::NotificationService::AllSources()); | 122 content::NotificationService::AllSources()); |
| 123 browser()->NewTab(); | 123 browser()->NewTab(); |
| 124 tab_added_observer.Wait(); | 124 tab_added_observer.Wait(); |
| 125 LOG(INFO) << "New tab."; | 125 LOG(INFO) << "New tab."; |
| 126 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path3/empty.html")); | 126 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path3/empty.html")); |
| 127 LOG(INFO) << "Nav 3."; | 127 LOG(INFO) << "Nav 3."; |
| 128 EXPECT_FALSE(process_map->Contains( | 128 EXPECT_FALSE(process_map->Contains( |
| 129 browser()->GetTabContentsAt(3)->render_view_host()->process()->id())); | 129 browser()->GetTabContentsAt(3)->render_view_host()->process()->GetID())); |
| 130 EXPECT_FALSE(browser()->GetTabContentsAt(3)->web_ui()); | 130 EXPECT_FALSE(browser()->GetTabContentsAt(3)->web_ui()); |
| 131 | 131 |
| 132 // We should have opened 3 new extension tabs. Including the original blank | 132 // We should have opened 3 new extension tabs. Including the original blank |
| 133 // tab, we now have 4 tabs. Because the app_process app has the background | 133 // tab, we now have 4 tabs. Because the app_process app has the background |
| 134 // permission, all of its instances are in the same process. Thus two tabs | 134 // permission, all of its instances are in the same process. Thus two tabs |
| 135 // should be part of the extension app and grouped in the same process. | 135 // should be part of the extension app and grouped in the same process. |
| 136 ASSERT_EQ(4, browser()->tab_count()); | 136 ASSERT_EQ(4, browser()->tab_count()); |
| 137 RenderViewHost* host = browser()->GetTabContentsAt(1)->render_view_host(); | 137 RenderViewHost* host = browser()->GetTabContentsAt(1)->render_view_host(); |
| 138 | 138 |
| 139 EXPECT_EQ(host->process(), | 139 EXPECT_EQ(host->process(), |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 GURL base_url = GetTestBaseURL("app_process_instances"); | 210 GURL base_url = GetTestBaseURL("app_process_instances"); |
| 211 | 211 |
| 212 // Test both opening a URL in a new tab, and opening a tab and then navigating | 212 // Test both opening a URL in a new tab, and opening a tab and then navigating |
| 213 // it. Either way, app tabs should be considered extension processes, but | 213 // it. Either way, app tabs should be considered extension processes, but |
| 214 // they have no elevated privileges and thus should not have WebUI bindings. | 214 // they have no elevated privileges and thus should not have WebUI bindings. |
| 215 ui_test_utils::NavigateToURLWithDisposition( | 215 ui_test_utils::NavigateToURLWithDisposition( |
| 216 browser(), base_url.Resolve("path1/empty.html"), NEW_FOREGROUND_TAB, | 216 browser(), base_url.Resolve("path1/empty.html"), NEW_FOREGROUND_TAB, |
| 217 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 217 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 218 LOG(INFO) << "Nav 1."; | 218 LOG(INFO) << "Nav 1."; |
| 219 EXPECT_TRUE(process_map->Contains( | 219 EXPECT_TRUE(process_map->Contains( |
| 220 browser()->GetTabContentsAt(1)->render_view_host()->process()->id())); | 220 browser()->GetTabContentsAt(1)->render_view_host()->process()->GetID())); |
| 221 EXPECT_FALSE(browser()->GetTabContentsAt(1)->web_ui()); | 221 EXPECT_FALSE(browser()->GetTabContentsAt(1)->web_ui()); |
| 222 | 222 |
| 223 ui_test_utils::WindowedNotificationObserver tab_added_observer( | 223 ui_test_utils::WindowedNotificationObserver tab_added_observer( |
| 224 content::NOTIFICATION_TAB_ADDED, | 224 content::NOTIFICATION_TAB_ADDED, |
| 225 content::NotificationService::AllSources()); | 225 content::NotificationService::AllSources()); |
| 226 browser()->NewTab(); | 226 browser()->NewTab(); |
| 227 tab_added_observer.Wait(); | 227 tab_added_observer.Wait(); |
| 228 LOG(INFO) << "New tab."; | 228 LOG(INFO) << "New tab."; |
| 229 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path2/empty.html")); | 229 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path2/empty.html")); |
| 230 LOG(INFO) << "Nav 2."; | 230 LOG(INFO) << "Nav 2."; |
| 231 EXPECT_TRUE(process_map->Contains( | 231 EXPECT_TRUE(process_map->Contains( |
| 232 browser()->GetTabContentsAt(2)->render_view_host()->process()->id())); | 232 browser()->GetTabContentsAt(2)->render_view_host()->process()->GetID())); |
| 233 EXPECT_FALSE(browser()->GetTabContentsAt(2)->web_ui()); | 233 EXPECT_FALSE(browser()->GetTabContentsAt(2)->web_ui()); |
| 234 | 234 |
| 235 // We should have opened 2 new extension tabs. Including the original blank | 235 // We should have opened 2 new extension tabs. Including the original blank |
| 236 // tab, we now have 3 tabs. The two app tabs should not be in the same | 236 // tab, we now have 3 tabs. The two app tabs should not be in the same |
| 237 // process, since they do not have the background permission. (Thus, we want | 237 // process, since they do not have the background permission. (Thus, we want |
| 238 // to separate them to improve responsiveness.) | 238 // to separate them to improve responsiveness.) |
| 239 ASSERT_EQ(3, browser()->tab_count()); | 239 ASSERT_EQ(3, browser()->tab_count()); |
| 240 RenderViewHost* host1 = browser()->GetTabContentsAt(1)->render_view_host(); | 240 RenderViewHost* host1 = browser()->GetTabContentsAt(1)->render_view_host(); |
| 241 RenderViewHost* host2 = browser()->GetTabContentsAt(2)->render_view_host(); | 241 RenderViewHost* host2 = browser()->GetTabContentsAt(2)->render_view_host(); |
| 242 EXPECT_NE(host1->process(), host2->process()); | 242 EXPECT_NE(host1->process(), host2->process()); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 ASSERT_TRUE(test_server()->Start()); | 301 ASSERT_TRUE(test_server()->Start()); |
| 302 | 302 |
| 303 // The app under test acts on URLs whose host is "localhost", | 303 // The app under test acts on URLs whose host is "localhost", |
| 304 // so the URLs we navigate to must have host "localhost". | 304 // so the URLs we navigate to must have host "localhost". |
| 305 GURL base_url = GetTestBaseURL("app_process"); | 305 GURL base_url = GetTestBaseURL("app_process"); |
| 306 | 306 |
| 307 // Load an app URL before loading the app. | 307 // Load an app URL before loading the app. |
| 308 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html")); | 308 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html")); |
| 309 TabContents* contents = browser()->GetTabContentsAt(0); | 309 TabContents* contents = browser()->GetTabContentsAt(0); |
| 310 EXPECT_FALSE(process_map->Contains( | 310 EXPECT_FALSE(process_map->Contains( |
| 311 contents->render_view_host()->process()->id())); | 311 contents->render_view_host()->process()->GetID())); |
| 312 | 312 |
| 313 // Load app and navigate to the page. | 313 // Load app and navigate to the page. |
| 314 const Extension* app = | 314 const Extension* app = |
| 315 LoadExtension(test_data_dir_.AppendASCII("app_process")); | 315 LoadExtension(test_data_dir_.AppendASCII("app_process")); |
| 316 ASSERT_TRUE(app); | 316 ASSERT_TRUE(app); |
| 317 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html")); | 317 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html")); |
| 318 EXPECT_TRUE(process_map->Contains( | 318 EXPECT_TRUE(process_map->Contains( |
| 319 contents->render_view_host()->process()->id())); | 319 contents->render_view_host()->process()->GetID())); |
| 320 | 320 |
| 321 // Disable app and navigate to the page. | 321 // Disable app and navigate to the page. |
| 322 DisableExtension(app->id()); | 322 DisableExtension(app->id()); |
| 323 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html")); | 323 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html")); |
| 324 EXPECT_FALSE(process_map->Contains( | 324 EXPECT_FALSE(process_map->Contains( |
| 325 contents->render_view_host()->process()->id())); | 325 contents->render_view_host()->process()->GetID())); |
| 326 | 326 |
| 327 // Enable app and reload the page. | 327 // Enable app and reload the page. |
| 328 EnableExtension(app->id()); | 328 EnableExtension(app->id()); |
| 329 ui_test_utils::WindowedNotificationObserver reload_observer( | 329 ui_test_utils::WindowedNotificationObserver reload_observer( |
| 330 content::NOTIFICATION_LOAD_STOP, | 330 content::NOTIFICATION_LOAD_STOP, |
| 331 content::Source<NavigationController>( | 331 content::Source<NavigationController>( |
| 332 &browser()->GetSelectedTabContentsWrapper()->controller())); | 332 &browser()->GetSelectedTabContentsWrapper()->controller())); |
| 333 browser()->Reload(CURRENT_TAB); | 333 browser()->Reload(CURRENT_TAB); |
| 334 reload_observer.Wait(); | 334 reload_observer.Wait(); |
| 335 EXPECT_TRUE(process_map->Contains( | 335 EXPECT_TRUE(process_map->Contains( |
| 336 contents->render_view_host()->process()->id())); | 336 contents->render_view_host()->process()->GetID())); |
| 337 | 337 |
| 338 // Disable app and reload the page. | 338 // Disable app and reload the page. |
| 339 DisableExtension(app->id()); | 339 DisableExtension(app->id()); |
| 340 ui_test_utils::WindowedNotificationObserver reload_observer2( | 340 ui_test_utils::WindowedNotificationObserver reload_observer2( |
| 341 content::NOTIFICATION_LOAD_STOP, | 341 content::NOTIFICATION_LOAD_STOP, |
| 342 content::Source<NavigationController>( | 342 content::Source<NavigationController>( |
| 343 &browser()->GetSelectedTabContentsWrapper()->controller())); | 343 &browser()->GetSelectedTabContentsWrapper()->controller())); |
| 344 browser()->Reload(CURRENT_TAB); | 344 browser()->Reload(CURRENT_TAB); |
| 345 reload_observer2.Wait(); | 345 reload_observer2.Wait(); |
| 346 EXPECT_FALSE(process_map->Contains( | 346 EXPECT_FALSE(process_map->Contains( |
| 347 contents->render_view_host()->process()->id())); | 347 contents->render_view_host()->process()->GetID())); |
| 348 | 348 |
| 349 // Enable app and reload via JavaScript. | 349 // Enable app and reload via JavaScript. |
| 350 EnableExtension(app->id()); | 350 EnableExtension(app->id()); |
| 351 ui_test_utils::WindowedNotificationObserver js_reload_observer( | 351 ui_test_utils::WindowedNotificationObserver js_reload_observer( |
| 352 content::NOTIFICATION_LOAD_STOP, | 352 content::NOTIFICATION_LOAD_STOP, |
| 353 content::Source<NavigationController>( | 353 content::Source<NavigationController>( |
| 354 &browser()->GetSelectedTabContentsWrapper()->controller())); | 354 &browser()->GetSelectedTabContentsWrapper()->controller())); |
| 355 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript(contents->render_view_host(), | 355 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript(contents->render_view_host(), |
| 356 L"", L"location.reload();")); | 356 L"", L"location.reload();")); |
| 357 js_reload_observer.Wait(); | 357 js_reload_observer.Wait(); |
| 358 EXPECT_TRUE(process_map->Contains( | 358 EXPECT_TRUE(process_map->Contains( |
| 359 contents->render_view_host()->process()->id())); | 359 contents->render_view_host()->process()->GetID())); |
| 360 | 360 |
| 361 // Disable app and reload via JavaScript. | 361 // Disable app and reload via JavaScript. |
| 362 DisableExtension(app->id()); | 362 DisableExtension(app->id()); |
| 363 ui_test_utils::WindowedNotificationObserver js_reload_observer2( | 363 ui_test_utils::WindowedNotificationObserver js_reload_observer2( |
| 364 content::NOTIFICATION_LOAD_STOP, | 364 content::NOTIFICATION_LOAD_STOP, |
| 365 content::Source<NavigationController>( | 365 content::Source<NavigationController>( |
| 366 &browser()->GetSelectedTabContentsWrapper()->controller())); | 366 &browser()->GetSelectedTabContentsWrapper()->controller())); |
| 367 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript(contents->render_view_host(), | 367 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript(contents->render_view_host(), |
| 368 L"", L"location.reload();")); | 368 L"", L"location.reload();")); |
| 369 js_reload_observer2.Wait(); | 369 js_reload_observer2.Wait(); |
| 370 EXPECT_FALSE(process_map->Contains( | 370 EXPECT_FALSE(process_map->Contains( |
| 371 contents->render_view_host()->process()->id())); | 371 contents->render_view_host()->process()->GetID())); |
| 372 } | 372 } |
| 373 | 373 |
| 374 // Tests that if we have a non-app process (path3/container.html) that has an | 374 // Tests that if we have a non-app process (path3/container.html) that has an |
| 375 // iframe with a URL in the app's extent (path1/iframe.html), then opening a | 375 // iframe with a URL in the app's extent (path1/iframe.html), then opening a |
| 376 // link from that iframe to a new window to a URL in the app's extent (path1/ | 376 // link from that iframe to a new window to a URL in the app's extent (path1/ |
| 377 // empty.html) results in the new window being in an app process. See | 377 // empty.html) results in the new window being in an app process. See |
| 378 // http://crbug.com/89272 for more details. | 378 // http://crbug.com/89272 for more details. |
| 379 IN_PROC_BROWSER_TEST_F(AppApiTest, OpenAppFromIframe) { | 379 IN_PROC_BROWSER_TEST_F(AppApiTest, OpenAppFromIframe) { |
| 380 CommandLine::ForCurrentProcess()->AppendSwitch( | 380 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 381 switches::kDisablePopupBlocking); | 381 switches::kDisablePopupBlocking); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 392 const Extension* app = | 392 const Extension* app = |
| 393 LoadExtension(test_data_dir_.AppendASCII("app_process")); | 393 LoadExtension(test_data_dir_.AppendASCII("app_process")); |
| 394 ASSERT_TRUE(app); | 394 ASSERT_TRUE(app); |
| 395 ui_test_utils::NavigateToURLWithDisposition( | 395 ui_test_utils::NavigateToURLWithDisposition( |
| 396 browser(), | 396 browser(), |
| 397 base_url.Resolve("path3/container.html"), | 397 base_url.Resolve("path3/container.html"), |
| 398 CURRENT_TAB, | 398 CURRENT_TAB, |
| 399 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION | | 399 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION | |
| 400 ui_test_utils::BROWSER_TEST_WAIT_FOR_BROWSER); | 400 ui_test_utils::BROWSER_TEST_WAIT_FOR_BROWSER); |
| 401 EXPECT_FALSE(process_map->Contains( | 401 EXPECT_FALSE(process_map->Contains( |
| 402 browser()->GetTabContentsAt(0)->render_view_host()->process()->id())); | 402 browser()->GetTabContentsAt(0)->render_view_host()->process()->GetID())); |
| 403 | 403 |
| 404 // Wait for popup window to appear. | 404 // Wait for popup window to appear. |
| 405 GURL app_url = base_url.Resolve("path1/empty.html"); | 405 GURL app_url = base_url.Resolve("path1/empty.html"); |
| 406 Browser* last_active_browser = BrowserList::GetLastActive(); | 406 Browser* last_active_browser = BrowserList::GetLastActive(); |
| 407 EXPECT_TRUE(last_active_browser); | 407 EXPECT_TRUE(last_active_browser); |
| 408 ASSERT_NE(browser(), last_active_browser); | 408 ASSERT_NE(browser(), last_active_browser); |
| 409 TabContents* newtab = last_active_browser->GetSelectedTabContents(); | 409 TabContents* newtab = last_active_browser->GetSelectedTabContents(); |
| 410 EXPECT_TRUE(newtab); | 410 EXPECT_TRUE(newtab); |
| 411 if (!newtab->controller().GetLastCommittedEntry() || | 411 if (!newtab->controller().GetLastCommittedEntry() || |
| 412 newtab->controller().GetLastCommittedEntry()->url() != app_url) { | 412 newtab->controller().GetLastCommittedEntry()->url() != app_url) { |
| 413 // TODO(gbillock): This still looks racy. Need to make a custom | 413 // TODO(gbillock): This still looks racy. Need to make a custom |
| 414 // observer to intercept new window creation and then look for | 414 // observer to intercept new window creation and then look for |
| 415 // NAV_ENTRY_COMMITTED on the new tab there. | 415 // NAV_ENTRY_COMMITTED on the new tab there. |
| 416 ui_test_utils::WindowedNotificationObserver observer( | 416 ui_test_utils::WindowedNotificationObserver observer( |
| 417 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 417 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 418 content::Source<NavigationController>(&(newtab->controller()))); | 418 content::Source<NavigationController>(&(newtab->controller()))); |
| 419 observer.Wait(); | 419 observer.Wait(); |
| 420 } | 420 } |
| 421 | 421 |
| 422 // Popup window should be in the app's process. | 422 // Popup window should be in the app's process. |
| 423 EXPECT_TRUE(process_map->Contains( | 423 EXPECT_TRUE(process_map->Contains( |
| 424 last_active_browser->GetTabContentsAt(0)->render_view_host()->process()-> | 424 last_active_browser->GetTabContentsAt(0)->render_view_host()->process()-> |
| 425 id())); | 425 GetID())); |
| 426 } | 426 } |
| 427 | 427 |
| 428 // Tests that if we have an app process (path1/container.html) with a non-app | 428 // Tests that if we have an app process (path1/container.html) with a non-app |
| 429 // iframe (path3/iframe.html), then opening a link from that iframe to a new | 429 // iframe (path3/iframe.html), then opening a link from that iframe to a new |
| 430 // window to a same-origin non-app URL (path3/empty.html) should keep the window | 430 // window to a same-origin non-app URL (path3/empty.html) should keep the window |
| 431 // in the app process. | 431 // in the app process. |
| 432 // This is in contrast to OpenAppFromIframe, since here the popup will not be | 432 // This is in contrast to OpenAppFromIframe, since here the popup will not be |
| 433 // missing special permissions and should be scriptable from the iframe. | 433 // missing special permissions and should be scriptable from the iframe. |
| 434 // See http://crbug.com/92669 for more details. | 434 // See http://crbug.com/92669 for more details. |
| 435 IN_PROC_BROWSER_TEST_F(AppApiTest, OpenWebPopupFromWebIframe) { | 435 IN_PROC_BROWSER_TEST_F(AppApiTest, OpenWebPopupFromWebIframe) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 450 ASSERT_TRUE(app); | 450 ASSERT_TRUE(app); |
| 451 ui_test_utils::WindowedNotificationObserver observer( | 451 ui_test_utils::WindowedNotificationObserver observer( |
| 452 content::NOTIFICATION_LOAD_STOP, | 452 content::NOTIFICATION_LOAD_STOP, |
| 453 content::NotificationService::AllSources()); | 453 content::NotificationService::AllSources()); |
| 454 ui_test_utils::NavigateToURLWithDisposition( | 454 ui_test_utils::NavigateToURLWithDisposition( |
| 455 browser(), | 455 browser(), |
| 456 base_url.Resolve("path1/container.html"), | 456 base_url.Resolve("path1/container.html"), |
| 457 CURRENT_TAB, | 457 CURRENT_TAB, |
| 458 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION | | 458 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION | |
| 459 ui_test_utils::BROWSER_TEST_WAIT_FOR_BROWSER); | 459 ui_test_utils::BROWSER_TEST_WAIT_FOR_BROWSER); |
| 460 RenderProcessHost* process = | 460 content::RenderProcessHost* process = |
| 461 browser()->GetTabContentsAt(0)->render_view_host()->process(); | 461 browser()->GetTabContentsAt(0)->render_view_host()->process(); |
| 462 EXPECT_TRUE(process_map->Contains(process->id())); | 462 EXPECT_TRUE(process_map->Contains(process->GetID())); |
| 463 | 463 |
| 464 // Wait for popup window to appear. The new Browser may not have been | 464 // Wait for popup window to appear. The new Browser may not have been |
| 465 // added with SetLastActive, in which case we need to show it first. | 465 // added with SetLastActive, in which case we need to show it first. |
| 466 // This is necessary for popup windows without a cross-site transition. | 466 // This is necessary for popup windows without a cross-site transition. |
| 467 if (browser() == BrowserList::GetLastActive()) { | 467 if (browser() == BrowserList::GetLastActive()) { |
| 468 // Grab the second window and show it. | 468 // Grab the second window and show it. |
| 469 ASSERT_TRUE(BrowserList::size() == 2); | 469 ASSERT_TRUE(BrowserList::size() == 2); |
| 470 Browser* popup_browser = *(++BrowserList::begin()); | 470 Browser* popup_browser = *(++BrowserList::begin()); |
| 471 popup_browser->window()->Show(); | 471 popup_browser->window()->Show(); |
| 472 } | 472 } |
| 473 Browser* last_active_browser = BrowserList::GetLastActive(); | 473 Browser* last_active_browser = BrowserList::GetLastActive(); |
| 474 EXPECT_TRUE(last_active_browser); | 474 EXPECT_TRUE(last_active_browser); |
| 475 ASSERT_NE(browser(), last_active_browser); | 475 ASSERT_NE(browser(), last_active_browser); |
| 476 TabContents* newtab = last_active_browser->GetSelectedTabContents(); | 476 TabContents* newtab = last_active_browser->GetSelectedTabContents(); |
| 477 EXPECT_TRUE(newtab); | 477 EXPECT_TRUE(newtab); |
| 478 GURL non_app_url = base_url.Resolve("path3/empty.html"); | 478 GURL non_app_url = base_url.Resolve("path3/empty.html"); |
| 479 observer.Wait(); | 479 observer.Wait(); |
| 480 | 480 |
| 481 // Popup window should be in the app's process. | 481 // Popup window should be in the app's process. |
| 482 RenderProcessHost* popup_process = | 482 content::RenderProcessHost* popup_process = |
| 483 last_active_browser->GetTabContentsAt(0)->render_view_host()->process(); | 483 last_active_browser->GetTabContentsAt(0)->render_view_host()->process(); |
| 484 EXPECT_EQ(process, popup_process); | 484 EXPECT_EQ(process, popup_process); |
| 485 } | 485 } |
| 486 | 486 |
| 487 IN_PROC_BROWSER_TEST_F(AppApiTest, ReloadAppAfterCrash) { | 487 IN_PROC_BROWSER_TEST_F(AppApiTest, ReloadAppAfterCrash) { |
| 488 extensions::ProcessMap* process_map = | 488 extensions::ProcessMap* process_map = |
| 489 browser()->profile()->GetExtensionService()->process_map(); | 489 browser()->profile()->GetExtensionService()->process_map(); |
| 490 | 490 |
| 491 host_resolver()->AddRule("*", "127.0.0.1"); | 491 host_resolver()->AddRule("*", "127.0.0.1"); |
| 492 ASSERT_TRUE(test_server()->Start()); | 492 ASSERT_TRUE(test_server()->Start()); |
| 493 | 493 |
| 494 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app_process"))); | 494 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app_process"))); |
| 495 | 495 |
| 496 GURL base_url = GetTestBaseURL("app_process"); | 496 GURL base_url = GetTestBaseURL("app_process"); |
| 497 | 497 |
| 498 // Load the app, chrome.app.isInstalled should be true. | 498 // Load the app, chrome.app.isInstalled should be true. |
| 499 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html")); | 499 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html")); |
| 500 TabContents* contents = browser()->GetTabContentsAt(0); | 500 TabContents* contents = browser()->GetTabContentsAt(0); |
| 501 EXPECT_TRUE(process_map->Contains( | 501 EXPECT_TRUE(process_map->Contains( |
| 502 contents->render_view_host()->process()->id())); | 502 contents->render_view_host()->process()->GetID())); |
| 503 bool is_installed = false; | 503 bool is_installed = false; |
| 504 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 504 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 505 contents->render_view_host(), L"", | 505 contents->render_view_host(), L"", |
| 506 L"window.domAutomationController.send(chrome.app.isInstalled)", | 506 L"window.domAutomationController.send(chrome.app.isInstalled)", |
| 507 &is_installed)); | 507 &is_installed)); |
| 508 ASSERT_TRUE(is_installed); | 508 ASSERT_TRUE(is_installed); |
| 509 | 509 |
| 510 // Crash the tab and reload it, chrome.app.isInstalled should still be true. | 510 // Crash the tab and reload it, chrome.app.isInstalled should still be true. |
| 511 ui_test_utils::CrashTab(browser()->GetSelectedTabContents()); | 511 ui_test_utils::CrashTab(browser()->GetSelectedTabContents()); |
| 512 ui_test_utils::WindowedNotificationObserver observer( | 512 ui_test_utils::WindowedNotificationObserver observer( |
| 513 content::NOTIFICATION_LOAD_STOP, | 513 content::NOTIFICATION_LOAD_STOP, |
| 514 content::Source<NavigationController>( | 514 content::Source<NavigationController>( |
| 515 &browser()->GetSelectedTabContentsWrapper()->controller())); | 515 &browser()->GetSelectedTabContentsWrapper()->controller())); |
| 516 browser()->Reload(CURRENT_TAB); | 516 browser()->Reload(CURRENT_TAB); |
| 517 observer.Wait(); | 517 observer.Wait(); |
| 518 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 518 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 519 contents->render_view_host(), L"", | 519 contents->render_view_host(), L"", |
| 520 L"window.domAutomationController.send(chrome.app.isInstalled)", | 520 L"window.domAutomationController.send(chrome.app.isInstalled)", |
| 521 &is_installed)); | 521 &is_installed)); |
| 522 ASSERT_TRUE(is_installed); | 522 ASSERT_TRUE(is_installed); |
| 523 } | 523 } |
| OLD | NEW |