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 "base/macros.h" | 6 #include "base/macros.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/process/process.h" | 8 #include "base/process/process.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 99 |
100 WaitForLauncherThread(); | 100 WaitForLauncherThread(); |
101 WaitForMessageProcessing(wc); | 101 WaitForMessageProcessing(wc); |
102 return ProcessFromHandle(wc->GetRenderProcessHost()->GetHandle()); | 102 return ProcessFromHandle(wc->GetRenderProcessHost()->GetHandle()); |
103 } | 103 } |
104 | 104 |
105 // Loads the given url in a new background tab and returns the handle of its | 105 // Loads the given url in a new background tab and returns the handle of its |
106 // renderer. | 106 // renderer. |
107 base::Process OpenBackgroundTab(const GURL& page) { | 107 base::Process OpenBackgroundTab(const GURL& page) { |
108 ui_test_utils::NavigateToURLWithDisposition( | 108 ui_test_utils::NavigateToURLWithDisposition( |
109 browser(), page, NEW_BACKGROUND_TAB, | 109 browser(), page, WindowOpenDisposition::NEW_BACKGROUND_TAB, |
110 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 110 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
111 | 111 |
112 TabStripModel* tab_strip = browser()->tab_strip_model(); | 112 TabStripModel* tab_strip = browser()->tab_strip_model(); |
113 WebContents* wc = | 113 WebContents* wc = |
114 tab_strip->GetWebContentsAt(tab_strip->active_index() + 1); | 114 tab_strip->GetWebContentsAt(tab_strip->active_index() + 1); |
115 CHECK(wc->GetVisibleURL() == page); | 115 CHECK(wc->GetVisibleURL() == page); |
116 | 116 |
117 WaitForLauncherThread(); | 117 WaitForLauncherThread(); |
118 WaitForMessageProcessing(wc); | 118 WaitForMessageProcessing(wc); |
119 return ProcessFromHandle(wc->GetRenderProcessHost()->GetHandle()); | 119 return ProcessFromHandle(wc->GetRenderProcessHost()->GetHandle()); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 content::NotificationService::AllSources()); | 273 content::NotificationService::AllSources()); |
274 chrome::ShowSingletonTab(browser(), page2); | 274 chrome::ShowSingletonTab(browser(), page2); |
275 observer2.Wait(); | 275 observer2.Wait(); |
276 tab_count++; | 276 tab_count++; |
277 EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); | 277 EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); |
278 EXPECT_EQ(host_count, RenderProcessHostCount()); | 278 EXPECT_EQ(host_count, RenderProcessHostCount()); |
279 | 279 |
280 // Create another omnibox tab. It should share the process with the other | 280 // Create another omnibox tab. It should share the process with the other |
281 // WebUI. | 281 // WebUI. |
282 ui_test_utils::NavigateToURLWithDisposition( | 282 ui_test_utils::NavigateToURLWithDisposition( |
283 browser(), omnibox, NEW_FOREGROUND_TAB, | 283 browser(), omnibox, WindowOpenDisposition::NEW_FOREGROUND_TAB, |
284 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 284 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
285 tab_count++; | 285 tab_count++; |
286 EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); | 286 EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); |
287 EXPECT_EQ(host_count, RenderProcessHostCount()); | 287 EXPECT_EQ(host_count, RenderProcessHostCount()); |
288 | 288 |
289 // Create another omnibox tab. It should share the process with the other | 289 // Create another omnibox tab. It should share the process with the other |
290 // WebUI. | 290 // WebUI. |
291 ui_test_utils::NavigateToURLWithDisposition( | 291 ui_test_utils::NavigateToURLWithDisposition( |
292 browser(), omnibox, NEW_FOREGROUND_TAB, | 292 browser(), omnibox, WindowOpenDisposition::NEW_FOREGROUND_TAB, |
293 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 293 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
294 tab_count++; | 294 tab_count++; |
295 EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); | 295 EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); |
296 EXPECT_EQ(host_count, RenderProcessHostCount()); | 296 EXPECT_EQ(host_count, RenderProcessHostCount()); |
297 } | 297 } |
298 | 298 |
299 // We don't change process priorities on Mac or Posix because the user lacks the | 299 // We don't change process priorities on Mac or Posix because the user lacks the |
300 // permission to raise a process' priority even after lowering it. | 300 // permission to raise a process' priority even after lowering it. |
301 #if defined(OS_WIN) || defined(OS_LINUX) | 301 #if defined(OS_WIN) || defined(OS_LINUX) |
302 IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, Backgrounding) { | 302 IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, Backgrounding) { |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 DISABLED_CloseAllTabsDuringProcessDied | 507 DISABLED_CloseAllTabsDuringProcessDied |
508 #else | 508 #else |
509 #define MAYBE_CloseAllTabsDuringProcessDied CloseAllTabsDuringProcessDied | 509 #define MAYBE_CloseAllTabsDuringProcessDied CloseAllTabsDuringProcessDied |
510 #endif | 510 #endif |
511 IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, | 511 IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, |
512 MAYBE_CloseAllTabsDuringProcessDied) { | 512 MAYBE_CloseAllTabsDuringProcessDied) { |
513 GURL url(chrome::kChromeUIOmniboxURL); | 513 GURL url(chrome::kChromeUIOmniboxURL); |
514 | 514 |
515 ui_test_utils::NavigateToURL(browser(), url); | 515 ui_test_utils::NavigateToURL(browser(), url); |
516 ui_test_utils::NavigateToURLWithDisposition( | 516 ui_test_utils::NavigateToURLWithDisposition( |
517 browser(), url, NEW_BACKGROUND_TAB, | 517 browser(), url, WindowOpenDisposition::NEW_BACKGROUND_TAB, |
518 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 518 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
519 | 519 |
520 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 520 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
521 | 521 |
522 WebContents* wc1 = browser()->tab_strip_model()->GetWebContentsAt(0); | 522 WebContents* wc1 = browser()->tab_strip_model()->GetWebContentsAt(0); |
523 WebContents* wc2 = browser()->tab_strip_model()->GetWebContentsAt(1); | 523 WebContents* wc2 = browser()->tab_strip_model()->GetWebContentsAt(1); |
524 EXPECT_EQ(wc1->GetRenderProcessHost(), wc2->GetRenderProcessHost()); | 524 EXPECT_EQ(wc1->GetRenderProcessHost(), wc2->GetRenderProcessHost()); |
525 | 525 |
526 // Create an object that will close the window on a process crash. | 526 // Create an object that will close the window on a process crash. |
527 WindowDestroyer destroyer(wc1, browser()->tab_strip_model()); | 527 WindowDestroyer destroyer(wc1, browser()->tab_strip_model()); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 content::ExecuteScript(audio_tab_web_contents_, | 679 content::ExecuteScript(audio_tab_web_contents_, |
680 "document.getElementById('audioPlayer').play();")); | 680 "document.getElementById('audioPlayer').play();")); |
681 | 681 |
682 // Wait until the two pages are not backgrounded. | 682 // Wait until the two pages are not backgrounded. |
683 while (no_audio_process_.IsProcessBackgrounded() || | 683 while (no_audio_process_.IsProcessBackgrounded() || |
684 audio_process_.IsProcessBackgrounded()) { | 684 audio_process_.IsProcessBackgrounded()) { |
685 base::RunLoop().RunUntilIdle(); | 685 base::RunLoop().RunUntilIdle(); |
686 base::PlatformThread::Sleep(TestTimeouts::tiny_timeout()); | 686 base::PlatformThread::Sleep(TestTimeouts::tiny_timeout()); |
687 } | 687 } |
688 } | 688 } |
OLD | NEW |