| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 functools import partial | 5 from functools import partial |
| 6 import logging | 6 import logging |
| 7 | 7 |
| 8 from telemetry.core import exceptions | 8 from telemetry.core import exceptions |
| 9 from telemetry.internal.browser import web_contents | 9 from telemetry.internal.browser import web_contents |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 return None | 30 return None |
| 31 | 31 |
| 32 def _GaiaWebviewContext(self): | 32 def _GaiaWebviewContext(self): |
| 33 webview_contexts = self.GetWebviewContexts() | 33 webview_contexts = self.GetWebviewContexts() |
| 34 if webview_contexts: | 34 if webview_contexts: |
| 35 return webview_contexts[0] | 35 return webview_contexts[0] |
| 36 return None | 36 return None |
| 37 | 37 |
| 38 def _ExecuteOobeApi(self, api, *args): | 38 def _ExecuteOobeApi(self, api, *args): |
| 39 logging.info('Invoking %s' % api) | 39 logging.info('Invoking %s' % api) |
| 40 self.WaitForJavaScriptCondition("typeof Oobe == 'function'", timeout=120) | 40 self.WaitForJavaScriptCondition( |
| 41 "typeof Oobe == 'function' && Oobe.readyForTesting", timeout=120) |
| 41 | 42 |
| 42 if self.EvaluateJavaScript( | 43 if self.EvaluateJavaScript( |
| 43 "typeof {{ @api }} == 'undefined'", api=api): | 44 "typeof {{ @api }} == 'undefined'", api=api): |
| 44 raise exceptions.LoginException('%s js api missing' % api) | 45 raise exceptions.LoginException('%s js api missing' % api) |
| 45 | 46 |
| 46 # Example values: | 47 # Example values: |
| 47 # |api|: 'doLogin' | 48 # |api|: 'doLogin' |
| 48 # |args|: ['username', 'pass', True] | 49 # |args|: ['username', 'pass', True] |
| 49 # Executes: 'doLogin("username", "pass", true)' | 50 # Executes: 'doLogin("username", "pass", true)' |
| 50 self.ExecuteJavaScript('{{ @f }}({{ *args }})', f=api, args=args) | 51 self.ExecuteJavaScript('{{ @f }}({{ *args }})', f=api, args=args) |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 document.getElementById({{ field }}).value= {{ value }}; | 117 document.getElementById({{ field }}).value= {{ value }}; |
| 117 document.getElementById({{ next_field }}).click()""", | 118 document.getElementById({{ next_field }}).click()""", |
| 118 field=field, value=value, next_field=next_field) | 119 field=field, value=value, next_field=next_field) |
| 119 | 120 |
| 120 def _WaitForField(self, field): | 121 def _WaitForField(self, field): |
| 121 gaia_webview_context = py_utils.WaitFor(self._GaiaWebviewContext, 5) | 122 gaia_webview_context = py_utils.WaitFor(self._GaiaWebviewContext, 5) |
| 122 py_utils.WaitFor(gaia_webview_context.HasReachedQuiescence, 20) | 123 py_utils.WaitFor(gaia_webview_context.HasReachedQuiescence, 20) |
| 123 gaia_webview_context.WaitForJavaScriptCondition( | 124 gaia_webview_context.WaitForJavaScriptCondition( |
| 124 "document.getElementById({{ field }}) != null", | 125 "document.getElementById({{ field }}) != null", |
| 125 field=field, timeout=20) | 126 field=field, timeout=20) |
| OLD | NEW |