| 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 import logging | 5 import logging |
| 6 | 6 |
| 7 from telemetry.core import exceptions | 7 from telemetry.core import exceptions |
| 8 from telemetry.core import util | 8 from telemetry.core import util |
| 9 from telemetry.core import web_contents | 9 from telemetry.core import web_contents |
| 10 | 10 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 67 |
| 68 # TODO(resetswitch): Move UI specifics out of this util. crbug/486904 | 68 # TODO(resetswitch): Move UI specifics out of this util. crbug/486904 |
| 69 self.WaitForJavaScriptExpression(""" | 69 self.WaitForJavaScriptExpression(""" |
| 70 document.getElementById('oauth-enrollment').classList.contains( | 70 document.getElementById('oauth-enrollment').classList.contains( |
| 71 'oauth-enroll-state-success')""", 30) | 71 'oauth-enroll-state-success')""", 30) |
| 72 self._ExecuteOobeApi('Oobe.enterpriseEnrollmentDone') | 72 self._ExecuteOobeApi('Oobe.enterpriseEnrollmentDone') |
| 73 | 73 |
| 74 def NavigateGaiaLogin(self, username, password): | 74 def NavigateGaiaLogin(self, username, password): |
| 75 """Logs in using the GAIA webview or IFrame, whichever is | 75 """Logs in using the GAIA webview or IFrame, whichever is |
| 76 present.""" | 76 present.""" |
| 77 self._ExecuteOobeApi('Oobe.skipToLoginForTesting') |
| 77 def _GetGaiaFunction(): | 78 def _GetGaiaFunction(): |
| 78 self._ExecuteOobeApi('Oobe.showAddUserForTesting') | 79 self._ExecuteOobeApi('Oobe.showAddUserForTesting') |
| 79 if self._GaiaIFrameContext() is not None: | 80 if self._GaiaIFrameContext() is not None: |
| 80 return Oobe._NavigateIFrameLogin | 81 return Oobe._NavigateIFrameLogin |
| 81 elif self._GaiaWebViewContext() is not None: | 82 elif self._GaiaWebViewContext() is not None: |
| 82 return Oobe._NavigateWebViewLogin | 83 return Oobe._NavigateWebViewLogin |
| 83 return None | 84 return None |
| 84 util.WaitFor(_GetGaiaFunction, 20)(self, username, password) | 85 util.WaitFor(_GetGaiaFunction, 20)(self, username, password) |
| 85 | 86 |
| 86 def _NavigateIFrameLogin(self, username, password): | 87 def _NavigateIFrameLogin(self, username, password): |
| (...skipping 23 matching lines...) Expand all Loading... |
| 110 gaia_webview_context.EvaluateJavaScript(""" | 111 gaia_webview_context.EvaluateJavaScript(""" |
| 111 document.getElementById('%s').value='%s'; | 112 document.getElementById('%s').value='%s'; |
| 112 document.getElementById('next').click()""" | 113 document.getElementById('next').click()""" |
| 113 % (field, value)) | 114 % (field, value)) |
| 114 | 115 |
| 115 def _WaitForField(self, field_id): | 116 def _WaitForField(self, field_id): |
| 116 gaia_webview_context = util.WaitFor(self._GaiaWebViewContext, 5) | 117 gaia_webview_context = util.WaitFor(self._GaiaWebViewContext, 5) |
| 117 util.WaitFor(gaia_webview_context.HasReachedQuiescence, 20) | 118 util.WaitFor(gaia_webview_context.HasReachedQuiescence, 20) |
| 118 gaia_webview_context.WaitForJavaScriptExpression( | 119 gaia_webview_context.WaitForJavaScriptExpression( |
| 119 "document.getElementById('%s') != null" % field_id, 20) | 120 "document.getElementById('%s') != null" % field_id, 20) |
| OLD | NEW |