| Index: tools/telemetry/telemetry/core/backends/chrome/cros_browser_backend.py
|
| diff --git a/tools/telemetry/telemetry/core/backends/chrome/cros_browser_backend.py b/tools/telemetry/telemetry/core/backends/chrome/cros_browser_backend.py
|
| index ce7890c1a0d63a3b8a4afaca5506106aea1ccc70..5db7a5bb7bdad55f10652af2358127bca70484a3 100644
|
| --- a/tools/telemetry/telemetry/core/backends/chrome/cros_browser_backend.py
|
| +++ b/tools/telemetry/telemetry/core/backends/chrome/cros_browser_backend.py
|
| @@ -215,6 +215,8 @@ class CrOSBrowserBackend(chrome_browser_backend.ChromeBrowserBackend):
|
| # incognito browser in a separate process, which we need to wait for.
|
| util.WaitFor(lambda: pid != self.pid, 10)
|
| self._WaitForBrowserToComeUp()
|
| + elif self.browser_options.gaia_login:
|
| + self._NavigateGaiaLogin()
|
| else:
|
| self._NavigateFakeLogin()
|
|
|
| @@ -312,6 +314,20 @@ class CrOSBrowserBackend(chrome_browser_backend.ChromeBrowserBackend):
|
| exceptions.BrowserConnectionGoneException):
|
| pass
|
|
|
| + def _GaiaLoginContext(self):
|
| + oobe = self.oobe
|
| + # TODO(achuith): Implement an api in the oobe instead of calling
|
| + # chrome.send.
|
| + oobe.ExecuteJavaScript("chrome.send('addUser');")
|
| + for gaia_context in range(15):
|
| + try:
|
| + if oobe.EvaluateJavaScriptInContext(
|
| + "document.getElementById('Email') != null", gaia_context):
|
| + return gaia_context
|
| + except exceptions.EvaluateException:
|
| + pass
|
| + return None
|
| +
|
| def _NavigateGuestLogin(self):
|
| """Navigates through oobe login screen as guest."""
|
| logging.info('Logging in as guest')
|
| @@ -344,6 +360,22 @@ class CrOSBrowserBackend(chrome_browser_backend.ChromeBrowserBackend):
|
| % (self.browser_options.username, self.browser_options.password))
|
| self._WaitForLogin()
|
|
|
| + def _NavigateGaiaLogin(self):
|
| + """Logs into the GAIA service with provided credentials."""
|
| + # TODO(achuith): Fake gaia service with a python server.
|
| + self._WaitForSigninScreen()
|
| + gaia_context = util.WaitFor(self._GaiaLoginContext, timeout=10)
|
| + oobe = self.oobe
|
| + oobe.ExecuteJavaScriptInContext(
|
| + "document.getElementById('Email').value='%s';"
|
| + % self.browser_options.username, gaia_context)
|
| + oobe.ExecuteJavaScriptInContext(
|
| + "document.getElementById('Passwd').value='%s';"
|
| + % self.browser_options.password, gaia_context)
|
| + oobe.ExecuteJavaScriptInContext(
|
| + "document.getElementById('signIn').click();", gaia_context)
|
| + self._WaitForLogin()
|
| +
|
| def _WaitForLogin(self):
|
| try:
|
| util.WaitFor(self._IsLoggedIn, 60)
|
|
|