OLD | NEW |
(Empty) | |
| 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 |
| 6 import os, subprocess, time |
| 7 from autotest_lib.client.bin import site_utils, test, utils |
| 8 from autotest_lib.client.common_lib import error, site_ui |
| 9 |
| 10 |
| 11 class security_RendererSandbox(test.test): |
| 12 version = 1 |
| 13 render_pid = -1 |
| 14 |
| 15 def run_once(self, time_to_wait=20): |
| 16 # open browser to google.com. |
| 17 session = site_ui.ChromeSession('http://www.google.com') |
| 18 |
| 19 try: |
| 20 # wait till the page is loaded and poll for the renderer pid |
| 21 # if renderer pid is found, it is stored in self.render_pid |
| 22 site_utils.poll_for_condition( |
| 23 self._get_renderer_pid, |
| 24 error.TestFail('Timed out waiting to obtain pid of renderer'), |
| 25 time_to_wait) |
| 26 |
| 27 #check if renderer is sandboxed |
| 28 cwd_contents = os.listdir('/proc/%s/cwd' % self.render_pid) |
| 29 if len(cwd_contents) > 0: |
| 30 raise error.TestFail('Contents present in the CWD directory') |
| 31 finally: |
| 32 session.close() |
| 33 |
| 34 |
| 35 # queries pgrep for the pid of the renderer. since this function is passed |
| 36 # as an argument to site_utils.poll_for_condition, the return values are set |
| 37 # to true/false depending on whether a pid has been found |
| 38 def _get_renderer_pid(self): |
| 39 pgrep = subprocess.Popen(['pgrep', '-f', '%s' % 'type=renderer'], |
| 40 stdout=subprocess.PIPE) |
| 41 pids = pgrep.communicate()[0].split() |
| 42 if pids: |
| 43 self.render_pid = pids[0] |
| 44 return True |
| 45 else: |
| 46 return False |
OLD | NEW |