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/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" |
11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 12 #include "chrome/browser/ui/browser_finder.h" |
12 #include "chrome/browser/ui/browser_list.h" | 13 #include "chrome/browser/ui/browser_list.h" |
13 #include "chrome/browser/ui/browser_window.h" | 14 #include "chrome/browser/ui/browser_window.h" |
14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 15 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
15 #include "chrome/common/chrome_notification_types.h" | 16 #include "chrome/common/chrome_notification_types.h" |
16 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
17 #include "chrome/common/extensions/extension.h" | 18 #include "chrome/common/extensions/extension.h" |
18 #include "chrome/common/extensions/extension_file_util.h" | 19 #include "chrome/common/extensions/extension_file_util.h" |
19 #include "chrome/common/string_ordinal.h" | 20 #include "chrome/common/string_ordinal.h" |
20 #include "chrome/test/base/ui_test_utils.h" | 21 #include "chrome/test/base/ui_test_utils.h" |
21 #include "content/public/browser/navigation_entry.h" | 22 #include "content/public/browser/navigation_entry.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 // tab, we now have 3 tabs. The two app tabs should not be in the same | 144 // tab, we now have 3 tabs. The two app tabs should not be in the same |
144 // process, since they do not have the background permission. (Thus, we | 145 // process, since they do not have the background permission. (Thus, we |
145 // want to separate them to improve responsiveness.) | 146 // want to separate them to improve responsiveness.) |
146 ASSERT_EQ(3, browser()->tab_count()); | 147 ASSERT_EQ(3, browser()->tab_count()); |
147 RenderViewHost* host1 = browser()->GetWebContentsAt(1)->GetRenderViewHost(); | 148 RenderViewHost* host1 = browser()->GetWebContentsAt(1)->GetRenderViewHost(); |
148 RenderViewHost* host2 = browser()->GetWebContentsAt(2)->GetRenderViewHost(); | 149 RenderViewHost* host2 = browser()->GetWebContentsAt(2)->GetRenderViewHost(); |
149 EXPECT_NE(host1->GetProcess(), host2->GetProcess()); | 150 EXPECT_NE(host1->GetProcess(), host2->GetProcess()); |
150 | 151 |
151 // Opening tabs with window.open should keep the page in the opener's | 152 // Opening tabs with window.open should keep the page in the opener's |
152 // process. | 153 // process. |
153 ASSERT_EQ(1u, BrowserList::GetBrowserCount(browser()->profile())); | 154 ASSERT_EQ(1u, browser::GetBrowserCount(browser()->profile())); |
154 WindowOpenHelper(browser(), host1, | 155 WindowOpenHelper(browser(), host1, |
155 base_url.Resolve("path1/empty.html"), true); | 156 base_url.Resolve("path1/empty.html"), true); |
156 LOG(INFO) << "WindowOpenHelper 1."; | 157 LOG(INFO) << "WindowOpenHelper 1."; |
157 WindowOpenHelper(browser(), host2, | 158 WindowOpenHelper(browser(), host2, |
158 base_url.Resolve("path2/empty.html"), true); | 159 base_url.Resolve("path2/empty.html"), true); |
159 LOG(INFO) << "End of test."; | 160 LOG(INFO) << "End of test."; |
160 } | 161 } |
161 }; | 162 }; |
162 | 163 |
163 // Tests that hosted apps with the background permission get a process-per-app | 164 // Tests that hosted apps with the background permission get a process-per-app |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 // should be part of the extension app and grouped in the same process. | 216 // should be part of the extension app and grouped in the same process. |
216 ASSERT_EQ(4, browser()->tab_count()); | 217 ASSERT_EQ(4, browser()->tab_count()); |
217 RenderViewHost* host = browser()->GetWebContentsAt(1)->GetRenderViewHost(); | 218 RenderViewHost* host = browser()->GetWebContentsAt(1)->GetRenderViewHost(); |
218 | 219 |
219 EXPECT_EQ(host->GetProcess(), | 220 EXPECT_EQ(host->GetProcess(), |
220 browser()->GetWebContentsAt(2)->GetRenderProcessHost()); | 221 browser()->GetWebContentsAt(2)->GetRenderProcessHost()); |
221 EXPECT_NE(host->GetProcess(), | 222 EXPECT_NE(host->GetProcess(), |
222 browser()->GetWebContentsAt(3)->GetRenderProcessHost()); | 223 browser()->GetWebContentsAt(3)->GetRenderProcessHost()); |
223 | 224 |
224 // Now let's do the same using window.open. The same should happen. | 225 // Now let's do the same using window.open. The same should happen. |
225 ASSERT_EQ(1u, BrowserList::GetBrowserCount(browser()->profile())); | 226 ASSERT_EQ(1u, browser::GetBrowserCount(browser()->profile())); |
226 WindowOpenHelper(browser(), host, | 227 WindowOpenHelper(browser(), host, |
227 base_url.Resolve("path1/empty.html"), true); | 228 base_url.Resolve("path1/empty.html"), true); |
228 LOG(INFO) << "WindowOpenHelper 1."; | 229 LOG(INFO) << "WindowOpenHelper 1."; |
229 WindowOpenHelper(browser(), host, | 230 WindowOpenHelper(browser(), host, |
230 base_url.Resolve("path2/empty.html"), true); | 231 base_url.Resolve("path2/empty.html"), true); |
231 LOG(INFO) << "WindowOpenHelper 2."; | 232 LOG(INFO) << "WindowOpenHelper 2."; |
232 // TODO(creis): This should open in a new process (i.e., false for the last | 233 // TODO(creis): This should open in a new process (i.e., false for the last |
233 // argument), but we temporarily avoid swapping processes away from an app | 234 // argument), but we temporarily avoid swapping processes away from an app |
234 // until we're able to support cross-process postMessage calls. | 235 // until we're able to support cross-process postMessage calls. |
235 // See crbug.com/59285. | 236 // See crbug.com/59285. |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 | 327 |
327 // We should have opened 2 new bookmark app tabs. Including the original blank | 328 // We should have opened 2 new bookmark app tabs. Including the original blank |
328 // tab, we now have 3 tabs. Because normal pages use the | 329 // tab, we now have 3 tabs. Because normal pages use the |
329 // process-per-site-instance model, each should be in its own process. | 330 // process-per-site-instance model, each should be in its own process. |
330 ASSERT_EQ(3, browser()->tab_count()); | 331 ASSERT_EQ(3, browser()->tab_count()); |
331 RenderViewHost* host = browser()->GetWebContentsAt(1)->GetRenderViewHost(); | 332 RenderViewHost* host = browser()->GetWebContentsAt(1)->GetRenderViewHost(); |
332 EXPECT_NE(host->GetProcess(), | 333 EXPECT_NE(host->GetProcess(), |
333 browser()->GetWebContentsAt(2)->GetRenderProcessHost()); | 334 browser()->GetWebContentsAt(2)->GetRenderProcessHost()); |
334 | 335 |
335 // Now let's do the same using window.open. The same should happen. | 336 // Now let's do the same using window.open. The same should happen. |
336 ASSERT_EQ(1u, BrowserList::GetBrowserCount(browser()->profile())); | 337 ASSERT_EQ(1u, browser::GetBrowserCount(browser()->profile())); |
337 WindowOpenHelper(browser(), host, | 338 WindowOpenHelper(browser(), host, |
338 base_url.Resolve("path1/empty.html"), true); | 339 base_url.Resolve("path1/empty.html"), true); |
339 WindowOpenHelper(browser(), host, | 340 WindowOpenHelper(browser(), host, |
340 base_url.Resolve("path2/empty.html"), true); | 341 base_url.Resolve("path2/empty.html"), true); |
341 | 342 |
342 // Now let's have a tab navigate out of and back into the app's web | 343 // Now let's have a tab navigate out of and back into the app's web |
343 // extent. Neither navigation should switch processes. | 344 // extent. Neither navigation should switch processes. |
344 const GURL& app_url(base_url.Resolve("path1/empty.html")); | 345 const GURL& app_url(base_url.Resolve("path1/empty.html")); |
345 const GURL& non_app_url(base_url.Resolve("path3/empty.html")); | 346 const GURL& non_app_url(base_url.Resolve("path3/empty.html")); |
346 RenderViewHost* host2 = browser()->GetWebContentsAt(2)->GetRenderViewHost(); | 347 RenderViewHost* host2 = browser()->GetWebContentsAt(2)->GetRenderViewHost(); |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 &browser()->GetSelectedTabContentsWrapper()->web_contents()-> | 680 &browser()->GetSelectedTabContentsWrapper()->web_contents()-> |
680 GetController())); | 681 GetController())); |
681 browser()->Reload(CURRENT_TAB); | 682 browser()->Reload(CURRENT_TAB); |
682 observer.Wait(); | 683 observer.Wait(); |
683 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 684 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
684 contents->GetRenderViewHost(), L"", | 685 contents->GetRenderViewHost(), L"", |
685 L"window.domAutomationController.send(chrome.app.isInstalled)", | 686 L"window.domAutomationController.send(chrome.app.isInstalled)", |
686 &is_installed)); | 687 &is_installed)); |
687 ASSERT_TRUE(is_installed); | 688 ASSERT_TRUE(is_installed); |
688 } | 689 } |
OLD | NEW |