Index: chrome/browser/resources/chromeos/login/login_common.js |
diff --git a/chrome/browser/resources/chromeos/login/login_common.js b/chrome/browser/resources/chromeos/login/login_common.js |
index cd48d356eadd9a6a01519f3fa5ad08a51899418e..4f7172c651b67f15ebed101ee7b4dd5b7c61cf09 100644 |
--- a/chrome/browser/resources/chromeos/login/login_common.js |
+++ b/chrome/browser/resources/chromeos/login/login_common.js |
@@ -293,17 +293,46 @@ cr.define('cr.ui', function() { |
* Login for telemetry. |
* @param {string} username Login username. |
* @param {string} password Login password. |
- */ |
- Oobe.loginForTesting = function(username, password, gaia_id) { |
- Oobe.disableSigninUI(); |
- chrome.send('skipToLoginForTesting', [username]); |
+ * @param {boolean} enterpriseEnroll Login as an enterprise enrollment? |
+ */ |
+ Oobe.loginForTesting = function(username, password, gaia_id, |
+ enterpriseEnroll = false) { |
+ // Helper method that runs |fn| after |screenName| is visible. |
+ function waitForOobeScreen(screenName, fn) { |
+ if (Oobe.getInstance().currentScreen.id === screenName) { |
+ fn(); |
+ } else { |
+ $('oobe').addEventListener('screenchanged', function handler(e) { |
+ if (e.detail == screenName) { |
+ $('oobe').removeEventListener('screenchanged', handler); |
+ fn(); |
+ } |
+ }); |
+ } |
+ } |
+ |
if (!gaia_id) { |
- /* TODO (alemate): Remove this backward compatibility hack when |
- as soon as all telemetry tests will pass gaia_id directly. |
- */ |
+ // TODO (alemate): Remove this backward compatibility hack when |
+ // as soon as all telemetry tests will pass gaia_id directly. |
gaia_id = '12345'; |
} |
- chrome.send('completeLogin', [gaia_id, username, password, false]); |
+ |
+ Oobe.disableSigninUI(); |
+ chrome.send('skipToLoginForTesting', [username]); |
+ |
+ if (!enterpriseEnroll) { |
+ chrome.send('completeLogin', [gaia_id, username, password, false]); |
+ } else { |
+ waitForOobeScreen('gaia-signin', function() { |
+ chrome.send('toggleEnrollmentScreen'); |
+ chrome.send('toggleFakeEnrollment'); |
+ }); |
+ |
+ waitForOobeScreen('oauth-enrollment', function() { |
+ chrome.send('oauthEnrollCompleteLogin', [username, 'authcode']); |
+ chrome.send('completeLogin', ['12345', username, password, false]); |
+ }); |
+ } |
}; |
/** |