2 # Copyright (c) 2011 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.
6 """Enable chrome testing interface on ChromeOS.
8 Enables chrome automation over a named automation channel on ChromeOS.
9 Also, allows passing extra flags to chrome (--extra-chrome-flags).
10 The path to named testing interface automation socket is printed out.
12 Needs to be run with superuser privileges.
15 sudo python enable_testing.py --extra-chrome-flags="--homepage=about:blank"
24 class EnableChromeTestingOnChromeOS(object):
25 """Helper to enable chrome testing interface on ChromeOS.
27 Also, can add additional flags to chrome to be used for testing.
30 SESSION_MANAGER_INTERFACE = 'org.chromium.SessionManagerInterface'
31 SESSION_MANAGER_PATH = '/org/chromium/SessionManager'
32 SESSION_MANAGER_SERVICE = 'org.chromium.SessionManager'
35 parser = optparse.OptionParser()
37 '', '--extra-chrome-flags', action='append', default=[],
38 help='Pass extra flags to chrome.')
39 self._options, self._args = parser.parse_args()
43 assert os.geteuid() == 0, 'Needs superuser privileges.'
44 system_bus = dbus.SystemBus()
45 manager = dbus.Interface(system_bus.get_object(self.SESSION_MANAGER_SERVICE,
46 self.SESSION_MANAGER_PATH),
47 self.SESSION_MANAGER_INTERFACE)
48 print manager.EnableChromeTesting(True, self._options.extra_chrome_flags)
52 if __name__ == '__main__':
53 sys.exit(EnableChromeTestingOnChromeOS().Run())