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_list.h" | 12 #include "chrome/browser/ui/browser_list.h" |
13 #include "chrome/browser/ui/browser_window.h" | 13 #include "chrome/browser/ui/browser_window.h" |
14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 15 #include "chrome/common/chrome_notification_types.h" |
15 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
16 #include "chrome/common/extensions/extension.h" | 17 #include "chrome/common/extensions/extension.h" |
17 #include "chrome/common/extensions/extension_file_util.h" | 18 #include "chrome/common/extensions/extension_file_util.h" |
18 #include "chrome/common/string_ordinal.h" | 19 #include "chrome/common/string_ordinal.h" |
19 #include "chrome/test/base/ui_test_utils.h" | 20 #include "chrome/test/base/ui_test_utils.h" |
20 #include "content/public/browser/navigation_entry.h" | 21 #include "content/public/browser/navigation_entry.h" |
21 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
22 #include "content/public/browser/render_process_host.h" | 23 #include "content/public/browser/render_process_host.h" |
23 #include "content/public/browser/render_view_host.h" | 24 #include "content/public/browser/render_view_host.h" |
24 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 // have WebUI bindings. | 120 // have WebUI bindings. |
120 ui_test_utils::NavigateToURLWithDisposition( | 121 ui_test_utils::NavigateToURLWithDisposition( |
121 browser(), base_url.Resolve("path1/empty.html"), NEW_FOREGROUND_TAB, | 122 browser(), base_url.Resolve("path1/empty.html"), NEW_FOREGROUND_TAB, |
122 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 123 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
123 LOG(INFO) << "Nav 1."; | 124 LOG(INFO) << "Nav 1."; |
124 EXPECT_TRUE(process_map->Contains( | 125 EXPECT_TRUE(process_map->Contains( |
125 browser()->GetWebContentsAt(1)->GetRenderProcessHost()->GetID())); | 126 browser()->GetWebContentsAt(1)->GetRenderProcessHost()->GetID())); |
126 EXPECT_FALSE(browser()->GetWebContentsAt(1)->GetWebUI()); | 127 EXPECT_FALSE(browser()->GetWebContentsAt(1)->GetWebUI()); |
127 | 128 |
128 ui_test_utils::WindowedNotificationObserver tab_added_observer( | 129 ui_test_utils::WindowedNotificationObserver tab_added_observer( |
129 content::NOTIFICATION_TAB_ADDED, | 130 chrome::NOTIFICATION_TAB_ADDED, |
130 content::NotificationService::AllSources()); | 131 content::NotificationService::AllSources()); |
131 browser()->NewTab(); | 132 browser()->NewTab(); |
132 tab_added_observer.Wait(); | 133 tab_added_observer.Wait(); |
133 LOG(INFO) << "New tab."; | 134 LOG(INFO) << "New tab."; |
134 ui_test_utils::NavigateToURL(browser(), | 135 ui_test_utils::NavigateToURL(browser(), |
135 base_url.Resolve("path2/empty.html")); | 136 base_url.Resolve("path2/empty.html")); |
136 LOG(INFO) << "Nav 2."; | 137 LOG(INFO) << "Nav 2."; |
137 EXPECT_TRUE(process_map->Contains( | 138 EXPECT_TRUE(process_map->Contains( |
138 browser()->GetWebContentsAt(2)->GetRenderProcessHost()->GetID())); | 139 browser()->GetWebContentsAt(2)->GetRenderProcessHost()->GetID())); |
139 EXPECT_FALSE(browser()->GetWebContentsAt(2)->GetWebUI()); | 140 EXPECT_FALSE(browser()->GetWebContentsAt(2)->GetWebUI()); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 | 191 |
191 ui_test_utils::NavigateToURLWithDisposition( | 192 ui_test_utils::NavigateToURLWithDisposition( |
192 browser(), base_url.Resolve("path2/empty.html"), NEW_FOREGROUND_TAB, | 193 browser(), base_url.Resolve("path2/empty.html"), NEW_FOREGROUND_TAB, |
193 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 194 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
194 EXPECT_TRUE(process_map->Contains( | 195 EXPECT_TRUE(process_map->Contains( |
195 browser()->GetWebContentsAt(2)->GetRenderProcessHost()->GetID())); | 196 browser()->GetWebContentsAt(2)->GetRenderProcessHost()->GetID())); |
196 EXPECT_FALSE(browser()->GetWebContentsAt(2)->GetWebUI()); | 197 EXPECT_FALSE(browser()->GetWebContentsAt(2)->GetWebUI()); |
197 LOG(INFO) << "Nav 2."; | 198 LOG(INFO) << "Nav 2."; |
198 | 199 |
199 ui_test_utils::WindowedNotificationObserver tab_added_observer( | 200 ui_test_utils::WindowedNotificationObserver tab_added_observer( |
200 content::NOTIFICATION_TAB_ADDED, | 201 chrome::NOTIFICATION_TAB_ADDED, |
201 content::NotificationService::AllSources()); | 202 content::NotificationService::AllSources()); |
202 browser()->NewTab(); | 203 browser()->NewTab(); |
203 tab_added_observer.Wait(); | 204 tab_added_observer.Wait(); |
204 LOG(INFO) << "New tab."; | 205 LOG(INFO) << "New tab."; |
205 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path3/empty.html")); | 206 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path3/empty.html")); |
206 LOG(INFO) << "Nav 3."; | 207 LOG(INFO) << "Nav 3."; |
207 EXPECT_FALSE(process_map->Contains( | 208 EXPECT_FALSE(process_map->Contains( |
208 browser()->GetWebContentsAt(3)->GetRenderProcessHost()->GetID())); | 209 browser()->GetWebContentsAt(3)->GetRenderProcessHost()->GetID())); |
209 EXPECT_FALSE(browser()->GetWebContentsAt(3)->GetWebUI()); | 210 EXPECT_FALSE(browser()->GetWebContentsAt(3)->GetWebUI()); |
210 | 211 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 // it. Either way, bookmark app tabs should be considered normal processes | 308 // it. Either way, bookmark app tabs should be considered normal processes |
308 // with no elevated privileges and no WebUI bindings. | 309 // with no elevated privileges and no WebUI bindings. |
309 ui_test_utils::NavigateToURLWithDisposition( | 310 ui_test_utils::NavigateToURLWithDisposition( |
310 browser(), base_url.Resolve("path1/empty.html"), NEW_FOREGROUND_TAB, | 311 browser(), base_url.Resolve("path1/empty.html"), NEW_FOREGROUND_TAB, |
311 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 312 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
312 EXPECT_FALSE(process_map->Contains( | 313 EXPECT_FALSE(process_map->Contains( |
313 browser()->GetWebContentsAt(1)->GetRenderProcessHost()->GetID())); | 314 browser()->GetWebContentsAt(1)->GetRenderProcessHost()->GetID())); |
314 EXPECT_FALSE(browser()->GetWebContentsAt(1)->GetWebUI()); | 315 EXPECT_FALSE(browser()->GetWebContentsAt(1)->GetWebUI()); |
315 | 316 |
316 ui_test_utils::WindowedNotificationObserver tab_added_observer( | 317 ui_test_utils::WindowedNotificationObserver tab_added_observer( |
317 content::NOTIFICATION_TAB_ADDED, | 318 chrome::NOTIFICATION_TAB_ADDED, |
318 content::NotificationService::AllSources()); | 319 content::NotificationService::AllSources()); |
319 browser()->NewTab(); | 320 browser()->NewTab(); |
320 tab_added_observer.Wait(); | 321 tab_added_observer.Wait(); |
321 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path2/empty.html")); | 322 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path2/empty.html")); |
322 EXPECT_FALSE(process_map->Contains( | 323 EXPECT_FALSE(process_map->Contains( |
323 browser()->GetWebContentsAt(2)->GetRenderProcessHost()->GetID())); | 324 browser()->GetWebContentsAt(2)->GetRenderProcessHost()->GetID())); |
324 EXPECT_FALSE(browser()->GetWebContentsAt(2)->GetWebUI()); | 325 EXPECT_FALSE(browser()->GetWebContentsAt(2)->GetWebUI()); |
325 | 326 |
326 // We should have opened 2 new bookmark app tabs. Including the original blank | 327 // We should have opened 2 new bookmark app tabs. Including the original blank |
327 // tab, we now have 3 tabs. Because normal pages use the | 328 // tab, we now have 3 tabs. Because normal pages use the |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 &browser()->GetSelectedTabContentsWrapper()->web_contents()-> | 672 &browser()->GetSelectedTabContentsWrapper()->web_contents()-> |
672 GetController())); | 673 GetController())); |
673 browser()->Reload(CURRENT_TAB); | 674 browser()->Reload(CURRENT_TAB); |
674 observer.Wait(); | 675 observer.Wait(); |
675 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 676 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
676 contents->GetRenderViewHost(), L"", | 677 contents->GetRenderViewHost(), L"", |
677 L"window.domAutomationController.send(chrome.app.isInstalled)", | 678 L"window.domAutomationController.send(chrome.app.isInstalled)", |
678 &is_installed)); | 679 &is_installed)); |
679 ASSERT_TRUE(is_installed); | 680 ASSERT_TRUE(is_installed); |
680 } | 681 } |
OLD | NEW |