| OLD | NEW |
| (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 logging | |
| 7 import os | |
| 8 import signal | |
| 9 import subprocess | |
| 10 import tempfile | |
| 11 import unittest | |
| 12 | |
| 13 import pyauto_functional | |
| 14 import pyauto | |
| 15 import test_utils | |
| 16 | |
| 17 | |
| 18 class SimpleTest(pyauto.PyUITest): | |
| 19 | |
| 20 def ExtraChromeFlags(self): | |
| 21 """Ensures Chrome is launched with custom flags. | |
| 22 | |
| 23 Returns: | |
| 24 A list of extra flags to pass to Chrome when it is launched. | |
| 25 """ | |
| 26 fd, self._strace_log = tempfile.mkstemp() | |
| 27 os.close(fd) | |
| 28 extra_flags = ['--no-sandbox', '--child-clean-exit', | |
| 29 '--renderer-cmd-prefix=/usr/bin/strace -o %s' % | |
| 30 self._strace_log] | |
| 31 logging.debug('Strace file is: %s' % self._strace_log) | |
| 32 return pyauto.PyUITest.ExtraChromeFlags(self) + extra_flags | |
| 33 | |
| 34 | |
| 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) | |
| 44 | |
| 45 def _IsFileOpen(self, filename): | |
| 46 p = subprocess.Popen(['lsof', filename]) | |
| 47 return p.communicate()[0] == '' | |
| 48 | |
| 49 | |
| 50 if __name__ == '__main__': | |
| 51 pyauto_functional.Main() | |
| OLD | NEW |