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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 GURL base_url = GetTestBaseURL("app_process"); | 102 GURL base_url = GetTestBaseURL("app_process"); |
103 | 103 |
104 // Test both opening a URL in a new tab, and opening a tab and then navigating | 104 // Test both opening a URL in a new tab, and opening a tab and then navigating |
105 // it. Either way, app tabs should be considered extension processes, but | 105 // it. Either way, app tabs should be considered extension processes, but |
106 // they have no elevated privileges and thus should not have WebUI bindings. | 106 // they have no elevated privileges and thus should not have WebUI bindings. |
107 ui_test_utils::NavigateToURLWithDisposition( | 107 ui_test_utils::NavigateToURLWithDisposition( |
108 browser(), base_url.Resolve("path1/empty.html"), NEW_FOREGROUND_TAB, | 108 browser(), base_url.Resolve("path1/empty.html"), NEW_FOREGROUND_TAB, |
109 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 109 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
110 EXPECT_TRUE(process_map->Contains( | 110 EXPECT_TRUE(process_map->Contains( |
111 browser()->GetTabContentsAt(1)->GetRenderProcessHost()->GetID())); | 111 browser()->GetTabContentsAt(1)->GetRenderProcessHost()->GetID())); |
112 EXPECT_FALSE(browser()->GetTabContentsAt(1)->web_ui()); | 112 EXPECT_FALSE(browser()->GetTabContentsAt(1)->GetWebUI()); |
113 LOG(INFO) << "Nav 1."; | 113 LOG(INFO) << "Nav 1."; |
114 | 114 |
115 ui_test_utils::NavigateToURLWithDisposition( | 115 ui_test_utils::NavigateToURLWithDisposition( |
116 browser(), base_url.Resolve("path2/empty.html"), NEW_FOREGROUND_TAB, | 116 browser(), base_url.Resolve("path2/empty.html"), NEW_FOREGROUND_TAB, |
117 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 117 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
118 EXPECT_TRUE(process_map->Contains( | 118 EXPECT_TRUE(process_map->Contains( |
119 browser()->GetTabContentsAt(2)->GetRenderProcessHost()->GetID())); | 119 browser()->GetTabContentsAt(2)->GetRenderProcessHost()->GetID())); |
120 EXPECT_FALSE(browser()->GetTabContentsAt(2)->web_ui()); | 120 EXPECT_FALSE(browser()->GetTabContentsAt(2)->GetWebUI()); |
121 LOG(INFO) << "Nav 2."; | 121 LOG(INFO) << "Nav 2."; |
122 | 122 |
123 ui_test_utils::WindowedNotificationObserver tab_added_observer( | 123 ui_test_utils::WindowedNotificationObserver tab_added_observer( |
124 content::NOTIFICATION_TAB_ADDED, | 124 content::NOTIFICATION_TAB_ADDED, |
125 content::NotificationService::AllSources()); | 125 content::NotificationService::AllSources()); |
126 browser()->NewTab(); | 126 browser()->NewTab(); |
127 tab_added_observer.Wait(); | 127 tab_added_observer.Wait(); |
128 LOG(INFO) << "New tab."; | 128 LOG(INFO) << "New tab."; |
129 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path3/empty.html")); | 129 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path3/empty.html")); |
130 LOG(INFO) << "Nav 3."; | 130 LOG(INFO) << "Nav 3."; |
131 EXPECT_FALSE(process_map->Contains( | 131 EXPECT_FALSE(process_map->Contains( |
132 browser()->GetTabContentsAt(3)->GetRenderProcessHost()->GetID())); | 132 browser()->GetTabContentsAt(3)->GetRenderProcessHost()->GetID())); |
133 EXPECT_FALSE(browser()->GetTabContentsAt(3)->web_ui()); | 133 EXPECT_FALSE(browser()->GetTabContentsAt(3)->GetWebUI()); |
134 | 134 |
135 // We should have opened 3 new extension tabs. Including the original blank | 135 // We should have opened 3 new extension tabs. Including the original blank |
136 // tab, we now have 4 tabs. Because the app_process app has the background | 136 // tab, we now have 4 tabs. Because the app_process app has the background |
137 // permission, all of its instances are in the same process. Thus two tabs | 137 // permission, all of its instances are in the same process. Thus two tabs |
138 // should be part of the extension app and grouped in the same process. | 138 // should be part of the extension app and grouped in the same process. |
139 ASSERT_EQ(4, browser()->tab_count()); | 139 ASSERT_EQ(4, browser()->tab_count()); |
140 RenderViewHost* host = browser()->GetTabContentsAt(1)->GetRenderViewHost(); | 140 RenderViewHost* host = browser()->GetTabContentsAt(1)->GetRenderViewHost(); |
141 | 141 |
142 EXPECT_EQ(host->process(), | 142 EXPECT_EQ(host->process(), |
143 browser()->GetTabContentsAt(2)->GetRenderProcessHost()); | 143 browser()->GetTabContentsAt(2)->GetRenderProcessHost()); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 | 214 |
215 // Test both opening a URL in a new tab, and opening a tab and then navigating | 215 // Test both opening a URL in a new tab, and opening a tab and then navigating |
216 // it. Either way, app tabs should be considered extension processes, but | 216 // it. Either way, app tabs should be considered extension processes, but |
217 // they have no elevated privileges and thus should not have WebUI bindings. | 217 // they have no elevated privileges and thus should not have WebUI bindings. |
218 ui_test_utils::NavigateToURLWithDisposition( | 218 ui_test_utils::NavigateToURLWithDisposition( |
219 browser(), base_url.Resolve("path1/empty.html"), NEW_FOREGROUND_TAB, | 219 browser(), base_url.Resolve("path1/empty.html"), NEW_FOREGROUND_TAB, |
220 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 220 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
221 LOG(INFO) << "Nav 1."; | 221 LOG(INFO) << "Nav 1."; |
222 EXPECT_TRUE(process_map->Contains( | 222 EXPECT_TRUE(process_map->Contains( |
223 browser()->GetTabContentsAt(1)->GetRenderProcessHost()->GetID())); | 223 browser()->GetTabContentsAt(1)->GetRenderProcessHost()->GetID())); |
224 EXPECT_FALSE(browser()->GetTabContentsAt(1)->web_ui()); | 224 EXPECT_FALSE(browser()->GetTabContentsAt(1)->GetWebUI()); |
225 | 225 |
226 ui_test_utils::WindowedNotificationObserver tab_added_observer( | 226 ui_test_utils::WindowedNotificationObserver tab_added_observer( |
227 content::NOTIFICATION_TAB_ADDED, | 227 content::NOTIFICATION_TAB_ADDED, |
228 content::NotificationService::AllSources()); | 228 content::NotificationService::AllSources()); |
229 browser()->NewTab(); | 229 browser()->NewTab(); |
230 tab_added_observer.Wait(); | 230 tab_added_observer.Wait(); |
231 LOG(INFO) << "New tab."; | 231 LOG(INFO) << "New tab."; |
232 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path2/empty.html")); | 232 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path2/empty.html")); |
233 LOG(INFO) << "Nav 2."; | 233 LOG(INFO) << "Nav 2."; |
234 EXPECT_TRUE(process_map->Contains( | 234 EXPECT_TRUE(process_map->Contains( |
235 browser()->GetTabContentsAt(2)->GetRenderProcessHost()->GetID())); | 235 browser()->GetTabContentsAt(2)->GetRenderProcessHost()->GetID())); |
236 EXPECT_FALSE(browser()->GetTabContentsAt(2)->web_ui()); | 236 EXPECT_FALSE(browser()->GetTabContentsAt(2)->GetWebUI()); |
237 | 237 |
238 // We should have opened 2 new extension tabs. Including the original blank | 238 // We should have opened 2 new extension tabs. Including the original blank |
239 // tab, we now have 3 tabs. The two app tabs should not be in the same | 239 // tab, we now have 3 tabs. The two app tabs should not be in the same |
240 // process, since they do not have the background permission. (Thus, we want | 240 // process, since they do not have the background permission. (Thus, we want |
241 // to separate them to improve responsiveness.) | 241 // to separate them to improve responsiveness.) |
242 ASSERT_EQ(3, browser()->tab_count()); | 242 ASSERT_EQ(3, browser()->tab_count()); |
243 RenderViewHost* host1 = browser()->GetTabContentsAt(1)->GetRenderViewHost(); | 243 RenderViewHost* host1 = browser()->GetTabContentsAt(1)->GetRenderViewHost(); |
244 RenderViewHost* host2 = browser()->GetTabContentsAt(2)->GetRenderViewHost(); | 244 RenderViewHost* host2 = browser()->GetTabContentsAt(2)->GetRenderViewHost(); |
245 EXPECT_NE(host1->process(), host2->process()); | 245 EXPECT_NE(host1->process(), host2->process()); |
246 | 246 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 ASSERT_TRUE(extension->from_bookmark()); | 280 ASSERT_TRUE(extension->from_bookmark()); |
281 | 281 |
282 // Test both opening a URL in a new tab, and opening a tab and then navigating | 282 // Test both opening a URL in a new tab, and opening a tab and then navigating |
283 // it. Either way, bookmark app tabs should be considered normal processes | 283 // it. Either way, bookmark app tabs should be considered normal processes |
284 // with no elevated privileges and no WebUI bindings. | 284 // with no elevated privileges and no WebUI bindings. |
285 ui_test_utils::NavigateToURLWithDisposition( | 285 ui_test_utils::NavigateToURLWithDisposition( |
286 browser(), base_url.Resolve("path1/empty.html"), NEW_FOREGROUND_TAB, | 286 browser(), base_url.Resolve("path1/empty.html"), NEW_FOREGROUND_TAB, |
287 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 287 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
288 EXPECT_FALSE(process_map->Contains( | 288 EXPECT_FALSE(process_map->Contains( |
289 browser()->GetTabContentsAt(1)->GetRenderProcessHost()->GetID())); | 289 browser()->GetTabContentsAt(1)->GetRenderProcessHost()->GetID())); |
290 EXPECT_FALSE(browser()->GetTabContentsAt(1)->web_ui()); | 290 EXPECT_FALSE(browser()->GetTabContentsAt(1)->GetWebUI()); |
291 | 291 |
292 ui_test_utils::WindowedNotificationObserver tab_added_observer( | 292 ui_test_utils::WindowedNotificationObserver tab_added_observer( |
293 content::NOTIFICATION_TAB_ADDED, | 293 content::NOTIFICATION_TAB_ADDED, |
294 content::NotificationService::AllSources()); | 294 content::NotificationService::AllSources()); |
295 browser()->NewTab(); | 295 browser()->NewTab(); |
296 tab_added_observer.Wait(); | 296 tab_added_observer.Wait(); |
297 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path2/empty.html")); | 297 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path2/empty.html")); |
298 EXPECT_FALSE(process_map->Contains( | 298 EXPECT_FALSE(process_map->Contains( |
299 browser()->GetTabContentsAt(2)->GetRenderProcessHost()->GetID())); | 299 browser()->GetTabContentsAt(2)->GetRenderProcessHost()->GetID())); |
300 EXPECT_FALSE(browser()->GetTabContentsAt(2)->web_ui()); | 300 EXPECT_FALSE(browser()->GetTabContentsAt(2)->GetWebUI()); |
301 | 301 |
302 // We should have opened 2 new bookmark app tabs. Including the original blank | 302 // We should have opened 2 new bookmark app tabs. Including the original blank |
303 // tab, we now have 3 tabs. Because normal pages use the | 303 // tab, we now have 3 tabs. Because normal pages use the |
304 // process-per-site-instance model, each should be in its own process. | 304 // process-per-site-instance model, each should be in its own process. |
305 ASSERT_EQ(3, browser()->tab_count()); | 305 ASSERT_EQ(3, browser()->tab_count()); |
306 RenderViewHost* host = browser()->GetTabContentsAt(1)->GetRenderViewHost(); | 306 RenderViewHost* host = browser()->GetTabContentsAt(1)->GetRenderViewHost(); |
307 EXPECT_NE(host->process(), | 307 EXPECT_NE(host->process(), |
308 browser()->GetTabContentsAt(2)->GetRenderProcessHost()); | 308 browser()->GetTabContentsAt(2)->GetRenderProcessHost()); |
309 | 309 |
310 // Now let's do the same using window.open. The same should happen. | 310 // Now let's do the same using window.open. The same should happen. |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 &browser()->GetSelectedTabContentsWrapper()->tab_contents()-> | 654 &browser()->GetSelectedTabContentsWrapper()->tab_contents()-> |
655 GetController())); | 655 GetController())); |
656 browser()->Reload(CURRENT_TAB); | 656 browser()->Reload(CURRENT_TAB); |
657 observer.Wait(); | 657 observer.Wait(); |
658 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 658 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
659 contents->GetRenderViewHost(), L"", | 659 contents->GetRenderViewHost(), L"", |
660 L"window.domAutomationController.send(chrome.app.isInstalled)", | 660 L"window.domAutomationController.send(chrome.app.isInstalled)", |
661 &is_installed)); | 661 &is_installed)); |
662 ASSERT_TRUE(is_installed); | 662 ASSERT_TRUE(is_installed); |
663 } | 663 } |
OLD | NEW |