| 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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 fake_gaia_->SetFakeMergeSessionParams( | 351 fake_gaia_->SetFakeMergeSessionParams( |
| 352 kFirstSAMLUserEmail, kTestAuthSIDCookie1, kTestAuthLSIDCookie1); | 352 kFirstSAMLUserEmail, kTestAuthSIDCookie1, kTestAuthLSIDCookie1); |
| 353 | 353 |
| 354 embedded_test_server()->RegisterRequestHandler(base::Bind( | 354 embedded_test_server()->RegisterRequestHandler(base::Bind( |
| 355 &FakeSamlIdp::HandleRequest, base::Unretained(&fake_saml_idp_))); | 355 &FakeSamlIdp::HandleRequest, base::Unretained(&fake_saml_idp_))); |
| 356 | 356 |
| 357 OobeBaseTest::SetUpOnMainThread(); | 357 OobeBaseTest::SetUpOnMainThread(); |
| 358 } | 358 } |
| 359 | 359 |
| 360 void SetupAuthFlowChangeListener() { | 360 void SetupAuthFlowChangeListener() { |
| 361 ASSERT_TRUE(content::ExecuteScript( | 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);" | 367 " window.domAutomationController.setAutomationId(0);" |
| 368 "window.domAutomationController.send(" | 368 " window.domAutomationController.send(" |
| 369 "$('gaia-signin').isSAML() ? 'SamlLoaded' : 'GaiaLoaded');" | 369 " $('gaia-signin').isSAML() ? 'SamlLoaded' : 'GaiaLoaded');" |
| 370 "});")); | 370 " });"); |
| 371 } | 371 } |
| 372 | 372 |
| 373 virtual void StartSamlAndWaitForIdpPageLoad(const std::string& gaia_email) { | 373 virtual void StartSamlAndWaitForIdpPageLoad(const std::string& gaia_email) { |
| 374 WaitForSigninScreen(); | 374 WaitForSigninScreen(); |
| 375 | 375 |
| 376 SetupAuthFlowChangeListener(); | 376 SetupAuthFlowChangeListener(); |
| 377 | 377 |
| 378 content::DOMMessageQueue message_queue; // Start observe before SAML. | 378 content::DOMMessageQueue message_queue; // Start observe before SAML. |
| 379 GetLoginDisplay()->ShowSigninScreenForCreds(gaia_email, ""); | 379 GetLoginDisplay()->ShowSigninScreenForCreds(gaia_email, ""); |
| 380 | 380 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 JsExpect("$('gaia-signin').classList.contains('full-width')"); | 456 JsExpect("$('gaia-signin').classList.contains('full-width')"); |
| 457 JsExpect("!$('saml-notice-container').hidden"); | 457 JsExpect("!$('saml-notice-container').hidden"); |
| 458 std::string js = "$('saml-notice-message').textContent.indexOf('$Host') > -1"; | 458 std::string js = "$('saml-notice-message').textContent.indexOf('$Host') > -1"; |
| 459 base::ReplaceSubstringsAfterOffset(&js, 0, "$Host", kIdPHost); | 459 base::ReplaceSubstringsAfterOffset(&js, 0, "$Host", kIdPHost); |
| 460 JsExpect(js); | 460 JsExpect(js); |
| 461 | 461 |
| 462 SetupAuthFlowChangeListener(); | 462 SetupAuthFlowChangeListener(); |
| 463 | 463 |
| 464 // Click on 'cancel'. | 464 // Click on 'cancel'. |
| 465 content::DOMMessageQueue message_queue; // Observe before 'cancel'. | 465 content::DOMMessageQueue message_queue; // Observe before 'cancel'. |
| 466 ASSERT_TRUE( | 466 content::ExecuteScriptAsync(GetLoginUI()->GetWebContents(), |
| 467 content::ExecuteScript(GetLoginUI()->GetWebContents(), | 467 "$('gaia-navigation').$.closeButton.click();"); |
| 468 "$('gaia-navigation').$.closeButton.click();")); | |
| 469 | 468 |
| 470 // Auth flow should change back to Gaia. | 469 // Auth flow should change back to Gaia. |
| 471 std::string message; | 470 std::string message; |
| 472 do { | 471 do { |
| 473 ASSERT_TRUE(message_queue.WaitForMessage(&message)); | 472 ASSERT_TRUE(message_queue.WaitForMessage(&message)); |
| 474 } while (message != "\"GaiaLoaded\""); | 473 } while (message != "\"GaiaLoaded\""); |
| 475 | 474 |
| 476 // Saml flow is gone. | 475 // Saml flow is gone. |
| 477 JsExpect("!$('gaia-signin').classList.contains('full-width')"); | 476 JsExpect("!$('gaia-signin').classList.contains('full-width')"); |
| 478 } | 477 } |
| (...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1477 ->SetContentSettingDefaultScope(url3, url3, | 1476 ->SetContentSettingDefaultScope(url3, url3, |
| 1478 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, | 1477 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, |
| 1479 std::string(), CONTENT_SETTING_ALLOW); | 1478 std::string(), CONTENT_SETTING_ALLOW); |
| 1480 | 1479 |
| 1481 EXPECT_FALSE( | 1480 EXPECT_FALSE( |
| 1482 MediaCaptureDevicesDispatcher::GetInstance()->CheckMediaAccessPermission( | 1481 MediaCaptureDevicesDispatcher::GetInstance()->CheckMediaAccessPermission( |
| 1483 web_contents, url3, content::MEDIA_DEVICE_VIDEO_CAPTURE)); | 1482 web_contents, url3, content::MEDIA_DEVICE_VIDEO_CAPTURE)); |
| 1484 } | 1483 } |
| 1485 | 1484 |
| 1486 } // namespace chromeos | 1485 } // namespace chromeos |
| OLD | NEW |