Commit 726cd74f authored by courage@chromium.org's avatar courage@chromium.org

fix crash when identity.getAuthToken is called without an options parameter

This change updates the multi-account handling code to make sure the
options parameter object is present before dereferencing it to find
the "account" field. A new browser test calls getAuthToken without
options.

BUG=381637

Review URL: https://codereview.chromium.org/323563004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275587 0039d316-1c4b-4281-b951-d872f2087c98
parent bfb77b51
......@@ -325,7 +325,7 @@ bool IdentityGetAuthTokenFunction::RunAsync() {
std::string account_key = GetPrimaryAccountId(GetProfile());
if (params->details->account.get()) {
if (params->details.get() && params->details->account.get()) {
std::string detail_key =
extensions::IdentityAPI::GetFactoryInstance()
->Get(GetProfile())
......
......@@ -836,6 +836,32 @@ IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
id_api()->GetAuthStatusForTest());
}
IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
NoOptionsSuccess) {
#if defined(OS_WIN) && defined(USE_ASH)
// Disable this test in Metro+Ash for now (http://crbug.com/262796).
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests))
return;
#endif
scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction());
scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES));
func->set_extension(extension.get());
EXPECT_CALL(*func.get(), HasLoginToken()).WillOnce(Return(true));
TestOAuth2MintTokenFlow* flow = new TestOAuth2MintTokenFlow(
TestOAuth2MintTokenFlow::MINT_TOKEN_SUCCESS, func.get());
EXPECT_CALL(*func.get(), CreateMintTokenFlow(_)).WillOnce(Return(flow));
scoped_ptr<base::Value> value(utils::RunFunctionAndReturnSingleResult(
func.get(), "[]", browser()));
std::string access_token;
EXPECT_TRUE(value->GetAsString(&access_token));
EXPECT_EQ(std::string(kAccessToken), access_token);
EXPECT_FALSE(func->login_ui_shown());
EXPECT_FALSE(func->scope_ui_shown());
EXPECT_EQ(IdentityTokenCacheValue::CACHE_STATUS_TOKEN,
GetCachedToken(std::string()).status());
}
IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest,
NonInteractiveSuccess) {
#if defined(OS_WIN) && defined(USE_ASH)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment