| OLD | NEW | 
|     1 // Copyright 2014 The Chromium Authors. All rights reserved. |     1 // Copyright 2014 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 <cstring> |     5 #include <cstring> | 
|     6 #include <memory> |     6 #include <memory> | 
|     7 #include <string> |     7 #include <string> | 
|     8 #include <utility> |     8 #include <utility> | 
|     9  |     9  | 
|    10 #include "base/bind.h" |    10 #include "base/bind.h" | 
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   357     OobeBaseTest::SetUpOnMainThread(); |   357     OobeBaseTest::SetUpOnMainThread(); | 
|   358   } |   358   } | 
|   359  |   359  | 
|   360   void SetupAuthFlowChangeListener() { |   360   void SetupAuthFlowChangeListener() { | 
|   361     content::ExecuteScriptAsync( |   361     content::ExecuteScriptAsync( | 
|   362         GetLoginUI()->GetWebContents(), |   362         GetLoginUI()->GetWebContents(), | 
|   363         "$('gaia-signin').gaiaAuthHost_.addEventListener('authFlowChange'," |   363         "$('gaia-signin').gaiaAuthHost_.addEventListener('authFlowChange'," | 
|   364         "    function f() {" |   364         "    function f() {" | 
|   365         "      $('gaia-signin').gaiaAuthHost_.removeEventListener(" |   365         "      $('gaia-signin').gaiaAuthHost_.removeEventListener(" | 
|   366         "          'authFlowChange', f);" |   366         "          'authFlowChange', f);" | 
|   367         "      window.domAutomationController.setAutomationId(0);" |  | 
|   368         "      window.domAutomationController.send(" |   367         "      window.domAutomationController.send(" | 
|   369         "          $('gaia-signin').isSAML() ? 'SamlLoaded' : 'GaiaLoaded');" |   368         "          $('gaia-signin').isSAML() ? 'SamlLoaded' : 'GaiaLoaded');" | 
|   370         "    });"); |   369         "    });"); | 
|   371   } |   370   } | 
|   372  |   371  | 
|   373   virtual void StartSamlAndWaitForIdpPageLoad(const std::string& gaia_email) { |   372   virtual void StartSamlAndWaitForIdpPageLoad(const std::string& gaia_email) { | 
|   374     WaitForSigninScreen(); |   373     WaitForSigninScreen(); | 
|   375  |   374  | 
|   376     SetupAuthFlowChangeListener(); |   375     SetupAuthFlowChangeListener(); | 
|   377  |   376  | 
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   516 IN_PROC_BROWSER_TEST_F(SamlTest, ScrapedSingle) { |   515 IN_PROC_BROWSER_TEST_F(SamlTest, ScrapedSingle) { | 
|   517   fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); |   516   fake_saml_idp()->SetLoginHTMLTemplate("saml_login.html"); | 
|   518   StartSamlAndWaitForIdpPageLoad(kFirstSAMLUserEmail); |   517   StartSamlAndWaitForIdpPageLoad(kFirstSAMLUserEmail); | 
|   519  |   518  | 
|   520   // Make sure that the password is scraped correctly. |   519   // Make sure that the password is scraped correctly. | 
|   521   ASSERT_TRUE(content::ExecuteScript( |   520   ASSERT_TRUE(content::ExecuteScript( | 
|   522       GetLoginUI()->GetWebContents(), |   521       GetLoginUI()->GetWebContents(), | 
|   523       "$('gaia-signin').gaiaAuthHost_.addEventListener('authCompleted'," |   522       "$('gaia-signin').gaiaAuthHost_.addEventListener('authCompleted'," | 
|   524       "    function(e) {" |   523       "    function(e) {" | 
|   525       "      var password = e.detail.password;" |   524       "      var password = e.detail.password;" | 
|   526       "      window.domAutomationController.setAutomationId(0);" |  | 
|   527       "      window.domAutomationController.send(password);" |   525       "      window.domAutomationController.send(password);" | 
|   528       "    });")); |   526       "    });")); | 
|   529  |   527  | 
|   530   // Fill-in the SAML IdP form and submit. |   528   // Fill-in the SAML IdP form and submit. | 
|   531   SetSignFormField("Email", "fake_user"); |   529   SetSignFormField("Email", "fake_user"); | 
|   532   SetSignFormField("Password", "fake_password"); |   530   SetSignFormField("Password", "fake_password"); | 
|   533  |   531  | 
|   534   // Scraping a single password should finish the login and start the session. |   532   // Scraping a single password should finish the login and start the session. | 
|   535   content::WindowedNotificationObserver session_start_waiter( |   533   content::WindowedNotificationObserver session_start_waiter( | 
|   536       chrome::NOTIFICATION_SESSION_STARTED, |   534       chrome::NOTIFICATION_SESSION_STARTED, | 
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1114   fake_session_manager_client_->set_device_policy(device_policy_->GetBlob()); |  1112   fake_session_manager_client_->set_device_policy(device_policy_->GetBlob()); | 
|  1115   fake_session_manager_client_->OnPropertyChangeComplete(true); |  1113   fake_session_manager_client_->OnPropertyChangeComplete(true); | 
|  1116   run_loop.Run(); |  1114   run_loop.Run(); | 
|  1117 } |  1115 } | 
|  1118  |  1116  | 
|  1119 void SAMLPolicyTest::ShowGAIALoginForm() { |  1117 void SAMLPolicyTest::ShowGAIALoginForm() { | 
|  1120   login_screen_load_observer_->Wait(); |  1118   login_screen_load_observer_->Wait(); | 
|  1121   ASSERT_TRUE(content::ExecuteScript( |  1119   ASSERT_TRUE(content::ExecuteScript( | 
|  1122       GetLoginUI()->GetWebContents(), |  1120       GetLoginUI()->GetWebContents(), | 
|  1123       "$('gaia-signin').gaiaAuthHost_.addEventListener('ready', function() {" |  1121       "$('gaia-signin').gaiaAuthHost_.addEventListener('ready', function() {" | 
|  1124       "  window.domAutomationController.setAutomationId(0);" |  | 
|  1125       "  window.domAutomationController.send('ready');" |  1122       "  window.domAutomationController.send('ready');" | 
|  1126       "});" |  1123       "});" | 
|  1127       "$('add-user-button').click();")); |  1124       "$('add-user-button').click();")); | 
|  1128   content::DOMMessageQueue message_queue; |  1125   content::DOMMessageQueue message_queue; | 
|  1129   std::string message; |  1126   std::string message; | 
|  1130   ASSERT_TRUE(message_queue.WaitForMessage(&message)); |  1127   ASSERT_TRUE(message_queue.WaitForMessage(&message)); | 
|  1131   EXPECT_EQ("\"ready\"", message); |  1128   EXPECT_EQ("\"ready\"", message); | 
|  1132 } |  1129 } | 
|  1133  |  1130  | 
|  1134 void SAMLPolicyTest::ShowSAMLInterstitial() { |  1131 void SAMLPolicyTest::ShowSAMLInterstitial() { | 
|  1135   login_screen_load_observer_->Wait(); |  1132   login_screen_load_observer_->Wait(); | 
|  1136   ASSERT_TRUE(content::ExecuteScript( |  1133   ASSERT_TRUE(content::ExecuteScript( | 
|  1137       GetLoginUI()->GetWebContents(), |  1134       GetLoginUI()->GetWebContents(), | 
|  1138       "$('saml-interstitial').addEventListener(" |  1135       "$('saml-interstitial').addEventListener(" | 
|  1139       "    'samlInterstitialPageReady'," |  1136       "    'samlInterstitialPageReady'," | 
|  1140       "    function() {" |  1137       "    function() {" | 
|  1141       "        window.domAutomationController.setAutomationId(0);" |  | 
|  1142       "        window.domAutomationController.send(" |  1138       "        window.domAutomationController.send(" | 
|  1143       "            'samlInterstitialPageReady');" |  1139       "            'samlInterstitialPageReady');" | 
|  1144       "    });" |  1140       "    });" | 
|  1145       "$('add-user-button').click();")); |  1141       "$('add-user-button').click();")); | 
|  1146  |  1142  | 
|  1147   content::DOMMessageQueue message_queue; |  1143   content::DOMMessageQueue message_queue; | 
|  1148   std::string message; |  1144   std::string message; | 
|  1149   ASSERT_TRUE(message_queue.WaitForMessage(&message)); |  1145   ASSERT_TRUE(message_queue.WaitForMessage(&message)); | 
|  1150   EXPECT_EQ("\"samlInterstitialPageReady\"", message); |  1146   EXPECT_EQ("\"samlInterstitialPageReady\"", message); | 
|  1151 } |  1147 } | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
|  1164     ASSERT_TRUE(message_queue.WaitForMessage(&message)); |  1160     ASSERT_TRUE(message_queue.WaitForMessage(&message)); | 
|  1165   } while (message != "\"SamlLoaded\""); |  1161   } while (message != "\"SamlLoaded\""); | 
|  1166   EXPECT_EQ("\"SamlLoaded\"", message); |  1162   EXPECT_EQ("\"SamlLoaded\"", message); | 
|  1167 } |  1163 } | 
|  1168  |  1164  | 
|  1169 void SAMLPolicyTest::ClickChangeAccountOnSAMLInterstitialPage() { |  1165 void SAMLPolicyTest::ClickChangeAccountOnSAMLInterstitialPage() { | 
|  1170   login_screen_load_observer_->Wait(); |  1166   login_screen_load_observer_->Wait(); | 
|  1171   ASSERT_TRUE(content::ExecuteScript( |  1167   ASSERT_TRUE(content::ExecuteScript( | 
|  1172       GetLoginUI()->GetWebContents(), |  1168       GetLoginUI()->GetWebContents(), | 
|  1173       "$('gaia-signin').gaiaAuthHost_.addEventListener('ready', function() {" |  1169       "$('gaia-signin').gaiaAuthHost_.addEventListener('ready', function() {" | 
|  1174       "  window.domAutomationController.setAutomationId(0);" |  | 
|  1175       "  window.domAutomationController.send('ready');" |  1170       "  window.domAutomationController.send('ready');" | 
|  1176       "});" |  1171       "});" | 
|  1177       "$('saml-interstitial').changeAccountLink.click();")); |  1172       "$('saml-interstitial').changeAccountLink.click();")); | 
|  1178  |  1173  | 
|  1179   content::DOMMessageQueue message_queue; |  1174   content::DOMMessageQueue message_queue; | 
|  1180   std::string message; |  1175   std::string message; | 
|  1181   ASSERT_TRUE(message_queue.WaitForMessage(&message)); |  1176   ASSERT_TRUE(message_queue.WaitForMessage(&message)); | 
|  1182   EXPECT_EQ("\"ready\"", message); |  1177   EXPECT_EQ("\"ready\"", message); | 
|  1183 } |  1178 } | 
|  1184  |  1179  | 
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1476       ->SetContentSettingDefaultScope(url3, url3, |  1471       ->SetContentSettingDefaultScope(url3, url3, | 
|  1477                                       CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, |  1472                                       CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, | 
|  1478                                       std::string(), CONTENT_SETTING_ALLOW); |  1473                                       std::string(), CONTENT_SETTING_ALLOW); | 
|  1479  |  1474  | 
|  1480   EXPECT_FALSE( |  1475   EXPECT_FALSE( | 
|  1481       MediaCaptureDevicesDispatcher::GetInstance()->CheckMediaAccessPermission( |  1476       MediaCaptureDevicesDispatcher::GetInstance()->CheckMediaAccessPermission( | 
|  1482           web_contents, url3, content::MEDIA_DEVICE_VIDEO_CAPTURE)); |  1477           web_contents, url3, content::MEDIA_DEVICE_VIDEO_CAPTURE)); | 
|  1483 } |  1478 } | 
|  1484  |  1479  | 
|  1485 }  // namespace chromeos |  1480 }  // namespace chromeos | 
| OLD | NEW |