| 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/test/test_timeouts.h" | 9 #include "base/test/test_timeouts.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 | 329 |
| 330 // Load another tab in background. The renderer of the new tab should be | 330 // Load another tab in background. The renderer of the new tab should be |
| 331 // backgrounded, while visibility of the other renderers should not change. | 331 // backgrounded, while visibility of the other renderers should not change. |
| 332 GURL page3("data:text/html,hello world3"); | 332 GURL page3("data:text/html,hello world3"); |
| 333 base::Process process3 = OpenBackgroundTab(page3); | 333 base::Process process3 = OpenBackgroundTab(page3); |
| 334 ASSERT_TRUE(process3.IsValid()); | 334 ASSERT_TRUE(process3.IsValid()); |
| 335 EXPECT_NE(process3.Pid(), process1.Pid()); | 335 EXPECT_NE(process3.Pid(), process1.Pid()); |
| 336 EXPECT_NE(process3.Pid(), process2.Pid()); | 336 EXPECT_NE(process3.Pid(), process2.Pid()); |
| 337 EXPECT_TRUE(process1.IsProcessBackgrounded()); | 337 EXPECT_TRUE(process1.IsProcessBackgrounded()); |
| 338 EXPECT_FALSE(process2.IsProcessBackgrounded()); | 338 EXPECT_FALSE(process2.IsProcessBackgrounded()); |
| 339 EXPECT_TRUE(process3.IsProcessBackgrounded()); | 339 // TODO(gab): The new background tab should be backgrounded but it currently |
| 340 // intentionally isn't per a workaround to https://crbug.com/560446 in |
| 341 // RenderProcessHostImpl::OnProcessLaunched(). |
| 342 EXPECT_FALSE(process3.IsProcessBackgrounded()); |
| 340 | 343 |
| 341 // Navigate back to the first page. Its renderer should be in foreground | 344 // Navigate back to the first page. Its renderer should be in foreground |
| 342 // again while the other renderers should be backgrounded. | 345 // again while the other renderers should be backgrounded. |
| 343 EXPECT_EQ(process1.Pid(), ShowSingletonTab(page1).Pid()); | 346 EXPECT_EQ(process1.Pid(), ShowSingletonTab(page1).Pid()); |
| 344 EXPECT_FALSE(process1.IsProcessBackgrounded()); | 347 EXPECT_FALSE(process1.IsProcessBackgrounded()); |
| 345 EXPECT_TRUE(process2.IsProcessBackgrounded()); | 348 EXPECT_TRUE(process2.IsProcessBackgrounded()); |
| 349 // TODO(gab): Same as above. |
| 350 EXPECT_FALSE(process3.IsProcessBackgrounded()); |
| 351 |
| 352 // TODO(gab): Remove this when https://crbug.com/560446 is fixed, but for now |
| 353 // confirm that the correct state is at least achieved when tab #3 is |
| 354 // explicitly foregrounded and re-backgrounded. |
| 355 EXPECT_EQ(process3.Pid(), ShowSingletonTab(page3).Pid()); |
| 356 EXPECT_EQ(process1.Pid(), ShowSingletonTab(page1).Pid()); |
| 357 EXPECT_FALSE(process1.IsProcessBackgrounded()); |
| 358 EXPECT_TRUE(process2.IsProcessBackgrounded()); |
| 346 EXPECT_TRUE(process3.IsProcessBackgrounded()); | 359 EXPECT_TRUE(process3.IsProcessBackgrounded()); |
| 347 } | 360 } |
| 348 #endif | 361 #endif |
| 349 | 362 |
| 350 // TODO(nasko): crbug.com/173137 | 363 // TODO(nasko): crbug.com/173137 |
| 351 // Disable on Mac 10.9 due to ongoing flakiness. (crbug.com/442785) | 364 // Disable on Mac 10.9 due to ongoing flakiness. (crbug.com/442785) |
| 352 #if defined(OS_MACOSX) | 365 #if defined(OS_MACOSX) |
| 353 #define MAYBE_ProcessOverflow DISABLED_ProcessOverflow | 366 #define MAYBE_ProcessOverflow DISABLED_ProcessOverflow |
| 354 #else | 367 #else |
| 355 #define MAYBE_ProcessOverflow ProcessOverflow | 368 #define MAYBE_ProcessOverflow ProcessOverflow |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 content::ExecuteScript(audio_tab_web_contents_, | 686 content::ExecuteScript(audio_tab_web_contents_, |
| 674 "document.getElementById('audioPlayer').play();")); | 687 "document.getElementById('audioPlayer').play();")); |
| 675 | 688 |
| 676 // Wait until the two pages are not backgrounded. | 689 // Wait until the two pages are not backgrounded. |
| 677 while (no_audio_process_.IsProcessBackgrounded() || | 690 while (no_audio_process_.IsProcessBackgrounded() || |
| 678 audio_process_.IsProcessBackgrounded()) { | 691 audio_process_.IsProcessBackgrounded()) { |
| 679 base::RunLoop().RunUntilIdle(); | 692 base::RunLoop().RunUntilIdle(); |
| 680 base::PlatformThread::Sleep(TestTimeouts::tiny_timeout()); | 693 base::PlatformThread::Sleep(TestTimeouts::tiny_timeout()); |
| 681 } | 694 } |
| 682 } | 695 } |
| OLD | NEW |