blob: 373c7646c48e08838f5831b97ec6a213e5d61f6b [file] [log] [blame]
#!/usr/bin/env python
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Enable chrome testing interface on ChromeOS.
Enables chrome automation over a named automation channel on ChromeOS.
Also, allows passing extra flags to chrome (--extra-chrome-flags).
The path to named testing interface automation socket is printed out.
Needs to be run with superuser privileges.
sudo python --extra-chrome-flags="--homepage=about:blank"
import dbus
import optparse
import os
import sys
class EnableChromeTestingOnChromeOS(object):
"""Helper to enable chrome testing interface on ChromeOS.
Also, can add additional flags to chrome to be used for testing.
SESSION_MANAGER_INTERFACE = 'org.chromium.SessionManagerInterface'
SESSION_MANAGER_PATH = '/org/chromium/SessionManager'
SESSION_MANAGER_SERVICE = 'org.chromium.SessionManager'
def _ParseArgs(self):
parser = optparse.OptionParser()
'', '--extra-chrome-flags', action='append', default=[],
help='Pass extra flags to chrome.')
self._options, self._args = parser.parse_args()
def Run(self):
assert os.geteuid() == 0, 'Needs superuser privileges.'
system_bus = dbus.SystemBus()
manager = dbus.Interface(system_bus.get_object(self.SESSION_MANAGER_SERVICE,
print manager.EnableChromeTesting(True, self._options.extra_chrome_flags)
return 0
if __name__ == '__main__':