OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/extensions/extension_apitest.h" | 5 #include "chrome/browser/extensions/extension_apitest.h" |
6 #include "chrome/browser/extensions/extension_host.h" | 6 #include "chrome/browser/extensions/extension_host.h" |
7 #include "chrome/browser/extensions/extension_service.h" | 7 #include "chrome/browser/extensions/extension_service.h" |
8 #include "chrome/browser/extensions/extension_system.h" | 8 #include "chrome/browser/extensions/extension_system.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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 EXPECT_EQ(tab->GetRenderProcessHost(), | 217 EXPECT_EQ(tab->GetRenderProcessHost(), |
218 chrome::GetWebContentsAt(browser(), 3)->GetRenderProcessHost()); | 218 chrome::GetWebContentsAt(browser(), 3)->GetRenderProcessHost()); |
219 | 219 |
220 // If one of the popup tabs navigates back to the app, window.opener should | 220 // If one of the popup tabs navigates back to the app, window.opener should |
221 // be valid. | 221 // be valid. |
222 NavigateInRenderer(chrome::GetWebContentsAt(browser(), 6), app_url); | 222 NavigateInRenderer(chrome::GetWebContentsAt(browser(), 6), app_url); |
223 LOG(INFO) << "NavigateTabHelper 3."; | 223 LOG(INFO) << "NavigateTabHelper 3."; |
224 EXPECT_EQ(tab->GetRenderProcessHost(), | 224 EXPECT_EQ(tab->GetRenderProcessHost(), |
225 chrome::GetWebContentsAt(browser(), 6)->GetRenderProcessHost()); | 225 chrome::GetWebContentsAt(browser(), 6)->GetRenderProcessHost()); |
226 bool windowOpenerValid = false; | 226 bool windowOpenerValid = false; |
227 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( | 227 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
228 chrome::GetWebContentsAt(browser(), 6)->GetRenderViewHost(), | 228 chrome::GetWebContentsAt(browser(), 6), |
229 "", | |
230 "window.domAutomationController.send(window.opener != null)", | 229 "window.domAutomationController.send(window.opener != null)", |
231 &windowOpenerValid)); | 230 &windowOpenerValid)); |
232 ASSERT_TRUE(windowOpenerValid); | 231 ASSERT_TRUE(windowOpenerValid); |
233 | 232 |
234 LOG(INFO) << "End of test."; | 233 LOG(INFO) << "End of test."; |
235 } | 234 } |
236 | 235 |
237 // Test that hosted apps without the background permission use a process per app | 236 // Test that hosted apps without the background permission use a process per app |
238 // instance model, such that separate instances are in separate processes. | 237 // instance model, such that separate instances are in separate processes. |
239 IN_PROC_BROWSER_TEST_F(AppApiTest, AppProcessInstances) { | 238 IN_PROC_BROWSER_TEST_F(AppApiTest, AppProcessInstances) { |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 reload_observer2.Wait(); | 427 reload_observer2.Wait(); |
429 EXPECT_FALSE(process_map->Contains( | 428 EXPECT_FALSE(process_map->Contains( |
430 contents->GetRenderProcessHost()->GetID())); | 429 contents->GetRenderProcessHost()->GetID())); |
431 | 430 |
432 // Enable app and reload via JavaScript. | 431 // Enable app and reload via JavaScript. |
433 EnableExtension(app->id()); | 432 EnableExtension(app->id()); |
434 content::WindowedNotificationObserver js_reload_observer( | 433 content::WindowedNotificationObserver js_reload_observer( |
435 content::NOTIFICATION_LOAD_STOP, | 434 content::NOTIFICATION_LOAD_STOP, |
436 content::Source<NavigationController>( | 435 content::Source<NavigationController>( |
437 &chrome::GetActiveWebContents(browser())->GetController())); | 436 &chrome::GetActiveWebContents(browser())->GetController())); |
438 ASSERT_TRUE(content::ExecuteJavaScript(contents->GetRenderViewHost(), | 437 ASSERT_TRUE(content::ExecuteScript(contents, "location.reload();")); |
439 "", "location.reload();")); | |
440 js_reload_observer.Wait(); | 438 js_reload_observer.Wait(); |
441 EXPECT_TRUE(process_map->Contains( | 439 EXPECT_TRUE(process_map->Contains( |
442 contents->GetRenderProcessHost()->GetID())); | 440 contents->GetRenderProcessHost()->GetID())); |
443 | 441 |
444 // Disable app and reload via JavaScript. | 442 // Disable app and reload via JavaScript. |
445 DisableExtension(app->id()); | 443 DisableExtension(app->id()); |
446 content::WindowedNotificationObserver js_reload_observer2( | 444 content::WindowedNotificationObserver js_reload_observer2( |
447 content::NOTIFICATION_LOAD_STOP, | 445 content::NOTIFICATION_LOAD_STOP, |
448 content::Source<NavigationController>( | 446 content::Source<NavigationController>( |
449 &chrome::GetActiveWebContents(browser())->GetController())); | 447 &chrome::GetActiveWebContents(browser())->GetController())); |
450 ASSERT_TRUE(content::ExecuteJavaScript(contents->GetRenderViewHost(), | 448 ASSERT_TRUE(content::ExecuteScript(contents, "location = location;")); |
451 "", "location = location;")); | |
452 js_reload_observer2.Wait(); | 449 js_reload_observer2.Wait(); |
453 EXPECT_FALSE(process_map->Contains( | 450 EXPECT_FALSE(process_map->Contains( |
454 contents->GetRenderProcessHost()->GetID())); | 451 contents->GetRenderProcessHost()->GetID())); |
455 } | 452 } |
456 | 453 |
457 // Tests that if we have a non-app process (path3/container.html) that has an | 454 // Tests that if we have a non-app process (path3/container.html) that has an |
458 // iframe with a URL in the app's extent (path1/iframe.html), then opening a | 455 // iframe with a URL in the app's extent (path1/iframe.html), then opening a |
459 // link from that iframe to a new window to a URL in the app's extent (path1/ | 456 // link from that iframe to a new window to a URL in the app's extent (path1/ |
460 // empty.html) results in the new window being in an app process. See | 457 // empty.html) results in the new window being in an app process. See |
461 // http://crbug.com/89272 for more details. | 458 // http://crbug.com/89272 for more details. |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 546 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
550 | 547 |
551 // Wait for app tab to be created and loaded. | 548 // Wait for app tab to be created and loaded. |
552 test_navigation_observer.WaitForObservation( | 549 test_navigation_observer.WaitForObservation( |
553 base::Bind(&content::RunMessageLoop), | 550 base::Bind(&content::RunMessageLoop), |
554 base::Bind(&MessageLoop::Quit, | 551 base::Bind(&MessageLoop::Quit, |
555 base::Unretained(MessageLoopForUI::current()))); | 552 base::Unretained(MessageLoopForUI::current()))); |
556 | 553 |
557 // App has loaded, and chrome.app.isInstalled should be true. | 554 // App has loaded, and chrome.app.isInstalled should be true. |
558 bool is_installed = false; | 555 bool is_installed = false; |
559 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( | 556 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
560 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), | 557 chrome::GetActiveWebContents(browser()), |
561 "", | |
562 "window.domAutomationController.send(chrome.app.isInstalled)", | 558 "window.domAutomationController.send(chrome.app.isInstalled)", |
563 &is_installed)); | 559 &is_installed)); |
564 ASSERT_TRUE(is_installed); | 560 ASSERT_TRUE(is_installed); |
565 } | 561 } |
566 | 562 |
567 // Tests that if we have an app process (path1/container.html) with a non-app | 563 // Tests that if we have an app process (path1/container.html) with a non-app |
568 // iframe (path3/iframe.html), then opening a link from that iframe to a new | 564 // iframe (path3/iframe.html), then opening a link from that iframe to a new |
569 // window to a same-origin non-app URL (path3/empty.html) should keep the window | 565 // window to a same-origin non-app URL (path3/empty.html) should keep the window |
570 // in the app process. | 566 // in the app process. |
571 // This is in contrast to OpenAppFromIframe, since here the popup will not be | 567 // This is in contrast to OpenAppFromIframe, since here the popup will not be |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app_process"))); | 615 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app_process"))); |
620 | 616 |
621 GURL base_url = GetTestBaseURL("app_process"); | 617 GURL base_url = GetTestBaseURL("app_process"); |
622 | 618 |
623 // Load the app, chrome.app.isInstalled should be true. | 619 // Load the app, chrome.app.isInstalled should be true. |
624 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html")); | 620 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html")); |
625 WebContents* contents = chrome::GetWebContentsAt(browser(), 0); | 621 WebContents* contents = chrome::GetWebContentsAt(browser(), 0); |
626 EXPECT_TRUE(process_map->Contains( | 622 EXPECT_TRUE(process_map->Contains( |
627 contents->GetRenderProcessHost()->GetID())); | 623 contents->GetRenderProcessHost()->GetID())); |
628 bool is_installed = false; | 624 bool is_installed = false; |
629 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( | 625 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
630 contents->GetRenderViewHost(), | 626 contents, |
631 "", | |
632 "window.domAutomationController.send(chrome.app.isInstalled)", | 627 "window.domAutomationController.send(chrome.app.isInstalled)", |
633 &is_installed)); | 628 &is_installed)); |
634 ASSERT_TRUE(is_installed); | 629 ASSERT_TRUE(is_installed); |
635 | 630 |
636 // Crash the tab and reload it, chrome.app.isInstalled should still be true. | 631 // Crash the tab and reload it, chrome.app.isInstalled should still be true. |
637 content::CrashTab(chrome::GetActiveWebContents(browser())); | 632 content::CrashTab(chrome::GetActiveWebContents(browser())); |
638 content::WindowedNotificationObserver observer( | 633 content::WindowedNotificationObserver observer( |
639 content::NOTIFICATION_LOAD_STOP, | 634 content::NOTIFICATION_LOAD_STOP, |
640 content::Source<NavigationController>( | 635 content::Source<NavigationController>( |
641 &chrome::GetActiveWebContents(browser())->GetController())); | 636 &chrome::GetActiveWebContents(browser())->GetController())); |
642 chrome::Reload(browser(), CURRENT_TAB); | 637 chrome::Reload(browser(), CURRENT_TAB); |
643 observer.Wait(); | 638 observer.Wait(); |
644 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( | 639 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
645 contents->GetRenderViewHost(), | 640 contents, |
646 "", | |
647 "window.domAutomationController.send(chrome.app.isInstalled)", | 641 "window.domAutomationController.send(chrome.app.isInstalled)", |
648 &is_installed)); | 642 &is_installed)); |
649 ASSERT_TRUE(is_installed); | 643 ASSERT_TRUE(is_installed); |
650 } | 644 } |
OLD | NEW |