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/process/process.h" | 6 #include "base/process/process.h" |
7 #include "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
8 #include "chrome/browser/devtools/devtools_window.h" | 8 #include "chrome/browser/devtools/devtools_window.h" |
9 #include "chrome/browser/search/search.h" | 9 #include "chrome/browser/search/search.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 GURL page1("data:text/html,hello world1"); | 314 GURL page1("data:text/html,hello world1"); |
315 base::Process process1 = ShowSingletonTab(page1); | 315 base::Process process1 = ShowSingletonTab(page1); |
316 ASSERT_TRUE(process1.IsValid()); | 316 ASSERT_TRUE(process1.IsValid()); |
317 EXPECT_FALSE(process1.IsProcessBackgrounded()); | 317 EXPECT_FALSE(process1.IsProcessBackgrounded()); |
318 | 318 |
319 // Create another tab. It should be foreground, and the first tab should | 319 // Create another tab. It should be foreground, and the first tab should |
320 // now be background. | 320 // now be background. |
321 GURL page2("data:text/html,hello world2"); | 321 GURL page2("data:text/html,hello world2"); |
322 base::Process process2 = ShowSingletonTab(page2); | 322 base::Process process2 = ShowSingletonTab(page2); |
323 ASSERT_TRUE(process2.IsValid()); | 323 ASSERT_TRUE(process2.IsValid()); |
324 EXPECT_NE(process1.pid(), process2.pid()); | 324 EXPECT_NE(process1.Pid(), process2.Pid()); |
325 EXPECT_TRUE(process1.IsProcessBackgrounded()); | 325 EXPECT_TRUE(process1.IsProcessBackgrounded()); |
326 EXPECT_FALSE(process2.IsProcessBackgrounded()); | 326 EXPECT_FALSE(process2.IsProcessBackgrounded()); |
327 | 327 |
328 // Load another tab in background. The renderer of the new tab should be | 328 // Load another tab in background. The renderer of the new tab should be |
329 // backgrounded, while visibility of the other renderers should not change. | 329 // backgrounded, while visibility of the other renderers should not change. |
330 GURL page3("data:text/html,hello world3"); | 330 GURL page3("data:text/html,hello world3"); |
331 base::Process process3 = OpenBackgroundTab(page3); | 331 base::Process process3 = OpenBackgroundTab(page3); |
332 ASSERT_TRUE(process3.IsValid()); | 332 ASSERT_TRUE(process3.IsValid()); |
333 EXPECT_NE(process3.pid(), process1.pid()); | 333 EXPECT_NE(process3.Pid(), process1.Pid()); |
334 EXPECT_NE(process3.pid(), process2.pid()); | 334 EXPECT_NE(process3.Pid(), process2.Pid()); |
335 EXPECT_TRUE(process1.IsProcessBackgrounded()); | 335 EXPECT_TRUE(process1.IsProcessBackgrounded()); |
336 EXPECT_FALSE(process2.IsProcessBackgrounded()); | 336 EXPECT_FALSE(process2.IsProcessBackgrounded()); |
337 EXPECT_TRUE(process3.IsProcessBackgrounded()); | 337 EXPECT_TRUE(process3.IsProcessBackgrounded()); |
338 | 338 |
339 // Navigate back to the first page. Its renderer should be in foreground | 339 // Navigate back to the first page. Its renderer should be in foreground |
340 // again while the other renderers should be backgrounded. | 340 // again while the other renderers should be backgrounded. |
341 EXPECT_EQ(process1.pid(), ShowSingletonTab(page1).pid()); | 341 EXPECT_EQ(process1.Pid(), ShowSingletonTab(page1).Pid()); |
342 EXPECT_FALSE(process1.IsProcessBackgrounded()); | 342 EXPECT_FALSE(process1.IsProcessBackgrounded()); |
343 EXPECT_TRUE(process2.IsProcessBackgrounded()); | 343 EXPECT_TRUE(process2.IsProcessBackgrounded()); |
344 EXPECT_TRUE(process3.IsProcessBackgrounded()); | 344 EXPECT_TRUE(process3.IsProcessBackgrounded()); |
345 } | 345 } |
346 #endif | 346 #endif |
347 | 347 |
348 // TODO(nasko): crbug.com/173137 | 348 // TODO(nasko): crbug.com/173137 |
349 // Disable on Mac 10.9 due to ongoing flakiness. (crbug.com/442785) | 349 // Disable on Mac 10.9 due to ongoing flakiness. (crbug.com/442785) |
350 #if defined(OS_WIN) || defined(OS_MACOSX) | 350 #if defined(OS_WIN) || defined(OS_MACOSX) |
351 #define MAYBE_ProcessOverflow DISABLED_ProcessOverflow | 351 #define MAYBE_ProcessOverflow DISABLED_ProcessOverflow |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 chrome::NOTIFICATION_BROWSER_CLOSED, | 527 chrome::NOTIFICATION_BROWSER_CLOSED, |
528 content::NotificationService::AllSources()); | 528 content::NotificationService::AllSources()); |
529 | 529 |
530 // Kill the renderer process, simulating a crash. This should the ProcessDied | 530 // Kill the renderer process, simulating a crash. This should the ProcessDied |
531 // method to be called. Alternatively, RenderProcessHost::OnChannelError can | 531 // method to be called. Alternatively, RenderProcessHost::OnChannelError can |
532 // be called to directly force a call to ProcessDied. | 532 // be called to directly force a call to ProcessDied. |
533 wc1->GetRenderProcessHost()->Shutdown(-1, true); | 533 wc1->GetRenderProcessHost()->Shutdown(-1, true); |
534 | 534 |
535 observer.Wait(); | 535 observer.Wait(); |
536 } | 536 } |
OLD | NEW |