| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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')"; |
| 159 const std::string email_next_button = | 159 const std::string email_next_button = |
| 160 "document.querySelector('#offline-gaia /deep/ #emailInput " | 160 "document.querySelector('#offline-gaia /deep/ #emailSection " |
| 161 "/deep/ .blue-button')"; | 161 "/deep/ .blue-button')"; |
| 162 const std::string password_input = | 162 const std::string password_input = |
| 163 "document.querySelector('#offline-gaia /deep/ " | 163 "document.querySelector('#offline-gaia /deep/ " |
| 164 "#passwordInput')"; | 164 "#passwordInput')"; |
| 165 const std::string password_next_button = | 165 const std::string password_next_button = |
| 166 "document.querySelector('#offline-gaia /deep/ #passwordInput" | 166 "document.querySelector('#offline-gaia /deep/ #passwordSection" |
| 167 " /deep/ .blue-button')"; | 167 " /deep/ .blue-button')"; |
| 168 | 168 |
| 169 content::DOMMessageQueue message_queue; | 169 content::DOMMessageQueue message_queue; |
| 170 JSExpect("!document.querySelector('#offline-gaia').hidden"); | 170 JSExpect("!document.querySelector('#offline-gaia').hidden"); |
| 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('core-animated-pages-transition-end'," | 174 ".addEventListener('core-animated-pages-transition-end'," |
| 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 + ".inputValue = '$Email'"; | 180 std::string set_email = email_input + ".value = '$Email'"; |
| 181 ReplaceSubstringsAfterOffset(&set_email, 0, "$Email", user_email); | 181 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 LOG(ERROR) << message; | 188 LOG(ERROR) << message; |
| 189 } while (message != "\"switchToPassword\""); | 189 } while (message != "\"switchToPassword\""); |
| 190 | 190 |
| 191 std::string set_password = password_input + ".inputValue = '$Password'"; | 191 std::string set_password = password_input + ".value = '$Password'"; |
| 192 ReplaceSubstringsAfterOffset(&set_password, 0, "$Password", password); | 192 ReplaceSubstringsAfterOffset(&set_password, 0, "$Password", password); |
| 193 ASSERT_TRUE(content::ExecuteScript(web_contents(), set_password)); | 193 ASSERT_TRUE(content::ExecuteScript(web_contents(), set_password)); |
| 194 ASSERT_TRUE(content::ExecuteScript(web_contents(), | 194 ASSERT_TRUE(content::ExecuteScript(web_contents(), |
| 195 password_next_button + ".fire('tap')")); | 195 password_next_button + ".fire('tap')")); |
| 196 } | 196 } |
| 197 | 197 |
| 198 void PrepareOfflineLogin() { | 198 void PrepareOfflineLogin() { |
| 199 bool show_user; | 199 bool show_user; |
| 200 ASSERT_TRUE(chromeos::CrosSettings::Get()->GetBoolean( | 200 ASSERT_TRUE(chromeos::CrosSettings::Get()->GetBoolean( |
| 201 chromeos::kAccountsPrefShowUserNamesOnSignIn, &show_user)); | 201 chromeos::kAccountsPrefShowUserNamesOnSignIn, &show_user)); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 content::WindowedNotificationObserver session_start_waiter( | 339 content::WindowedNotificationObserver session_start_waiter( |
| 340 chrome::NOTIFICATION_SESSION_STARTED, | 340 chrome::NOTIFICATION_SESSION_STARTED, |
| 341 content::NotificationService::AllSources()); | 341 content::NotificationService::AllSources()); |
| 342 SubmitGaiaAuthOfflineForm(kTestUser, kPassword); | 342 SubmitGaiaAuthOfflineForm(kTestUser, kPassword); |
| 343 session_start_waiter.Wait(); | 343 session_start_waiter.Wait(); |
| 344 | 344 |
| 345 TestSystemTrayIsVisible(); | 345 TestSystemTrayIsVisible(); |
| 346 } | 346 } |
| 347 | 347 |
| 348 } // namespace | 348 } // namespace |
| OLD | NEW |