| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 from page_sets.login_helpers import login_utils | 5 from page_sets.login_helpers import login_utils |
| 6 from telemetry.core import util | 6 from telemetry.core import util |
| 7 from telemetry.page import action_runner as action_runner_module | 7 from telemetry.page import action_runner as action_runner_module |
| 8 | 8 |
| 9 | 9 |
| 10 def GetGaiaContext(tab): | 10 def GetGaiaContext(tab): |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 action_runner.Navigate('chrome://chrome-signin') | 38 action_runner.Navigate('chrome://chrome-signin') |
| 39 | 39 |
| 40 # Get the Gaia webview context within the sign in extension to create a Gaia | 40 # Get the Gaia webview context within the sign in extension to create a Gaia |
| 41 # action_runner. The action runner will then execute JS in the Gaia context. | 41 # action_runner. The action runner will then execute JS in the Gaia context. |
| 42 gaia_context = util.WaitFor(lambda: GetGaiaContext(action_runner.tab), 5) | 42 gaia_context = util.WaitFor(lambda: GetGaiaContext(action_runner.tab), 5) |
| 43 if not gaia_context: | 43 if not gaia_context: |
| 44 raise RuntimeError('Can not find GAIA webview context for sign in.') | 44 raise RuntimeError('Can not find GAIA webview context for sign in.') |
| 45 gaia_action_runner = action_runner_module.ActionRunner(gaia_context) | 45 gaia_action_runner = action_runner_module.ActionRunner(gaia_context) |
| 46 | 46 |
| 47 new_flow = gaia_action_runner.EvaluateJavaScript2( | 47 new_flow = gaia_action_runner.EvaluateJavaScript( |
| 48 'document.querySelector("#gaia_firsform") != null') | 48 'document.querySelector("#gaia_firsform") != null') |
| 49 gaia_form_id = 'gaia_firstform' if new_flow else 'gaia_loginform' | 49 gaia_form_id = 'gaia_firstform' if new_flow else 'gaia_loginform' |
| 50 login_utils.InputForm(gaia_action_runner, account_name, input_id='Email', | 50 login_utils.InputForm(gaia_action_runner, account_name, input_id='Email', |
| 51 form_id=gaia_form_id) | 51 form_id=gaia_form_id) |
| 52 if new_flow: | 52 if new_flow: |
| 53 gaia_action_runner.ClickElement(selector='#%s #next' % gaia_form_id) | 53 gaia_action_runner.ClickElement(selector='#%s #next' % gaia_form_id) |
| 54 login_utils.InputForm(gaia_action_runner, password, input_id='Passwd', | 54 login_utils.InputForm(gaia_action_runner, password, input_id='Passwd', |
| 55 form_id=gaia_form_id) | 55 form_id=gaia_form_id) |
| 56 gaia_action_runner.ClickElement(selector='#signIn') | 56 gaia_action_runner.ClickElement(selector='#signIn') |
| 57 action_runner.WaitForNavigate() | 57 action_runner.WaitForNavigate() |
| OLD | NEW |