Commit 93dc10b6 authored by emaxx's avatar emaxx Committed by Commit bot

Reland of Clear the login webview when SAML flow is canceled (original CL crrev.com/1988113004).

The original CL was later reverted (CL crrev.com/2068953003) due to
frequent failures of the SAMLPolicyTest.SAMLInterstitialNext test.

This follow-up CL should resolve the tests flakiness.

The problem with the original CL was that it could introduce raising the
"ready" event too early, so that the test code could start working when
the webview was still pointing to the blank page.

BUG=613245,620353
CQ_INCLUDE_TRYBOTS=tryserver.chromium.linux:closure_compilation

Review-Url: https://codereview.chromium.org/2082533002
Cr-Commit-Position: refs/heads/master@{#400703}
parent 4b466fa4
...@@ -557,6 +557,13 @@ login.createScreen('GaiaSigninScreen', 'gaia-signin', function() { ...@@ -557,6 +557,13 @@ login.createScreen('GaiaSigninScreen', 'gaia-signin', function() {
* @private * @private
*/ */
loadAuthExtension: function(data) { loadAuthExtension: function(data) {
// Redirect the webview to the blank page in order to stop the SAML IdP
// page from working in a background (see crbug.com/613245).
if (this.screenMode_ == ScreenMode.DEFAULT &&
data.screenMode != ScreenMode.DEFAULT) {
this.gaiaAuthHost_.resetWebview();
}
this.screenMode = data.screenMode; this.screenMode = data.screenMode;
this.email = ''; this.email = '';
this.authCompleted_ = false; this.authCompleted_ = false;
...@@ -923,7 +930,7 @@ login.createScreen('GaiaSigninScreen', 'gaia-signin', function() { ...@@ -923,7 +930,7 @@ login.createScreen('GaiaSigninScreen', 'gaia-signin', function() {
*/ */
reset: function(takeFocus, forceOnline) { reset: function(takeFocus, forceOnline) {
// Reload and show the sign-in UI if needed. // Reload and show the sign-in UI if needed.
this.gaiaAuthHost_.resetStates_(); this.gaiaAuthHost_.resetStates();
if (takeFocus) { if (takeFocus) {
if (!forceOnline && this.isOffline()) { if (!forceOnline && this.isOffline()) {
// Show 'Cancel' button to allow user to return to the main screen // Show 'Cancel' button to allow user to return to the main screen
......
...@@ -32,6 +32,7 @@ cr.define('cr.login', function() { ...@@ -32,6 +32,7 @@ cr.define('cr.login', function() {
var SERVICE_ID = 'chromeoslogin'; var SERVICE_ID = 'chromeoslogin';
var EMBEDDED_SETUP_CHROMEOS_ENDPOINT = 'embedded/setup/chromeos'; var EMBEDDED_SETUP_CHROMEOS_ENDPOINT = 'embedded/setup/chromeos';
var SAML_REDIRECTION_PATH = 'samlredirect'; var SAML_REDIRECTION_PATH = 'samlredirect';
var BLANK_PAGE_URL = 'about:blank';
/** /**
* The source URL parameter for the constrained signin flow. * The source URL parameter for the constrained signin flow.
...@@ -196,7 +197,7 @@ cr.define('cr.login', function() { ...@@ -196,7 +197,7 @@ cr.define('cr.login', function() {
* Reinitializes authentication parameters so that a failed login attempt * Reinitializes authentication parameters so that a failed login attempt
* would not result in an infinite loop. * would not result in an infinite loop.
*/ */
Authenticator.prototype.resetStates_ = function() { Authenticator.prototype.resetStates = function() {
this.isLoaded_ = false; this.isLoaded_ = false;
this.email_ = null; this.email_ = null;
this.gaiaId_ = null; this.gaiaId_ = null;
...@@ -215,6 +216,14 @@ cr.define('cr.login', function() { ...@@ -215,6 +216,14 @@ cr.define('cr.login', function() {
this.videoEnabled = false; this.videoEnabled = false;
}; };
/**
* Resets the webview to the blank page.
*/
Authenticator.prototype.resetWebview = function() {
if (this.webview_.src && this.webview_.src != BLANK_PAGE_URL)
this.webview_.src = BLANK_PAGE_URL;
};
/** /**
* Loads the authenticator component with the given parameters. * Loads the authenticator component with the given parameters.
* @param {AuthMode} authMode Authorization mode. * @param {AuthMode} authMode Authorization mode.
...@@ -222,7 +231,7 @@ cr.define('cr.login', function() { ...@@ -222,7 +231,7 @@ cr.define('cr.login', function() {
*/ */
Authenticator.prototype.load = function(authMode, data) { Authenticator.prototype.load = function(authMode, data) {
this.authMode = authMode; this.authMode = authMode;
this.resetStates_(); this.resetStates();
// gaiaUrl parameter is used for testing. Once defined, it is never changed. // gaiaUrl parameter is used for testing. Once defined, it is never changed.
this.idpOrigin_ = data.gaiaUrl || IDP_ORIGIN; this.idpOrigin_ = data.gaiaUrl || IDP_ORIGIN;
this.continueUrl_ = data.continueUrl || CONTINUE_URL; this.continueUrl_ = data.continueUrl || CONTINUE_URL;
...@@ -270,7 +279,7 @@ cr.define('cr.login', function() { ...@@ -270,7 +279,7 @@ cr.define('cr.login', function() {
* Reloads the authenticator component. * Reloads the authenticator component.
*/ */
Authenticator.prototype.reload = function() { Authenticator.prototype.reload = function() {
this.resetStates_(); this.resetStates();
this.webview_.src = this.reloadUrl_; this.webview_.src = this.reloadUrl_;
this.isLoaded_ = true; this.isLoaded_ = true;
}; };
...@@ -703,7 +712,7 @@ cr.define('cr.login', function() { ...@@ -703,7 +712,7 @@ cr.define('cr.login', function() {
gapsCookie: this.newGapsCookie_ || this.gapsCookie_ || '', gapsCookie: this.newGapsCookie_ || this.gapsCookie_ || '',
} }
})); }));
this.resetStates_(); this.resetStates();
}; };
/** /**
...@@ -786,6 +795,8 @@ cr.define('cr.login', function() { ...@@ -786,6 +795,8 @@ cr.define('cr.login', function() {
this.fireReadyEvent_(); this.fireReadyEvent_();
// Focus webview after dispatching event when webview is already visible. // Focus webview after dispatching event when webview is already visible.
this.webview_.focus(); this.webview_.focus();
} else if (currentUrl == BLANK_PAGE_URL) {
this.fireReadyEvent_();
} }
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment