Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(483)

Side by Side Diff: chrome/test/functional/test_clean_exit_with_children.py

Issue 19231006: chrome: respect --child-clean-exit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Made comments better. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | content/app/content_main_runner.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 import os
7 import psutil
8 import signal
9 import time
10 import unittest
11
12 import pyauto_functional
13 import pyauto
14
15
16 class WaitForChildrenBeforeExitingTest(pyauto.PyUITest):
17
18 def ExtraChromeFlags(self):
19 """Ensures Chrome is launched with custom flags.
20
21 Returns:
22 A list of extra flags to pass to Chrome when it is launched.
23 """
24 extra_flags = ['--no-sandbox', '--child-clean-exit',
25 '--wait-for-children-before-exiting']
26 return pyauto.PyUITest.ExtraChromeFlags(self) + extra_flags
27
28
29 def _IsProcessAlive(self, pid):
30 """Checks whether a process is alive or not.
31
32 Args:
33 pid: The process id on which to perform this check.
34
35 Returns:
36 True if a process is alive and not a zombie.
37 """
38 try:
39 process = psutil.Process(pid)
40 except psutil.error.NoSuchProcess:
41 return False
42
43 if process.status == psutil.STATUS_ZOMBIE:
44 return False
45
46 return True
47
48 def testWaitForChildrenBeforeExiting(self):
49 """Ensures the browser process waits for all children before exiting."""
50 url = self.GetHttpURLForDataPath('title2.html')
51 self.NavigateToURL(url)
52
53 browser_pid = self.GetBrowserInfo()['browser_pid']
54 renderer_pid = (
55 self.GetBrowserInfo()['windows'][0]['tabs'][0]['renderer_pid'])
56
57 os.kill(renderer_pid, signal.SIGSTOP)
58 os.kill(browser_pid, signal.SIGINT)
59
60 time.sleep(20)
61
62 # The browser should still be alive, waiting for the renderer to die.
63 self.assertTrue(self._IsProcessAlive(browser_pid))
64 self.assertTrue(self._IsProcessAlive(renderer_pid))
65
66 # Resume the renderer.
67 os.kill(renderer_pid, signal.SIGCONT)
68
69 time.sleep(20)
70
71 self.assertFalse(self._IsProcessAlive(renderer_pid))
72 self.assertFalse(self._IsProcessAlive(browser_pid))
73
74
75 if __name__ == '__main__':
76 pyauto_functional.Main()
OLDNEW
« no previous file with comments | « no previous file | content/app/content_main_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698