summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxiyuan <xiyuan@chromium.org>2015-04-10 06:59:38 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-10 14:00:03 +0000
commit46f4d35e2e7c8f4bc2d6f1cd7dcd230f60874db5 (patch)
tree66f14ec132505780b65f86bc1149062fb7319876
parentd562a7288aa394e1996cd09f603e665ae52f9386 (diff)
downloadchromium_src-46f4d35e2e7c8f4bc2d6f1cd7dcd230f60874db5.zip
chromium_src-46f4d35e2e7c8f4bc2d6f1cd7dcd230f60874db5.tar.gz
chromium_src-46f4d35e2e7c8f4bc2d6f1cd7dcd230f60874db5.tar.bz2
cros: Replace iframe load event with explicit postMessage.
- Replace iframe load event with a 'loginUIDOMContentLoaded' message; - Wait for NOTIFICATION_SESSION_STARTED before submitting login form in GaiaAuthOffline; BUG=475516 Review URL: https://codereview.chromium.org/1072223002 Cr-Commit-Position: refs/heads/master@{#324626}
-rw-r--r--chrome/browser/chromeos/login/login_browsertest.cc32
-rw-r--r--chrome/browser/resources/gaia_auth/main.js1
-rw-r--r--chrome/browser/resources/gaia_auth/offline.js1
-rw-r--r--chrome/browser/resources/gaia_auth_host/gaia_auth_host.js11
4 files changed, 20 insertions, 25 deletions
diff --git a/chrome/browser/chromeos/login/login_browsertest.cc b/chrome/browser/chromeos/login/login_browsertest.cc
index b4abe68..85880b1 100644
--- a/chrome/browser/chromeos/login/login_browsertest.cc
+++ b/chrome/browser/chromeos/login/login_browsertest.cc
@@ -111,13 +111,13 @@ class LoginTest : public chromeos::LoginManagerTest {
void StartGaiaAuthOffline() {
content::DOMMessageQueue message_queue;
const std::string js = "(function() {"
- "var frame = $('signin-frame');"
- "var onload= function() {"
- "frame.removeEventListener('load', onload);"
- "window.domAutomationController.setAutomationId(0);"
- "window.domAutomationController.send('frameLoaded');"
- "};"
- "frame.addEventListener('load', onload);"
+ "var authenticator = $('gaia-signin').gaiaAuthHost_;"
+ "authenticator.addEventListener('ready',"
+ "function f() {"
+ "authenticator.removeEventListener('ready', f);"
+ "window.domAutomationController.setAutomationId(0);"
+ "window.domAutomationController.send('offlineLoaded');"
+ "});"
"$('error-offline-login-link').onclick();"
"})();";
ASSERT_TRUE(content::ExecuteScript(web_contents(), js));
@@ -125,7 +125,7 @@ class LoginTest : public chromeos::LoginManagerTest {
std::string message;
do {
ASSERT_TRUE(message_queue.WaitForMessage(&message));
- } while (message != "\"frameLoaded\"");
+ } while (message != "\"offlineLoaded\"");
}
void SubmitGaiaAuthOfflineForm(const std::string& user_email,
@@ -222,13 +222,7 @@ IN_PROC_BROWSER_TEST_F(LoginTest, PRE_GaiaAuthOffline) {
chromeos::kAccountsPrefShowUserNamesOnSignIn, false);
}
-#if defined(OS_CHROMEOS)
-// http://crbug.com/475617
-#define MAYBE_GaiaAuthOffline DISABLED_GaiaAuthOffline
-#else
-#define MAYBE_GaiaAuthOffline GaiaAuthOffline
-#endif
-IN_PROC_BROWSER_TEST_F(LoginTest, MAYBE_GaiaAuthOffline) {
+IN_PROC_BROWSER_TEST_F(LoginTest, GaiaAuthOffline) {
bool show_user;
ASSERT_TRUE(chromeos::CrosSettings::Get()->GetBoolean(
chromeos::kAccountsPrefShowUserNamesOnSignIn, &show_user));
@@ -240,11 +234,11 @@ IN_PROC_BROWSER_TEST_F(LoginTest, MAYBE_GaiaAuthOffline) {
user_context.SetKey(chromeos::Key(kPassword));
SetExpectedCredentials(user_context);
- SubmitGaiaAuthOfflineForm(kTestUser, kPassword);
-
- content::WindowedNotificationObserver(
+ content::WindowedNotificationObserver session_start_waiter(
chrome::NOTIFICATION_SESSION_STARTED,
- content::NotificationService::AllSources()).Wait();
+ content::NotificationService::AllSources());
+ SubmitGaiaAuthOfflineForm(kTestUser, kPassword);
+ session_start_waiter.Wait();
TestSystemTrayIsVisible();
}
diff --git a/chrome/browser/resources/gaia_auth/main.js b/chrome/browser/resources/gaia_auth/main.js
index b751687..e00869c 100644
--- a/chrome/browser/resources/gaia_auth/main.js
+++ b/chrome/browser/resources/gaia_auth/main.js
@@ -105,6 +105,7 @@ Authenticator.prototype = {
document.addEventListener('DOMContentLoaded', function() {
window.addEventListener('message', handleInitializeMessage);
+ window.parent.postMessage({'method': 'loginUIDOMContentLoaded'}, '*');
});
},
diff --git a/chrome/browser/resources/gaia_auth/offline.js b/chrome/browser/resources/gaia_auth/offline.js
index dcc153f..aaf6045 100644
--- a/chrome/browser/resources/gaia_auth/offline.js
+++ b/chrome/browser/resources/gaia_auth/offline.js
@@ -83,4 +83,5 @@ function handleInitializeMessage(e) {
document.addEventListener('DOMContentLoaded', function() {
window.addEventListener('message', handleInitializeMessage);
+ window.parent.postMessage({'method': 'loginUIDOMContentLoaded'}, '*');
});
diff --git a/chrome/browser/resources/gaia_auth_host/gaia_auth_host.js b/chrome/browser/resources/gaia_auth_host/gaia_auth_host.js
index cdd3db5..44dcc80 100644
--- a/chrome/browser/resources/gaia_auth_host/gaia_auth_host.js
+++ b/chrome/browser/resources/gaia_auth_host/gaia_auth_host.js
@@ -286,12 +286,6 @@ cr.define('cr.login', function() {
* Reloads the auth extension.
*/
reload: function() {
- var sendParamsOnLoad = function() {
- this.frame_.removeEventListener('load', sendParamsOnLoad);
- this.frame_.contentWindow.postMessage(this.authParams_, AUTH_URL_BASE);
- }.bind(this);
-
- this.frame_.addEventListener('load', sendParamsOnLoad);
this.frame_.src = this.reloadUrl_;
this.authFlow = AuthFlow.GAIA;
},
@@ -342,6 +336,11 @@ cr.define('cr.login', function() {
if (!this.isAuthExtMessage_(e))
return;
+ if (msg.method == 'loginUIDOMContentLoaded') {
+ this.frame_.contentWindow.postMessage(this.authParams_, AUTH_URL_BASE);
+ return;
+ }
+
if (msg.method == 'loginUILoaded') {
cr.dispatchSimpleEvent(this, 'ready');
return;