Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: tools/telemetry/telemetry/cros_browser_backend.py

Issue 11412238: Proof of concept for running extension API stack through dev tools. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 import logging 4 import logging
5 import os 5 import os
6 import socket 6 import socket
7 import subprocess 7 import subprocess
8 8
9 from telemetry import browser_backend 9 from telemetry import browser_backend
10 from telemetry import util 10 from telemetry import util
11 11
12 class CrOSBrowserBackend(browser_backend.BrowserBackend): 12 class CrOSBrowserBackend(browser_backend.BrowserBackend):
13 def __init__(self, browser_type, options, is_content_shell, cri): 13 def __init__(self, browser_type, options, is_content_shell, cri):
14 super(CrOSBrowserBackend, self).__init__(is_content_shell, options) 14 super(CrOSBrowserBackend, self).__init__(is_content_shell, options)
15 # Initialize fields so that an explosion during init doesn't break in Close. 15 # Initialize fields so that an explosion during init doesn't break in Close.
16 self._options = options 16 self._options = options
17 assert not is_content_shell 17 assert not is_content_shell
18 self._cri = cri 18 self._cri = cri
19 self._browser_type = browser_type 19 self._browser_type = browser_type
20 20
21 self._remote_debugging_port = self._cri.GetRemotePort() 21 self._remote_debugging_port = self._cri.GetRemotePort()
22 self._login_ext_dir = '/tmp/chromeos_login_ext' 22 self._login_ext_dir = '/tmp/chromeos_login_ext'
23 self._auto_ext_dir = '/tmp/auto_provider'
23 24
24 # Ensure the UI is running and logged out. 25 # Ensure the UI is running and logged out.
25 self._RestartUI() 26 self._RestartUI()
26 27
27 # Delete test@test.test's cryptohome vault (user data directory). 28 # Delete test@test.test's cryptohome vault (user data directory).
28 if not options.dont_override_profile: 29 if not options.dont_override_profile:
29 logging.info('Deleting user\'s cryptohome vault (the user data dir)') 30 logging.info('Deleting user\'s cryptohome vault (the user data dir)')
30 self._cri.GetCmdOutput( 31 self._cri.GetCmdOutput(
31 ['cryptohome', '--action=remove', '--force', '--user=test@test.test']) 32 ['cryptohome', '--action=remove', '--force', '--user=test@test.test'])
32 33
33 # Push a dummy login extension to the device. 34 # Push a dummy login extension to the device.
34 # This extension automatically logs in as test@test.test 35 # This extension automatically logs in as test@test.test
35 logging.info('Copying dummy login extension to the device') 36 logging.info('Copying dummy login extension to the device')
36 cri.PushFile( 37 cri.PushFile(
37 os.path.join(os.path.dirname(__file__), 'chromeos_login_ext'), '/tmp/') 38 os.path.join(os.path.dirname(__file__), 'chromeos_login_ext'), '/tmp/')
38 cri.GetCmdOutput(['chown', '-R', 'chronos:chronos', self._login_ext_dir]) 39 cri.GetCmdOutput(['chown', '-R', 'chronos:chronos', self._login_ext_dir])
40 # Push the automation provider extension to the device.
nduca 2012/12/07 19:23:47 looks like you forgot to make this file do the ite
zel 2012/12/12 21:03:42 iteration? what iteration?
41 # TODO(zelidrag): Make a call if this component should live in rootfs
42 # of CrOS test images or be pushed over the wire this way.
43 logging.info('Copying automation provider extension to the device')
44 cri.PushFile(
45 os.path.join(os.path.dirname(__file__), '..', '..', 'telemetry_auto',
46 'data', 'auto_provider'), '/tmp/')
47 cri.GetCmdOutput(['chown', '-R', 'chronos:chronos', self._auto_ext_dir])
39 48
40 # Restart Chrome with the login extension and remote debugging. 49 # Restart Chrome with the login extension and remote debugging.
41 logging.info('Restarting Chrome with flags and login') 50 logging.info('Restarting Chrome with flags and login')
42 args = ['dbus-send', '--system', '--type=method_call', 51 args = ['dbus-send', '--system', '--type=method_call',
43 '--dest=org.chromium.SessionManager', 52 '--dest=org.chromium.SessionManager',
44 '/org/chromium/SessionManager', 53 '/org/chromium/SessionManager',
45 'org.chromium.SessionManagerInterface.EnableChromeTesting', 54 'org.chromium.SessionManagerInterface.EnableChromeTesting',
46 'boolean:true', 55 'boolean:true',
47 'array:string:"%s"' % '","'.join(self.GetBrowserStartupArgs())] 56 'array:string:"%s"' % '","'.join(self.GetBrowserStartupArgs())]
48 cri.GetCmdOutput(args) 57 cri.GetCmdOutput(args)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 args.extend([ 90 args.extend([
82 '--allow-webui-compositing', 91 '--allow-webui-compositing',
83 '--aura-host-window-use-fullscreen', 92 '--aura-host-window-use-fullscreen',
84 '--enable-smooth-scrolling', 93 '--enable-smooth-scrolling',
85 '--enable-threaded-compositing', 94 '--enable-threaded-compositing',
86 '--enable-per-tile-painting', 95 '--enable-per-tile-painting',
87 '--enable-gpu-sandboxing', 96 '--enable-gpu-sandboxing',
88 '--force-compositing-mode', 97 '--force-compositing-mode',
89 '--remote-debugging-port=%i' % self._remote_debugging_port, 98 '--remote-debugging-port=%i' % self._remote_debugging_port,
90 '--auth-ext-path=%s' % self._login_ext_dir, 99 '--auth-ext-path=%s' % self._login_ext_dir,
100 '--load-component-extension=%s' % self._auto_ext_dir,
91 '--start-maximized']) 101 '--start-maximized'])
92 102
93 return args 103 return args
94 104
95 def __del__(self): 105 def __del__(self):
96 self.Close() 106 self.Close()
97 107
98 def Close(self): 108 def Close(self):
99 self._RestartUI() # Logs out. 109 self._RestartUI() # Logs out.
100 110
101 if self._forwarder: 111 if self._forwarder:
102 self._forwarder.Close() 112 self._forwarder.Close()
103 self._forwarder = None 113 self._forwarder = None
104 114
105 if self._login_ext_dir: 115 if self._login_ext_dir:
106 self._cri.RmRF(self._login_ext_dir) 116 self._cri.RmRF(self._login_ext_dir)
107 self._login_ext_dir = None 117 self._login_ext_dir = None
108 118
119 if self._auto_ext_dir:
120 self._cri.RmRF(self._auto_ext_dir)
121 self._auto_ext_dir = None
122
109 self._cri = None 123 self._cri = None
110 124
111 def IsBrowserRunning(self): 125 def IsBrowserRunning(self):
112 # On ChromeOS, there should always be a browser running. 126 # On ChromeOS, there should always be a browser running.
113 for _, process in self._cri.ListProcesses(): 127 for _, process in self._cri.ListProcesses():
114 if process.startswith('/opt/google/chrome/chrome'): 128 if process.startswith('/opt/google/chrome/chrome'):
115 return True 129 return True
116 return False 130 return False
117 131
118 def CreateForwarder(self, *ports): 132 def CreateForwarder(self, *ports):
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 174
161 @property 175 @property
162 def url(self): 176 def url(self):
163 assert self._proc 177 assert self._proc
164 return 'http://localhost:%i' % self._host_port 178 return 'http://localhost:%i' % self._host_port
165 179
166 def Close(self): 180 def Close(self):
167 if self._proc: 181 if self._proc:
168 self._proc.kill() 182 self._proc.kill()
169 self._proc = None 183 self._proc = None
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698