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.
13 import pyauto_functional
18 class SimpleTest(pyauto.PyUITest):
20 def ExtraChromeFlags(self):
21 """Ensures Chrome is launched with custom flags.
24 A list of extra flags to pass to Chrome when it is launched.
26 fd, self._strace_log = tempfile.mkstemp()
28 extra_flags = ['--no-sandbox', '--child-clean-exit',
29 '--renderer-cmd-prefix=/usr/bin/strace -o %s' %
31 logging.debug('Strace file is: %s' % self._strace_log)
32 return pyauto.PyUITest.ExtraChromeFlags(self) + extra_flags
35 def testCleanExit(self):
36 """Ensures the renderer process cleanly exits."""
37 url = self.GetHttpURLForDataPath('title2.html')
38 self.NavigateToURL(url)
39 os.kill(self.GetBrowserInfo()['browser_pid'], signal.SIGINT)
40 self.WaitUntil(lambda: self._IsFileOpen(self._strace_log))
41 strace_contents = open(self._strace_log).read()
42 self.assertTrue('exit_group' in strace_contents)
43 os.remove(self._strace_log)
45 def _IsFileOpen(self, filename):
46 p = subprocess.Popen(['lsof', filename])
47 return p.communicate()[0] == ''
50 if __name__ == '__main__':
51 pyauto_functional.Main()