diff options
author | glotov@chromium.org <glotov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-17 11:44:42 +0000 |
---|---|---|
committer | glotov@chromium.org <glotov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-17 11:44:42 +0000 |
commit | a99442bd84c6d95378f229730f53300c2e70bed1 (patch) | |
tree | fe1a47be8aa6a671e03aca3a0a323ac6e1ddad8c | |
parent | 3e902a85d478c4e2a7f5b1e734a7a8395fc552ff (diff) | |
download | chromium_src-a99442bd84c6d95378f229730f53300c2e70bed1.zip chromium_src-a99442bd84c6d95378f229730f53300c2e70bed1.tar.gz chromium_src-a99442bd84c6d95378f229730f53300c2e70bed1.tar.bz2 |
Add browser test for new user CrOS login flow
BUG=178009
TEST=this test
Review URL: https://codereview.chromium.org/13542003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194572 0039d316-1c4b-4281-b951-d872f2087c98
12 files changed, 347 insertions, 31 deletions
diff --git a/chrome/browser/chromeos/login/login_browsertest.cc b/chrome/browser/chromeos/login/login_browsertest.cc index afef1e2..d57a637 100644 --- a/chrome/browser/chromeos/login/login_browsertest.cc +++ b/chrome/browser/chromeos/login/login_browsertest.cc @@ -33,9 +33,9 @@ using ::testing::_; using ::testing::AnyNumber; using ::testing::Return; -namespace chromeos { +namespace { -class LoginTestBase : public CrosInProcessBrowserTest { +class LoginTestBase : public chromeos::CrosInProcessBrowserTest { public: LoginTestBase() : mock_cryptohome_library_(NULL), @@ -59,8 +59,8 @@ class LoginTestBase : public CrosInProcessBrowserTest { .WillRepeatedly(Return(true)); } - MockCryptohomeLibrary* mock_cryptohome_library_; - MockNetworkLibrary* mock_network_library_; + chromeos::MockCryptohomeLibrary* mock_cryptohome_library_; + chromeos::MockNetworkLibrary* mock_network_library_; private: DISALLOW_COPY_AND_ASSIGN(LoginTestBase); @@ -73,8 +73,9 @@ class LoginUserTest : public LoginTestBase { } virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { - command_line->AppendSwitchASCII(switches::kLoginUser, "TestUser@gmail.com"); - command_line->AppendSwitchASCII(switches::kLoginProfile, "user"); + command_line->AppendSwitchASCII( + chromeos::switches::kLoginUser, "TestUser@gmail.com"); + command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); command_line->AppendSwitch(::switches::kNoFirstRun); } }; @@ -82,9 +83,9 @@ class LoginUserTest : public LoginTestBase { class LoginGuestTest : public LoginTestBase { protected: virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { - command_line->AppendSwitch(switches::kGuestSession); + command_line->AppendSwitch(chromeos::switches::kGuestSession); command_line->AppendSwitch(::switches::kIncognito); - command_line->AppendSwitchASCII(switches::kLoginProfile, "user"); + command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); command_line->AppendSwitch(::switches::kNoFirstRun); } }; @@ -92,7 +93,7 @@ class LoginGuestTest : public LoginTestBase { class LoginCursorTest : public LoginTestBase { protected: virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { - command_line->AppendSwitch(switches::kLoginManager); + command_line->AppendSwitch(chromeos::switches::kLoginManager); } }; @@ -148,11 +149,11 @@ class TestContentBrowserClient : public chrome::ChromeContentBrowserClient { }; -class LoginSigninTest : public CrosInProcessBrowserTest { +class LoginSigninTest : public chromeos::CrosInProcessBrowserTest { protected: virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { - command_line->AppendSwitch(switches::kLoginManager); - command_line->AppendSwitch(switches::kForceLoginManagerInTests); + command_line->AppendSwitch(chromeos::switches::kLoginManager); + command_line->AppendSwitch(chromeos::switches::kForceLoginManagerInTests); } virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { @@ -200,7 +201,8 @@ IN_PROC_BROWSER_TEST_F(LoginGuestTest, CursorShown) { // Verifies the cursor is hidden at startup on login screen. IN_PROC_BROWSER_TEST_F(LoginCursorTest, CursorHidden) { // Login screen needs to be shown explicitly when running test. - ShowLoginWizard(WizardController::kLoginScreenName, gfx::Size()); + chromeos::ShowLoginWizard(chromeos::WizardController::kLoginScreenName, + gfx::Size()); // Cursor should be hidden at startup EXPECT_FALSE(ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible()); @@ -209,8 +211,8 @@ IN_PROC_BROWSER_TEST_F(LoginCursorTest, CursorHidden) { EXPECT_TRUE(ui_test_utils::SendMouseMoveSync(gfx::Point())); EXPECT_TRUE(ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible()); - MessageLoop::current()->DeleteSoon(FROM_HERE, - BaseLoginDisplayHost::default_host()); + MessageLoop::current()->DeleteSoon( + FROM_HERE, chromeos::BaseLoginDisplayHost::default_host()); } // Verifies that the webui for login comes up successfully. @@ -222,4 +224,4 @@ IN_PROC_BROWSER_TEST_F(LoginSigninTest, WebUIVisible) { runner->Run(); } -} // namespace chromeos +} diff --git a/chrome/browser/chromeos/login/oobe_browsertest.cc b/chrome/browser/chromeos/login/oobe_browsertest.cc new file mode 100644 index 0000000..b0ffedf --- /dev/null +++ b/chrome/browser/chromeos/login/oobe_browsertest.cc @@ -0,0 +1,204 @@ +// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/command_line.h" +#include "base/path_service.h" +#include "chrome/browser/chrome_browser_main.h" +#include "chrome/browser/chrome_browser_main_extra_parts.h" +#include "chrome/browser/chrome_content_browser_client.h" +#include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h" +#include "chrome/browser/chromeos/login/existing_user_controller.h" +#include "chrome/browser/chromeos/login/webui_login_display.h" +#include "chrome/browser/chromeos/login/wizard_controller.h" +#include "chrome/browser/google_apis/test_server/http_request.h" +#include "chrome/browser/google_apis/test_server/http_response.h" +#include "chrome/browser/google_apis/test_server/http_server.h" +#include "chrome/browser/ui/browser.h" +#include "chrome/common/chrome_notification_types.h" +#include "chrome/common/chrome_paths.h" +#include "chrome/common/chrome_switches.h" +#include "chrome/test/base/in_process_browser_test.h" +#include "chrome/test/base/interactive_test_utils.h" +#include "chrome/test/base/ui_test_utils.h" +#include "chromeos/chromeos_switches.h" +#include "content/public/browser/notification_observer.h" +#include "content/public/browser/notification_registrar.h" +#include "content/public/browser/notification_service.h" +#include "content/public/test/test_utils.h" +#include "google_apis/gaia/gaia_switches.h" +#include "testing/gmock/include/gmock/gmock.h" +#include "testing/gtest/include/gtest/gtest.h" + +using namespace google_apis; +using namespace google_apis::test_server; + +namespace { + +// Used to add an observer to NotificationService after it's created. +class TestBrowserMainExtraParts + : public ChromeBrowserMainExtraParts, + public content::NotificationObserver { + public: + TestBrowserMainExtraParts() {} + virtual ~TestBrowserMainExtraParts() {} + + // ChromeBrowserMainExtraParts implementation. + virtual void PreEarlyInitialization() OVERRIDE { + registrar_.Add(this, chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE, + content::NotificationService::AllSources()); + registrar_.Add(this, chrome::NOTIFICATION_SESSION_STARTED, + content::NotificationService::AllSources()); + } + + void set_quit_task(const base::Closure& quit_task) { quit_task_ = quit_task; } + void set_gaia_url(const std::string& url) { gaia_url_ = url; } + + private: + // Overridden from content::NotificationObserver: + virtual void Observe(int type, + const content::NotificationSource& source, + const content::NotificationDetails& details) OVERRIDE { + if (type == chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE) { + LOG(INFO) << "NOTIFICATION_LOGIN_WEBUI_VISIBLE"; + chromeos::ExistingUserController* controller = + chromeos::ExistingUserController::current_controller(); + CHECK(controller); + chromeos::WebUILoginDisplay* webui_login_display = + static_cast<chromeos::WebUILoginDisplay*>( + controller->login_display()); + CHECK(webui_login_display); + webui_login_display->SetGaiaOriginForTesting(gaia_url_); + webui_login_display->ShowSigninScreenForCreds("username", "password"); + // TODO(glotov): mock GAIA server (test_server_) should support + // username/password configuration. + } else if (type == chrome::NOTIFICATION_SESSION_STARTED) { + LOG(INFO) << "chrome::NOTIFICATION_SESSION_STARTED"; + quit_task_.Run(); + } else { + NOTREACHED(); + } + } + + content::NotificationRegistrar registrar_; + base::Closure quit_task_; + std::string gaia_url_; + + DISALLOW_COPY_AND_ASSIGN(TestBrowserMainExtraParts); +}; + +class TestContentBrowserClient : public chrome::ChromeContentBrowserClient { + public: + TestContentBrowserClient() {} + virtual ~TestContentBrowserClient() {} + + virtual content::BrowserMainParts* CreateBrowserMainParts( + const content::MainFunctionParams& parameters) OVERRIDE { + ChromeBrowserMainParts* main_parts = static_cast<ChromeBrowserMainParts*>( + ChromeContentBrowserClient::CreateBrowserMainParts(parameters)); + + browser_main_extra_parts_ = new TestBrowserMainExtraParts(); + main_parts->AddParts(browser_main_extra_parts_); + return main_parts; + } + + TestBrowserMainExtraParts* browser_main_extra_parts_; + + private: + DISALLOW_COPY_AND_ASSIGN(TestContentBrowserClient); +}; + +const base::FilePath kServiceLogin("chromeos/service_login.html"); + +class OobeTest : public chromeos::CrosInProcessBrowserTest { + protected: + virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { + command_line->AppendSwitch(chromeos::switches::kLoginManager); + command_line->AppendSwitch(chromeos::switches::kForceLoginManagerInTests); + command_line->AppendSwitch(switches::kDisableChromeCaptivePortalDetector); + command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); + command_line->AppendSwitchASCII(switches::kAuthExtensionPath, "gaia_auth"); + } + + virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { + content_browser_client_.reset(new TestContentBrowserClient()); + original_content_browser_client_ = content::SetBrowserClientForTesting( + content_browser_client_.get()); + base::FilePath test_data_dir; + PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir); + CHECK(file_util::ReadFileToString(test_data_dir.Append(kServiceLogin), + &service_login_response_)); + } + + virtual void SetUpOnMainThread() OVERRIDE { + test_server_ = new HttpServer(); // Constructor wants UI thread. + CHECK(test_server_->InitializeAndWaitUntilReady()); + test_server_->RegisterRequestHandler( + base::Bind(&OobeTest::HandleRequest, base::Unretained(this))); + LOG(INFO) << "Set up http server at " << test_server_->base_url(); + CHECK(test_server_->port() >= 8040 && test_server_->port() < 8045) + << "Current manifest_test.json for gaia_login restrictions " + << "does not allow this port"; + + const std::string gaia_url = + "http://localhost:" + test_server_->base_url().port(); + content_browser_client_->browser_main_extra_parts_->set_gaia_url(gaia_url); + } + + virtual void CleanUpOnMainThread() OVERRIDE { + LOG(INFO) << "Stopping the http server."; + test_server_->ShutdownAndWaitUntilComplete(); + delete test_server_; // Destructor wants UI thread. + } + + scoped_ptr<HttpResponse> HandleRequest(const HttpRequest& request) { + GURL url = test_server_->GetURL(request.relative_url); + LOG(INFO) << "Http request: " << url.spec(); + + scoped_ptr<HttpResponse> http_response(new HttpResponse()); + if (url.path() == "/ServiceLogin") { + http_response->set_code(test_server::SUCCESS); + http_response->set_content(service_login_response_); + http_response->set_content_type("text/html"); + } else if (url.path() == "/ServiceLoginAuth") { + LOG(INFO) << "Params: " << request.content; + static const char kContinueParam[] = "continue="; + int continue_arg_begin = request.content.find(kContinueParam) + + arraysize(kContinueParam) - 1; + int continue_arg_end = request.content.find("&", continue_arg_begin); + const std::string continue_url = request.content.substr( + continue_arg_begin, continue_arg_end - continue_arg_begin); + http_response->set_code(test_server::SUCCESS); + const std::string redirect_js = + "document.location.href = unescape('" + continue_url + "');"; + http_response->set_content( + "<HTML><HEAD><SCRIPT>\n" + redirect_js + "\n</SCRIPT></HEAD></HTML>"); + http_response->set_content_type("text/html"); + } else { + NOTREACHED() << url.path(); + } + return http_response.Pass(); + } + + scoped_ptr<TestContentBrowserClient> content_browser_client_; + content::ContentBrowserClient* original_content_browser_client_; + std::string service_login_response_; + HttpServer* test_server_; // cant use scoped_ptr because destructor + // needs UI thread. +}; + +IN_PROC_BROWSER_TEST_F(OobeTest, NewUser) { + chromeos::WizardController::SkipPostLoginScreensForTesting(); + chromeos::WizardController* wizard_controller = + chromeos::WizardController::default_controller(); + CHECK(wizard_controller); + wizard_controller->SkipToLoginForTesting(); + + scoped_refptr<content::MessageLoopRunner> runner = + new content::MessageLoopRunner; + content_browser_client_->browser_main_extra_parts_->set_quit_task( + runner->QuitClosure()); + runner->Run(); +} + +} diff --git a/chrome/browser/chromeos/login/webui_login_display.cc b/chrome/browser/chromeos/login/webui_login_display.cc index c1b9c81..bd6f2b0 100644 --- a/chrome/browser/chromeos/login/webui_login_display.cc +++ b/chrome/browser/chromeos/login/webui_login_display.cc @@ -311,6 +311,11 @@ void WebUILoginDisplay::ShowSigninScreenForCreds( webui_handler_->ShowSigninScreenForCreds(username, password); } +void WebUILoginDisplay::SetGaiaOriginForTesting(const std::string& arg) { + if (webui_handler_) + webui_handler_->SetGaiaOriginForTesting(arg); +} + const UserList& WebUILoginDisplay::GetUsers() const { return users_; } diff --git a/chrome/browser/chromeos/login/webui_login_display.h b/chrome/browser/chromeos/login/webui_login_display.h index 470e177..6d0a58e 100644 --- a/chrome/browser/chromeos/login/webui_login_display.h +++ b/chrome/browser/chromeos/login/webui_login_display.h @@ -72,6 +72,7 @@ class WebUILoginDisplay : public LoginDisplay, LoginDisplayWebUIHandler* webui_handler) OVERRIDE; virtual void ShowSigninScreenForCreds(const std::string& username, const std::string& password); + virtual void SetGaiaOriginForTesting(const std::string& arg); virtual const UserList& GetUsers() const OVERRIDE; virtual bool IsShowGuest() const OVERRIDE; virtual bool IsShowUsers() const OVERRIDE; diff --git a/chrome/browser/extensions/user_script_master.cc b/chrome/browser/extensions/user_script_master.cc index 999c0f7..4e26bb6 100644 --- a/chrome/browser/extensions/user_script_master.cc +++ b/chrome/browser/extensions/user_script_master.cc @@ -18,6 +18,7 @@ #include "base/version.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_system.h" +#include "chrome/browser/extensions/image_loader.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/extensions/api/i18n/default_locale_handler.h" @@ -29,6 +30,7 @@ #include "content/public/browser/notification_service.h" #include "content/public/browser/render_process_host.h" #include "extensions/common/extension_resource.h" +#include "ui/base/resource/resource_bundle.h" using content::BrowserThread; @@ -188,14 +190,23 @@ static bool LoadScriptContent(UserScript::File* script_file, script_file->extension_root(), script_file->relative_path(), ExtensionResource::SYMLINKS_MUST_RESOLVE_WITHIN_ROOT); if (path.empty()) { - LOG(WARNING) << "Failed to get file path to " - << script_file->relative_path().value() << " from " - << script_file->extension_root().value(); - return false; - } - if (!file_util::ReadFileToString(path, &content)) { - LOG(WARNING) << "Failed to load user script file: " << path.value(); - return false; + int resource_id; + if (extensions::ImageLoader::IsComponentExtensionResource( + script_file->extension_root(), script_file->relative_path(), + &resource_id)) { + const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); + content = rb.GetRawDataResource(resource_id).as_string(); + } else { + LOG(WARNING) << "Failed to get file path to " + << script_file->relative_path().value() << " from " + << script_file->extension_root().value(); + return false; + } + } else { + if (!file_util::ReadFileToString(path, &content)) { + LOG(WARNING) << "Failed to load user script file: " << path.value(); + return false; + } } // Localize the content. diff --git a/chrome/browser/resources/chromeos/login/screen_gaia_signin.js b/chrome/browser/resources/chromeos/login/screen_gaia_signin.js index 492224c..c08d37a 100644 --- a/chrome/browser/resources/chromeos/login/screen_gaia_signin.js +++ b/chrome/browser/resources/chromeos/login/screen_gaia_signin.js @@ -9,7 +9,7 @@ cr.define('login', function() { // Gaia loading time after which error message must be displayed and // lazy portal check should be fired. - /** @const */ var GAIA_LOADING_PORTAL_SUSSPECT_TIME_SEC = 7; + /** @const */ var GAIA_LOADING_PORTAL_SUSSPECT_TIME_SEC = 15; // Maximum Gaia loading time in seconds. /** @const */ var MAX_GAIA_LOADING_TIME_SEC = 60; @@ -231,7 +231,7 @@ cr.define('login', function() { url += '?' + params.join('&'); if (data.forceReload || this.extensionUrl_ != url) { - console.log('Opening extension: ' + data.url + + console.log('Opening extension: ' + url + ', opt_email=' + data.email); this.error_ = 0; diff --git a/chrome/browser/resources/gaia_auth/manifest_test.json b/chrome/browser/resources/gaia_auth/manifest_test.json index 3b0363a..6976bbf 100644 --- a/chrome/browser/resources/gaia_auth/manifest_test.json +++ b/chrome/browser/resources/gaia_auth/manifest_test.json @@ -4,7 +4,7 @@ "name": "GaiaTestAuthExtension", "version": "0.0.1", "manifest_version": 2, - "content_security_policy": "default-src 'self'; script-src 'self'; frame-src 'self' https://insecure.com https://www.google.com/accounts/ https://accounts.google.com https://accounts.youtube.com https://gaiastaging.corp.google.com", + "content_security_policy": "default-src 'self'; script-src 'self'; frame-src 'self' https://insecure.com https://www.google.com/accounts/ https://accounts.google.com https://accounts.youtube.com https://gaiastaging.corp.google.com http://localhost:8040 http://localhost:8041 http://localhost:8042 http://localhost:8043 http://localhost:8044", "description": "GAIA Test Component Extension", "content_scripts": [ { @@ -12,7 +12,8 @@ "https://www.google.com/accounts/*", "https://accounts.google.com/*", "https://gaiastaging.corp.google.com/*", - "https://insecure.com/*" + "https://insecure.com/*", + "http://localhost:8040/*" ], "js": ["test/content.js"], "all_frames": true @@ -35,6 +36,7 @@ "https://www.google.com/accounts/*", "https://accounts.google.com/*", "https://gaiastaging.corp.google.com/*", - "chrome://oobe/" + "chrome://oobe/", + "http://localhost:8040/*" ] } diff --git a/chrome/browser/resources/gaia_auth/test/content.js b/chrome/browser/resources/gaia_auth/test/content.js index 459a5b05..1bf055f 100644 --- a/chrome/browser/resources/gaia_auth/test/content.js +++ b/chrome/browser/resources/gaia_auth/test/content.js @@ -15,16 +15,20 @@ function getQueryParam(key, defaultVal) { return qs[1]; } +console.log(document.URL); if (document.URL.match(/https\:\/\/www\.google\.com\/accounts\/ServiceLogin/) || document.URL.match(/https\:\/\/accounts\.google\.com\/ServiceLogin/) || document.URL.match( /https\:\/\/gaiastaging\.corp\.google\.com\/ServiceLogin/) || - document.URL.match(/https\:\/\/insecure\.com\/accounts\/ServiceLogin/)) { + document.URL.match(/https\:\/\/insecure\.com\/accounts\/ServiceLogin/) || + document.URL.match(/http\:\/\/localhost(:[0-9]*)?\/ServiceLogin/)) { var testEmail = unescape(getQueryParam('test_email')); var testPassword = unescape(getQueryParam('test_pwd')); + var testContinue = unescape(getQueryParam('continue')); console.log('Got test account info: ' + testEmail + '/' + testPassword); document.getElementById('Email').value = testEmail; document.getElementById('Passwd').value = testPassword; + document.getElementById('continue').value = testContinue; console.log('Form field changed!'); if (testEmail != '') { document.getElementById('signIn').click(); diff --git a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc index a72a8e991..e0c487e 100644 --- a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc +++ b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc @@ -875,6 +875,10 @@ void SigninScreenHandler::ShowSigninScreenForCreds( HandleShowAddUser(NULL); } +void SigninScreenHandler::SetGaiaOriginForTesting(const std::string& arg) { + gaia_origin_for_test_ = arg; +} + void SigninScreenHandler::OnBrowsingDataRemoverDone() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); cookie_remover_ = NULL; @@ -1010,7 +1014,10 @@ void SigninScreenHandler::LoadAuthExtension( params.Set("localizedStrings", localized_strings); } - params.SetString("gaiaOrigin", GaiaUrls::GetInstance()->gaia_origin_url()); + std::string gaia_origin = GaiaUrls::GetInstance()->gaia_origin_url(); + if (!gaia_origin_for_test_.empty()) + gaia_origin = gaia_origin_for_test_; + params.SetString("gaiaOrigin", gaia_origin); const CommandLine* command_line = CommandLine::ForCurrentProcess(); if (command_line->HasSwitch(::switches::kGaiaUrlPath)) { params.SetString("gaiaUrlPath", diff --git a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h index f7969b4..34a6c9f 100644 --- a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h +++ b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h @@ -62,6 +62,7 @@ class LoginDisplayWebUIHandler { // Show sign-in screen for the given credentials. virtual void ShowSigninScreenForCreds(const std::string& username, const std::string& password) = 0; + virtual void SetGaiaOriginForTesting(const std::string& arg) = 0; protected: virtual ~LoginDisplayWebUIHandler() {} }; @@ -248,6 +249,7 @@ class SigninScreenHandler virtual void ShowErrorScreen(LoginDisplay::SigninError error_id) OVERRIDE; virtual void ShowSigninScreenForCreds(const std::string& username, const std::string& password) OVERRIDE; + virtual void SetGaiaOriginForTesting(const std::string& arg) OVERRIDE; // BrowsingDataRemover::Observer overrides. virtual void OnBrowsingDataRemoverDone() OVERRIDE; @@ -438,6 +440,9 @@ class SigninScreenHandler // NOTIFICATION_AUTH_CANCELLED. bool has_pending_auth_ui_; + // Testing helper, specifies new value for gaia url. + std::string gaia_origin_for_test_; + DISALLOW_COPY_AND_ASSIGN(SigninScreenHandler); }; diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 71d2ede..4f3e9bb 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -377,11 +377,13 @@ 'browser/chromeos/login/login_browsertest.cc', 'browser/chromeos/login/mock_authenticator.cc', 'browser/chromeos/login/mock_authenticator.h', + 'browser/chromeos/login/oobe_browsertest.cc', 'browser/chromeos/login/screen_locker_browsertest.cc', 'browser/chromeos/login/screen_locker_tester.cc', 'browser/chromeos/login/screen_locker_tester.h', 'browser/chromeos/login/wallpaper_manager_browsertest.cc', 'browser/chromeos/system/ash_focus_cycle_browsertest.cc', + 'test/data/chromeos/service_login.html', ], 'sources!': [ # chromeos does not use cross-platform panels diff --git a/chrome/test/data/chromeos/service_login.html b/chrome/test/data/chromeos/service_login.html new file mode 100644 index 0000000..91db471 --- /dev/null +++ b/chrome/test/data/chromeos/service_login.html @@ -0,0 +1,73 @@ +<HTML> +<HEAD> +<SCRIPT> +var gaia = gaia || {}; +gaia.chromeOSLogin = {}; + +gaia.chromeOSLogin.parent_page_url_ = +'chrome-extension://mfffpogegjflfpflabcdkioaeobkgjik/main.html'; + +gaia.chromeOSLogin.attemptLogin = function(email, password, attemptToken) { + var msg = { + 'method': 'attemptLogin', + 'email': email, + 'password': password, + 'attemptToken': attemptToken + }; + window.parent.postMessage(msg, gaia.chromeOSLogin.parent_page_url_); +}; + +gaia.chromeOSLogin.clearOldAttempts = function() { + var msg = { + 'method': 'clearOldAttempts' + }; + window.parent.postMessage(msg, gaia.chromeOSLogin.parent_page_url_); +}; + +gaia.chromeOSLogin.onAttemptedLogin = function(emailFormElement, + passwordFormElement, + continueUrlElement) { + var email = emailFormElement.value; + var passwd = passwordFormElement.value; + var attemptToken = new Date().getTime(); + + gaia.chromeOSLogin.attemptLogin(email, passwd, attemptToken); + + if (continueUrlElement) { + var prevAttemptIndex = continueUrlElement.value.indexOf('?attemptToken'); + if (prevAttemptIndex != -1) { + continueUrlElement.value = + continueUrlElement.value.substr(0, prevAttemptIndex); + } + continueUrlElement.value += '?attemptToken=' + attemptToken; + } +}; + +function submitAndGo() { + gaia.chromeOSLogin.onAttemptedLogin(document.getElementById("Email"), + document.getElementById("Passwd"), + document.getElementById("continue")); + return true; +} + +function onAuthError() { + if (window.domAutomationController) { + window.domAutomationController.sendWithId(4444, 'loginfail'); + } +} + +function onLoad() { + gaia.chromeOSLogin.clearOldAttempts(); +} +</SCRIPT> +</HEAD> +<BODY onload='onLoad();'> + Local Auth Server:<BR> + <FORM action='/ServiceLoginAuth' method=POST onsubmit='submitAndGo()'> + <INPUT TYPE=text id="Email" name="Email"> + <INPUT TYPE=text id="Passwd" name="Passwd"> + <INPUT TYPE=hidden id="continue" name="continue"> + <INPUT TYPE=Submit id="signIn"> + </FORM> +</BODY> +</HTML> |