| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "ash/shell.h" | 5 #include "ash/shell.h" |
| 6 #include "ash/system/tray/system_tray.h" | 6 #include "ash/system/tray/system_tray.h" |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/json/json_file_value_serializer.h" | 8 #include "base/json/json_file_value_serializer.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 const std::string& password) { | 137 const std::string& password) { |
| 138 // Note the input elements must match gaia_auth/offline.html. | 138 // Note the input elements must match gaia_auth/offline.html. |
| 139 JSExpect("document.querySelector('#offline-gaia').hidden"); | 139 JSExpect("document.querySelector('#offline-gaia').hidden"); |
| 140 JSExpect("!document.querySelector('#signin-frame').hidden"); | 140 JSExpect("!document.querySelector('#signin-frame').hidden"); |
| 141 std::string js = | 141 std::string js = |
| 142 "(function(){" | 142 "(function(){" |
| 143 "document.getElementsByName('email')[0].value = '$Email';" | 143 "document.getElementsByName('email')[0].value = '$Email';" |
| 144 "document.getElementsByName('password')[0].value = '$Password';" | 144 "document.getElementsByName('password')[0].value = '$Password';" |
| 145 "document.getElementById('submit-button').click();" | 145 "document.getElementById('submit-button').click();" |
| 146 "})();"; | 146 "})();"; |
| 147 ReplaceSubstringsAfterOffset(&js, 0, "$Email", user_email); | 147 base::ReplaceSubstringsAfterOffset(&js, 0, "$Email", user_email); |
| 148 ReplaceSubstringsAfterOffset(&js, 0, "$Password", password); | 148 base::ReplaceSubstringsAfterOffset(&js, 0, "$Password", password); |
| 149 ExecuteJsInGaiaAuthFrame(js); | 149 ExecuteJsInGaiaAuthFrame(js); |
| 150 } | 150 } |
| 151 | 151 |
| 152 void SubmitGaiaAuthOfflineForm(const std::string& user_email, | 152 void SubmitGaiaAuthOfflineForm(const std::string& user_email, |
| 153 const std::string& password) { | 153 const std::string& password) { |
| 154 const std::string animated_pages = | 154 const std::string animated_pages = |
| 155 "document.querySelector('#offline-gaia /deep/ " | 155 "document.querySelector('#offline-gaia /deep/ " |
| 156 "#animatedPages')"; | 156 "#animatedPages')"; |
| 157 const std::string email_input = | 157 const std::string email_input = |
| 158 "document.querySelector('#offline-gaia /deep/ #emailInput')"; | 158 "document.querySelector('#offline-gaia /deep/ #emailInput')"; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 171 JSExpect("document.querySelector('#signin-frame').hidden"); | 171 JSExpect("document.querySelector('#signin-frame').hidden"); |
| 172 const std::string js = | 172 const std::string js = |
| 173 animated_pages + | 173 animated_pages + |
| 174 ".addEventListener('neon-animation-finish'," | 174 ".addEventListener('neon-animation-finish'," |
| 175 "function() {" | 175 "function() {" |
| 176 "window.domAutomationController.setAutomationId(0);" | 176 "window.domAutomationController.setAutomationId(0);" |
| 177 "window.domAutomationController.send('switchToPassword');" | 177 "window.domAutomationController.send('switchToPassword');" |
| 178 "})"; | 178 "})"; |
| 179 ASSERT_TRUE(content::ExecuteScript(web_contents(), js)); | 179 ASSERT_TRUE(content::ExecuteScript(web_contents(), js)); |
| 180 std::string set_email = email_input + ".value = '$Email'"; | 180 std::string set_email = email_input + ".value = '$Email'"; |
| 181 ReplaceSubstringsAfterOffset(&set_email, 0, "$Email", user_email); | 181 base::ReplaceSubstringsAfterOffset(&set_email, 0, "$Email", user_email); |
| 182 ASSERT_TRUE(content::ExecuteScript(web_contents(), set_email)); | 182 ASSERT_TRUE(content::ExecuteScript(web_contents(), set_email)); |
| 183 ASSERT_TRUE(content::ExecuteScript(web_contents(), | 183 ASSERT_TRUE(content::ExecuteScript(web_contents(), |
| 184 email_next_button + ".fire('tap')")); | 184 email_next_button + ".fire('tap')")); |
| 185 std::string message; | 185 std::string message; |
| 186 do { | 186 do { |
| 187 ASSERT_TRUE(message_queue.WaitForMessage(&message)); | 187 ASSERT_TRUE(message_queue.WaitForMessage(&message)); |
| 188 } while (message != "\"switchToPassword\""); | 188 } while (message != "\"switchToPassword\""); |
| 189 | 189 |
| 190 std::string set_password = password_input + ".value = '$Password'"; | 190 std::string set_password = password_input + ".value = '$Password'"; |
| 191 ReplaceSubstringsAfterOffset(&set_password, 0, "$Password", password); | 191 base::ReplaceSubstringsAfterOffset(&set_password, 0, "$Password", password); |
| 192 ASSERT_TRUE(content::ExecuteScript(web_contents(), set_password)); | 192 ASSERT_TRUE(content::ExecuteScript(web_contents(), set_password)); |
| 193 ASSERT_TRUE(content::ExecuteScript(web_contents(), | 193 ASSERT_TRUE(content::ExecuteScript(web_contents(), |
| 194 password_next_button + ".fire('tap')")); | 194 password_next_button + ".fire('tap')")); |
| 195 } | 195 } |
| 196 | 196 |
| 197 void PrepareOfflineLogin() { | 197 void PrepareOfflineLogin() { |
| 198 bool show_user; | 198 bool show_user; |
| 199 ASSERT_TRUE(chromeos::CrosSettings::Get()->GetBoolean( | 199 ASSERT_TRUE(chromeos::CrosSettings::Get()->GetBoolean( |
| 200 chromeos::kAccountsPrefShowUserNamesOnSignIn, &show_user)); | 200 chromeos::kAccountsPrefShowUserNamesOnSignIn, &show_user)); |
| 201 ASSERT_FALSE(show_user); | 201 ASSERT_FALSE(show_user); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 content::WindowedNotificationObserver session_start_waiter( | 338 content::WindowedNotificationObserver session_start_waiter( |
| 339 chrome::NOTIFICATION_SESSION_STARTED, | 339 chrome::NOTIFICATION_SESSION_STARTED, |
| 340 content::NotificationService::AllSources()); | 340 content::NotificationService::AllSources()); |
| 341 SubmitGaiaAuthOfflineForm(kTestUser, kPassword); | 341 SubmitGaiaAuthOfflineForm(kTestUser, kPassword); |
| 342 session_start_waiter.Wait(); | 342 session_start_waiter.Wait(); |
| 343 | 343 |
| 344 TestSystemTrayIsVisible(); | 344 TestSystemTrayIsVisible(); |
| 345 } | 345 } |
| 346 | 346 |
| 347 } // namespace | 347 } // namespace |
| OLD | NEW |