blob: 373c7646c48e08838f5831b97ec6a213e5d61f6b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#!/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.
Usage:
sudo python enable_testing.py --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()
parser.add_option(
'', '--extra-chrome-flags', action='append', default=[],
help='Pass extra flags to chrome.')
self._options, self._args = parser.parse_args()
def Run(self):
self._ParseArgs()
assert os.geteuid() == 0, 'Needs superuser privileges.'
system_bus = dbus.SystemBus()
manager = dbus.Interface(system_bus.get_object(self.SESSION_MANAGER_SERVICE,
self.SESSION_MANAGER_PATH),
self.SESSION_MANAGER_INTERFACE)
print manager.EnableChromeTesting(True, self._options.extra_chrome_flags)
return 0
if __name__ == '__main__':
sys.exit(EnableChromeTestingOnChromeOS().Run())
|