Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(957)

Unified Diff: chrome/browser/chromeos/login/saml/saml_browsertest.cc

Issue 1066573003: cros: Use webview.addContentScripts for new Gaia SAML. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@webview-content-script-incognito
Patch Set: rebase Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/gaia_auth_host/authenticator.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/login/saml/saml_browsertest.cc
diff --git a/chrome/browser/chromeos/login/saml/saml_browsertest.cc b/chrome/browser/chromeos/login/saml/saml_browsertest.cc
index 593073422f37fcf657aac2e21425e0240718bf67..7c8af714d0c62bea443aacfc47dee282837145b0 100644
--- a/chrome/browser/chromeos/login/saml/saml_browsertest.cc
+++ b/chrome/browser/chromeos/login/saml/saml_browsertest.cc
@@ -267,7 +267,7 @@ scoped_ptr<HttpResponse> FakeSamlIdp::BuildHTMLResponse(
// iframe (false) GAIA sign in.
class SamlTest : public OobeBaseTest, public testing::WithParamInterface<bool> {
public:
- SamlTest() : saml_load_injected_(false) {
+ SamlTest() {
set_use_webview(GetParam());
set_initialize_fake_merge_session(false);
}
@@ -299,21 +299,23 @@ class SamlTest : public OobeBaseTest, public testing::WithParamInterface<bool> {
OobeBaseTest::SetUpOnMainThread();
}
+ void SetupAuthFlowChangeListener() {
+ ASSERT_TRUE(content::ExecuteScript(
+ GetLoginUI()->GetWebContents(),
+ "$('gaia-signin').gaiaAuthHost_.addEventListener('authFlowChange',"
+ "function f() {"
+ "$('gaia-signin').gaiaAuthHost_.removeEventListener("
+ "'authFlowChange', f);"
+ "window.domAutomationController.setAutomationId(0);"
+ "window.domAutomationController.send("
+ "$('gaia-signin').isSAML() ? 'SamlLoaded' : 'GaiaLoaded');"
+ "});"));
+ }
+
virtual void StartSamlAndWaitForIdpPageLoad(const std::string& gaia_email) {
WaitForSigninScreen();
- if (!saml_load_injected_) {
- saml_load_injected_ = true;
-
- ASSERT_TRUE(content::ExecuteScript(
- GetLoginUI()->GetWebContents(),
- "$('gaia-signin').gaiaAuthHost_.addEventListener('authFlowChange',"
- "function() {"
- "window.domAutomationController.setAutomationId(0);"
- "window.domAutomationController.send("
- "$('gaia-signin').isSAML() ? 'SamlLoaded' : 'GaiaLoaded');"
- "});"));
- }
+ SetupAuthFlowChangeListener();
content::DOMMessageQueue message_queue; // Start observe before SAML.
GetLoginDisplay()->ShowSigninScreenForCreds(gaia_email, "");
@@ -358,8 +360,6 @@ class SamlTest : public OobeBaseTest, public testing::WithParamInterface<bool> {
private:
FakeSamlIdp fake_saml_idp_;
- bool saml_load_injected_;
-
DISALLOW_COPY_AND_ASSIGN(SamlTest);
};
@@ -380,6 +380,8 @@ IN_PROC_BROWSER_TEST_P(SamlTest, SamlUI) {
JsExpect("!$('cancel-add-user-button').hidden");
}
+ SetupAuthFlowChangeListener();
+
// Click on 'cancel'.
content::DOMMessageQueue message_queue; // Observe before 'cancel'.
if (use_webview()) {
@@ -404,13 +406,6 @@ IN_PROC_BROWSER_TEST_P(SamlTest, SamlUI) {
// Tests the sign-in flow when the credentials passing API is used.
IN_PROC_BROWSER_TEST_P(SamlTest, CredentialPassingAPI) {
- // Disabled for webview because the script is injected using
- // webview.executeScript and there is no way to control the injection time.
- // As a result, this test is flaky and fails about 20% of the time.
- // TODO(xiyuan): Re-enable when webview.addContentScript API is ready.
- if (use_webview())
- return;
-
fake_saml_idp()->SetLoginHTMLTemplate("saml_api_login.html");
fake_saml_idp()->SetLoginAuthHTMLTemplate("saml_api_login_auth.html");
StartSamlAndWaitForIdpPageLoad(kFirstSAMLUserEmail);
« no previous file with comments | « no previous file | chrome/browser/resources/gaia_auth_host/authenticator.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698