| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "build/build_config.h" | 6 #include "build/build_config.h" |
| 7 #include "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
| 8 #include "chrome/browser/extensions/extension_apitest.h" | 8 #include "chrome/browser/extensions/extension_apitest.h" |
| 9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 const Extension* app = | 616 const Extension* app = |
| 617 LoadExtension(test_data_dir_.AppendASCII("app_process")); | 617 LoadExtension(test_data_dir_.AppendASCII("app_process")); |
| 618 ASSERT_TRUE(app); | 618 ASSERT_TRUE(app); |
| 619 | 619 |
| 620 ui_test_utils::NavigateToURL(browser(), | 620 ui_test_utils::NavigateToURL(browser(), |
| 621 base_url.Resolve("path3/container.html")); | 621 base_url.Resolve("path3/container.html")); |
| 622 EXPECT_FALSE(process_map->Contains( | 622 EXPECT_FALSE(process_map->Contains( |
| 623 browser()->tab_strip_model()->GetWebContentsAt(0)-> | 623 browser()->tab_strip_model()->GetWebContentsAt(0)-> |
| 624 GetRenderProcessHost()->GetID())); | 624 GetRenderProcessHost()->GetID())); |
| 625 | 625 |
| 626 const BrowserList* active_browser_list = | 626 const BrowserList* active_browser_list = BrowserList::GetInstance(); |
| 627 BrowserList::GetInstance(chrome::GetActiveDesktop()); | |
| 628 EXPECT_EQ(2U, active_browser_list->size()); | 627 EXPECT_EQ(2U, active_browser_list->size()); |
| 629 content::WebContents* popup_contents = | 628 content::WebContents* popup_contents = |
| 630 active_browser_list->get(1)->tab_strip_model()->GetActiveWebContents(); | 629 active_browser_list->get(1)->tab_strip_model()->GetActiveWebContents(); |
| 631 content::WaitForLoadStop(popup_contents); | 630 content::WaitForLoadStop(popup_contents); |
| 632 | 631 |
| 633 // Popup window should be in the app's process. | 632 // Popup window should be in the app's process. |
| 634 RenderViewHost* popup_host = popup_contents->GetRenderViewHost(); | 633 RenderViewHost* popup_host = popup_contents->GetRenderViewHost(); |
| 635 EXPECT_TRUE(process_map->Contains(popup_host->GetProcess()->GetID())); | 634 EXPECT_TRUE(process_map->Contains(popup_host->GetProcess()->GetID())); |
| 636 } | 635 } |
| 637 | 636 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 ASSERT_TRUE(app); | 761 ASSERT_TRUE(app); |
| 763 | 762 |
| 764 ui_test_utils::NavigateToURL(browser(), | 763 ui_test_utils::NavigateToURL(browser(), |
| 765 base_url.Resolve("path1/container.html")); | 764 base_url.Resolve("path1/container.html")); |
| 766 content::RenderProcessHost* process = | 765 content::RenderProcessHost* process = |
| 767 browser()->tab_strip_model()->GetWebContentsAt(0)->GetRenderProcessHost(); | 766 browser()->tab_strip_model()->GetWebContentsAt(0)->GetRenderProcessHost(); |
| 768 EXPECT_TRUE(process_map->Contains(process->GetID())); | 767 EXPECT_TRUE(process_map->Contains(process->GetID())); |
| 769 | 768 |
| 770 // Popup window should be in the app's process if site isolation is off; | 769 // Popup window should be in the app's process if site isolation is off; |
| 771 // otherwise they should be in different processes. | 770 // otherwise they should be in different processes. |
| 772 const BrowserList* active_browser_list = | 771 const BrowserList* active_browser_list = BrowserList::GetInstance(); |
| 773 BrowserList::GetInstance(chrome::GetActiveDesktop()); | |
| 774 EXPECT_EQ(2U, active_browser_list->size()); | 772 EXPECT_EQ(2U, active_browser_list->size()); |
| 775 content::WebContents* popup_contents = | 773 content::WebContents* popup_contents = |
| 776 active_browser_list->get(1)->tab_strip_model()->GetActiveWebContents(); | 774 active_browser_list->get(1)->tab_strip_model()->GetActiveWebContents(); |
| 777 content::WaitForLoadStop(popup_contents); | 775 content::WaitForLoadStop(popup_contents); |
| 778 | 776 |
| 779 bool should_be_in_same_process = !content::AreAllSitesIsolatedForTesting(); | 777 bool should_be_in_same_process = !content::AreAllSitesIsolatedForTesting(); |
| 780 content::RenderProcessHost* popup_process = | 778 content::RenderProcessHost* popup_process = |
| 781 popup_contents->GetRenderProcessHost(); | 779 popup_contents->GetRenderProcessHost(); |
| 782 EXPECT_EQ(should_be_in_same_process, process == popup_process); | 780 EXPECT_EQ(should_be_in_same_process, process == popup_process); |
| 783 EXPECT_EQ(should_be_in_same_process, | 781 EXPECT_EQ(should_be_in_same_process, |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 LoadExtension(test_data_dir_.AppendASCII("app_process")); | 844 LoadExtension(test_data_dir_.AppendASCII("app_process")); |
| 847 ASSERT_TRUE(app); | 845 ASSERT_TRUE(app); |
| 848 | 846 |
| 849 ui_test_utils::NavigateToURL(browser(), | 847 ui_test_utils::NavigateToURL(browser(), |
| 850 base_url.Resolve("path1/iframe.html")); | 848 base_url.Resolve("path1/iframe.html")); |
| 851 content::SiteInstance* app_instance = | 849 content::SiteInstance* app_instance = |
| 852 browser()->tab_strip_model()->GetWebContentsAt(0)->GetSiteInstance(); | 850 browser()->tab_strip_model()->GetWebContentsAt(0)->GetSiteInstance(); |
| 853 EXPECT_TRUE(process_map->Contains(app_instance->GetProcess()->GetID())); | 851 EXPECT_TRUE(process_map->Contains(app_instance->GetProcess()->GetID())); |
| 854 | 852 |
| 855 // Popup window should be in the app's process. | 853 // Popup window should be in the app's process. |
| 856 const BrowserList* active_browser_list = | 854 const BrowserList* active_browser_list = BrowserList::GetInstance(); |
| 857 BrowserList::GetInstance(chrome::GetActiveDesktop()); | |
| 858 EXPECT_EQ(2U, active_browser_list->size()); | 855 EXPECT_EQ(2U, active_browser_list->size()); |
| 859 content::WebContents* popup_contents = | 856 content::WebContents* popup_contents = |
| 860 active_browser_list->get(1)->tab_strip_model()->GetActiveWebContents(); | 857 active_browser_list->get(1)->tab_strip_model()->GetActiveWebContents(); |
| 861 content::WaitForLoadStop(popup_contents); | 858 content::WaitForLoadStop(popup_contents); |
| 862 | 859 |
| 863 SiteInstance* popup_instance = popup_contents->GetSiteInstance(); | 860 SiteInstance* popup_instance = popup_contents->GetSiteInstance(); |
| 864 EXPECT_EQ(app_instance, popup_instance); | 861 EXPECT_EQ(app_instance, popup_instance); |
| 865 | 862 |
| 866 // Navigate the popup to another process outside the app. | 863 // Navigate the popup to another process outside the app. |
| 867 GURL non_app_url(base_url.Resolve("path3/empty.html")); | 864 GURL non_app_url(base_url.Resolve("path3/empty.html")); |
| 868 ui_test_utils::NavigateToURL(active_browser_list->get(1), non_app_url); | 865 ui_test_utils::NavigateToURL(active_browser_list->get(1), non_app_url); |
| 869 SiteInstance* new_instance = popup_contents->GetSiteInstance(); | 866 SiteInstance* new_instance = popup_contents->GetSiteInstance(); |
| 870 EXPECT_NE(app_instance, new_instance); | 867 EXPECT_NE(app_instance, new_instance); |
| 871 | 868 |
| 872 // It should still be in the same BrowsingInstance, allowing postMessage to | 869 // It should still be in the same BrowsingInstance, allowing postMessage to |
| 873 // work. | 870 // work. |
| 874 EXPECT_TRUE(app_instance->IsRelatedSiteInstance(new_instance)); | 871 EXPECT_TRUE(app_instance->IsRelatedSiteInstance(new_instance)); |
| 875 } | 872 } |
| OLD | NEW |