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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 // tab, we now have 3 tabs. The two app tabs should not be in the same | 114 // tab, we now have 3 tabs. The two app tabs should not be in the same |
115 // process, since they do not have the background permission. (Thus, we | 115 // process, since they do not have the background permission. (Thus, we |
116 // want to separate them to improve responsiveness.) | 116 // want to separate them to improve responsiveness.) |
117 ASSERT_EQ(3, browser()->tab_strip_model()->count()); | 117 ASSERT_EQ(3, browser()->tab_strip_model()->count()); |
118 WebContents* tab1 = browser()->tab_strip_model()->GetWebContentsAt(1); | 118 WebContents* tab1 = browser()->tab_strip_model()->GetWebContentsAt(1); |
119 WebContents* tab2 = browser()->tab_strip_model()->GetWebContentsAt(2); | 119 WebContents* tab2 = browser()->tab_strip_model()->GetWebContentsAt(2); |
120 EXPECT_NE(tab1->GetRenderProcessHost(), tab2->GetRenderProcessHost()); | 120 EXPECT_NE(tab1->GetRenderProcessHost(), tab2->GetRenderProcessHost()); |
121 | 121 |
122 // Opening tabs with window.open should keep the page in the opener's | 122 // Opening tabs with window.open should keep the page in the opener's |
123 // process. | 123 // process. |
124 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile(), | 124 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile())); |
125 browser()->host_desktop_type())); | |
126 OpenWindow(tab1, base_url.Resolve("path1/empty.html"), true, NULL); | 125 OpenWindow(tab1, base_url.Resolve("path1/empty.html"), true, NULL); |
127 LOG(INFO) << "WindowOpenHelper 1."; | 126 LOG(INFO) << "WindowOpenHelper 1."; |
128 OpenWindow(tab2, base_url.Resolve("path2/empty.html"), true, NULL); | 127 OpenWindow(tab2, base_url.Resolve("path2/empty.html"), true, NULL); |
129 LOG(INFO) << "End of test."; | 128 LOG(INFO) << "End of test."; |
130 UnloadExtension(extension->id()); | 129 UnloadExtension(extension->id()); |
131 } | 130 } |
132 }; | 131 }; |
133 | 132 |
134 // Omits the disable-popup-blocking flag so we can cover that case. | 133 // Omits the disable-popup-blocking flag so we can cover that case. |
135 class BlockedAppApiTest : public AppApiTest { | 134 class BlockedAppApiTest : public AppApiTest { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 WebContents* tab = browser()->tab_strip_model()->GetWebContentsAt(1); | 201 WebContents* tab = browser()->tab_strip_model()->GetWebContentsAt(1); |
203 | 202 |
204 EXPECT_EQ(tab->GetRenderProcessHost(), | 203 EXPECT_EQ(tab->GetRenderProcessHost(), |
205 browser()->tab_strip_model()->GetWebContentsAt(2)-> | 204 browser()->tab_strip_model()->GetWebContentsAt(2)-> |
206 GetRenderProcessHost()); | 205 GetRenderProcessHost()); |
207 EXPECT_NE(tab->GetRenderProcessHost(), | 206 EXPECT_NE(tab->GetRenderProcessHost(), |
208 browser()->tab_strip_model()->GetWebContentsAt(3)-> | 207 browser()->tab_strip_model()->GetWebContentsAt(3)-> |
209 GetRenderProcessHost()); | 208 GetRenderProcessHost()); |
210 | 209 |
211 // Now let's do the same using window.open. The same should happen. | 210 // Now let's do the same using window.open. The same should happen. |
212 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile(), | 211 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile())); |
213 browser()->host_desktop_type())); | |
214 OpenWindow(tab, base_url.Resolve("path1/empty.html"), true, NULL); | 212 OpenWindow(tab, base_url.Resolve("path1/empty.html"), true, NULL); |
215 LOG(INFO) << "WindowOpenHelper 1."; | 213 LOG(INFO) << "WindowOpenHelper 1."; |
216 OpenWindow(tab, base_url.Resolve("path2/empty.html"), true, NULL); | 214 OpenWindow(tab, base_url.Resolve("path2/empty.html"), true, NULL); |
217 LOG(INFO) << "WindowOpenHelper 2."; | 215 LOG(INFO) << "WindowOpenHelper 2."; |
218 // TODO(creis): This should open in a new process (i.e., false for the last | 216 // TODO(creis): This should open in a new process (i.e., false for the last |
219 // argument), but we temporarily avoid swapping processes away from a hosted | 217 // argument), but we temporarily avoid swapping processes away from a hosted |
220 // app if it has an opener, because some OAuth providers make script calls | 218 // app if it has an opener, because some OAuth providers make script calls |
221 // between non-app popups and non-app iframes in the app process. | 219 // between non-app popups and non-app iframes in the app process. |
222 // See crbug.com/59285. | 220 // See crbug.com/59285. |
223 OpenWindow(tab, base_url.Resolve("path3/empty.html"), true, NULL); | 221 OpenWindow(tab, base_url.Resolve("path3/empty.html"), true, NULL); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 // We should have opened 2 new bookmark app tabs. Including the original blank | 338 // We should have opened 2 new bookmark app tabs. Including the original blank |
341 // tab, we now have 3 tabs. Because normal pages use the | 339 // tab, we now have 3 tabs. Because normal pages use the |
342 // process-per-site-instance model, each should be in its own process. | 340 // process-per-site-instance model, each should be in its own process. |
343 ASSERT_EQ(3, browser()->tab_strip_model()->count()); | 341 ASSERT_EQ(3, browser()->tab_strip_model()->count()); |
344 WebContents* tab = browser()->tab_strip_model()->GetWebContentsAt(1); | 342 WebContents* tab = browser()->tab_strip_model()->GetWebContentsAt(1); |
345 EXPECT_NE(tab->GetRenderProcessHost(), | 343 EXPECT_NE(tab->GetRenderProcessHost(), |
346 browser()->tab_strip_model()->GetWebContentsAt(2)-> | 344 browser()->tab_strip_model()->GetWebContentsAt(2)-> |
347 GetRenderProcessHost()); | 345 GetRenderProcessHost()); |
348 | 346 |
349 // Now let's do the same using window.open. The same should happen. | 347 // Now let's do the same using window.open. The same should happen. |
350 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile(), | 348 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile())); |
351 browser()->host_desktop_type())); | |
352 OpenWindow(tab, base_url.Resolve("path1/empty.html"), true, NULL); | 349 OpenWindow(tab, base_url.Resolve("path1/empty.html"), true, NULL); |
353 OpenWindow(tab, base_url.Resolve("path2/empty.html"), true, NULL); | 350 OpenWindow(tab, base_url.Resolve("path2/empty.html"), true, NULL); |
354 | 351 |
355 // Now let's have a tab navigate out of and back into the app's web | 352 // Now let's have a tab navigate out of and back into the app's web |
356 // extent. Neither navigation should switch processes. | 353 // extent. Neither navigation should switch processes. |
357 const GURL& app_url(base_url.Resolve("path1/empty.html")); | 354 const GURL& app_url(base_url.Resolve("path1/empty.html")); |
358 const GURL& non_app_url(base_url.Resolve("path3/empty.html")); | 355 const GURL& non_app_url(base_url.Resolve("path3/empty.html")); |
359 RenderViewHost* host2 = | 356 RenderViewHost* host2 = |
360 browser()->tab_strip_model()->GetWebContentsAt(2)->GetRenderViewHost(); | 357 browser()->tab_strip_model()->GetWebContentsAt(2)->GetRenderViewHost(); |
361 NavigateInRenderer(browser()->tab_strip_model()->GetWebContentsAt(2), | 358 NavigateInRenderer(browser()->tab_strip_model()->GetWebContentsAt(2), |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 // Navigate the popup to another process outside the app. | 860 // Navigate the popup to another process outside the app. |
864 GURL non_app_url(base_url.Resolve("path3/empty.html")); | 861 GURL non_app_url(base_url.Resolve("path3/empty.html")); |
865 ui_test_utils::NavigateToURL(active_browser_list->get(1), non_app_url); | 862 ui_test_utils::NavigateToURL(active_browser_list->get(1), non_app_url); |
866 SiteInstance* new_instance = popup_contents->GetSiteInstance(); | 863 SiteInstance* new_instance = popup_contents->GetSiteInstance(); |
867 EXPECT_NE(app_instance, new_instance); | 864 EXPECT_NE(app_instance, new_instance); |
868 | 865 |
869 // It should still be in the same BrowsingInstance, allowing postMessage to | 866 // It should still be in the same BrowsingInstance, allowing postMessage to |
870 // work. | 867 // work. |
871 EXPECT_TRUE(app_instance->IsRelatedSiteInstance(new_instance)); | 868 EXPECT_TRUE(app_instance->IsRelatedSiteInstance(new_instance)); |
872 } | 869 } |
OLD | NEW |