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

Side by Side Diff: telemetry/telemetry/internal/backends/chrome/cros_browser_backend.py

Issue 3002793002: [Telemetry] fix run_benchmark crash on CrOS (Closed)
Patch Set: Created 3 years, 4 months 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
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 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 4
5 import logging 5 import logging
6 import os 6 import os
7 7
8 from telemetry.core import exceptions 8 from telemetry.core import exceptions
9 from telemetry.core import util 9 from telemetry.core import util
10 from telemetry import decorators 10 from telemetry import decorators
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 '--dest=org.chromium.SessionManager', 160 '--dest=org.chromium.SessionManager',
161 '/org/chromium/SessionManager', 161 '/org/chromium/SessionManager',
162 'org.chromium.SessionManagerInterface.EnableChromeTesting', 162 'org.chromium.SessionManagerInterface.EnableChromeTesting',
163 'boolean:true', 163 'boolean:true',
164 'array:string:"%s"' % ','.join(startup_args)] 164 'array:string:"%s"' % ','.join(startup_args)]
165 logging.info(' '.join(args)) 165 logging.info(' '.join(args))
166 self._cri.RunCmdOnDevice(args) 166 self._cri.RunCmdOnDevice(args)
167 167
168 # Wait for new chrome and oobe. 168 # Wait for new chrome and oobe.
169 py_utils.WaitFor(lambda: pid != self.pid, 15) 169 py_utils.WaitFor(lambda: pid != self.pid, 15)
170 self._WaitForBrowserToComeUp() 170 # Disable tracing for the login-screen instance of Chrome, otherwise
171 # tracing on the instance of Chrome running the benchmark will fail.
172 self._WaitForBrowserToComeUp(enable_tracing=False)
171 py_utils.WaitFor(lambda: self.oobe_exists, 30) 173 py_utils.WaitFor(lambda: self.oobe_exists, 30)
172 174
173 if self.browser_options.auto_login: 175 if self.browser_options.auto_login:
174 if self._is_guest: 176 if self._is_guest:
175 pid = self.pid 177 pid = self.pid
176 self.oobe.NavigateGuestLogin() 178 self.oobe.NavigateGuestLogin()
177 # Guest browsing shuts down the current browser and launches an 179 # Guest browsing shuts down the current browser and launches an
178 # incognito browser in a separate process, which we need to wait for. 180 # incognito browser in a separate process, which we need to wait for.
179 try: 181 try:
180 # TODO(achuith): Reduce this timeout to 15 sec after crbug.com/631640 182 # TODO(achuith): Reduce this timeout to 15 sec after crbug.com/631640
181 # is resolved. 183 # is resolved.
182 py_utils.WaitFor(lambda: pid != self.pid, 60) 184 py_utils.WaitFor(lambda: pid != self.pid, 60)
183 except py_utils.TimeoutException: 185 except py_utils.TimeoutException:
184 self._RaiseOnLoginFailure( 186 self._RaiseOnLoginFailure(
185 'Failed to restart browser in guest mode (pid %d).' % pid) 187 'Failed to restart browser in guest mode (pid %d).' % pid)
186 188
187 elif self.browser_options.gaia_login: 189 elif self.browser_options.gaia_login:
188 self.oobe.NavigateGaiaLogin(self._username, self._password) 190 self.oobe.NavigateGaiaLogin(self._username, self._password)
189 else: 191 else:
190 self.oobe.NavigateFakeLogin( 192 self.oobe.NavigateFakeLogin(
191 self._username, self._password, self._gaia_id, 193 self._username, self._password, self._gaia_id,
192 not self.browser_options.disable_gaia_services) 194 not self.browser_options.disable_gaia_services)
193 195
194 try: 196 try:
195 self._WaitForLogin() 197 self._WaitForLogin(enable_tracing=True)
196 except py_utils.TimeoutException: 198 except py_utils.TimeoutException:
197 self._RaiseOnLoginFailure('Timed out going through login screen. ' 199 self._RaiseOnLoginFailure('Timed out going through login screen. '
198 + self._GetLoginStatus()) 200 + self._GetLoginStatus())
199 201
200 logging.info('Browser is up!') 202 logging.info('Browser is up!')
201 203
202 def Background(self): 204 def Background(self):
203 raise NotImplementedError 205 raise NotImplementedError
204 206
205 def Close(self): 207 def Close(self):
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 status += 'Browser didn\'t launch. ' 285 status += 'Browser didn\'t launch. '
284 if self.oobe_exists: 286 if self.oobe_exists:
285 status += 'OOBE not dismissed.' 287 status += 'OOBE not dismissed.'
286 return status 288 return status
287 289
288 def _IsLoggedIn(self): 290 def _IsLoggedIn(self):
289 """Returns True if cryptohome has mounted, the browser is 291 """Returns True if cryptohome has mounted, the browser is
290 responsive to devtools requests, and the oobe has been dismissed.""" 292 responsive to devtools requests, and the oobe has been dismissed."""
291 return not self._GetLoginStatus() 293 return not self._GetLoginStatus()
292 294
293 def _WaitForLogin(self): 295 def _WaitForLogin(self, enable_tracing):
294 # Wait for cryptohome to mount. 296 # Wait for cryptohome to mount.
295 py_utils.WaitFor(self._IsLoggedIn, 900) 297 py_utils.WaitFor(self._IsLoggedIn, 900)
296 298
297 # For incognito mode, the session manager actually relaunches chrome with 299 # For incognito mode, the session manager actually relaunches chrome with
298 # new arguments, so we have to wait for the browser to come up. 300 # new arguments, so we have to wait for the browser to come up.
299 self._WaitForBrowserToComeUp() 301 self._WaitForBrowserToComeUp(enable_tracing)
achuithb 2017/08/17 15:29:26 I think we may be able to get rid of this call, bu
300 302
301 # Wait for extensions to load. 303 # Wait for extensions to load.
302 if self._supports_extensions: 304 if self._supports_extensions:
303 self._WaitForExtensionsToLoad() 305 self._WaitForExtensionsToLoad()
304 306
305 def _RaiseOnLoginFailure(self, error): 307 def _RaiseOnLoginFailure(self, error):
306 if self._platform_backend.CanTakeScreenshot(): 308 if self._platform_backend.CanTakeScreenshot():
307 self._cri.TakeScreenshotWithPrefix('login-screen') 309 self._cri.TakeScreenshotWithPrefix('login-screen')
308 raise exceptions.LoginException(error) 310 raise exceptions.LoginException(error)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698