OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <set> | 5 #include <set> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 #include "chrome/test/base/in_process_browser_test.h" | 34 #include "chrome/test/base/in_process_browser_test.h" |
35 #include "chrome/test/base/test_switches.h" | 35 #include "chrome/test/base/test_switches.h" |
36 #include "components/crx_file/id_util.h" | 36 #include "components/crx_file/id_util.h" |
37 #include "components/signin/core/browser/signin_manager.h" | 37 #include "components/signin/core/browser/signin_manager.h" |
38 #include "components/signin/core/common/profile_management_switches.h" | 38 #include "components/signin/core/common/profile_management_switches.h" |
39 #include "components/signin/core/common/signin_pref_names.h" | 39 #include "components/signin/core/common/signin_pref_names.h" |
40 #include "content/public/browser/notification_service.h" | 40 #include "content/public/browser/notification_service.h" |
41 #include "content/public/browser/notification_source.h" | 41 #include "content/public/browser/notification_source.h" |
42 #include "content/public/test/test_utils.h" | 42 #include "content/public/test/test_utils.h" |
43 #include "extensions/browser/guest_view/guest_view_base.h" | 43 #include "extensions/browser/guest_view/guest_view_base.h" |
| 44 #include "extensions/common/test_util.h" |
44 #include "google_apis/gaia/google_service_auth_error.h" | 45 #include "google_apis/gaia/google_service_auth_error.h" |
45 #include "google_apis/gaia/oauth2_mint_token_flow.h" | 46 #include "google_apis/gaia/oauth2_mint_token_flow.h" |
46 #include "net/test/spawned_test_server/spawned_test_server.h" | 47 #include "net/test/spawned_test_server/spawned_test_server.h" |
47 #include "testing/gmock/include/gmock/gmock.h" | 48 #include "testing/gmock/include/gmock/gmock.h" |
48 #include "testing/gtest/include/gtest/gtest.h" | 49 #include "testing/gtest/include/gtest/gtest.h" |
49 #include "url/gurl.h" | 50 #include "url/gurl.h" |
50 | 51 |
51 using testing::_; | 52 using testing::_; |
52 using testing::Return; | 53 using testing::Return; |
53 using testing::ReturnRef; | 54 using testing::ReturnRef; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 const std::string& args) { | 111 const std::string& args) { |
111 response_delegate_.reset(new SendResponseDelegate); | 112 response_delegate_.reset(new SendResponseDelegate); |
112 function->set_test_delegate(response_delegate_.get()); | 113 function->set_test_delegate(response_delegate_.get()); |
113 scoped_ptr<base::ListValue> parsed_args(utils::ParseList(args)); | 114 scoped_ptr<base::ListValue> parsed_args(utils::ParseList(args)); |
114 EXPECT_TRUE(parsed_args.get()) << | 115 EXPECT_TRUE(parsed_args.get()) << |
115 "Could not parse extension function arguments: " << args; | 116 "Could not parse extension function arguments: " << args; |
116 function->SetArgs(parsed_args.get()); | 117 function->SetArgs(parsed_args.get()); |
117 | 118 |
118 if (!function->extension()) { | 119 if (!function->extension()) { |
119 scoped_refptr<Extension> empty_extension( | 120 scoped_refptr<Extension> empty_extension( |
120 utils::CreateEmptyExtension()); | 121 test_util::CreateEmptyExtension()); |
121 function->set_extension(empty_extension.get()); | 122 function->set_extension(empty_extension.get()); |
122 } | 123 } |
123 | 124 |
124 function->set_browser_context(browser()->profile()); | 125 function->set_browser_context(browser()->profile()); |
125 function->set_has_callback(true); | 126 function->set_has_callback(true); |
126 function->Run()->Execute(); | 127 function->Run()->Execute(); |
127 } | 128 } |
128 | 129 |
129 std::string WaitForError(UIThreadExtensionFunction* function) { | 130 std::string WaitForError(UIThreadExtensionFunction* function) { |
130 RunMessageLoopUntilResponse(); | 131 RunMessageLoopUntilResponse(); |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 protected: | 405 protected: |
405 void SetAccountState(gaia::AccountIds ids, bool is_signed_in) { | 406 void SetAccountState(gaia::AccountIds ids, bool is_signed_in) { |
406 IdentityAPI::GetFactoryInstance()->Get(profile())->SetAccountStateForTest( | 407 IdentityAPI::GetFactoryInstance()->Get(profile())->SetAccountStateForTest( |
407 ids, is_signed_in); | 408 ids, is_signed_in); |
408 } | 409 } |
409 | 410 |
410 testing::AssertionResult ExpectGetAccounts( | 411 testing::AssertionResult ExpectGetAccounts( |
411 const std::vector<std::string>& accounts) { | 412 const std::vector<std::string>& accounts) { |
412 scoped_refptr<IdentityGetAccountsFunction> func( | 413 scoped_refptr<IdentityGetAccountsFunction> func( |
413 new IdentityGetAccountsFunction); | 414 new IdentityGetAccountsFunction); |
414 func->set_extension(utils::CreateEmptyExtension(kExtensionId).get()); | 415 func->set_extension(test_util::CreateEmptyExtension(kExtensionId).get()); |
415 if (!utils::RunFunction( | 416 if (!utils::RunFunction( |
416 func.get(), std::string("[]"), browser(), utils::NONE)) { | 417 func.get(), std::string("[]"), browser(), utils::NONE)) { |
417 return GenerateFailureResult(accounts, NULL) | 418 return GenerateFailureResult(accounts, NULL) |
418 << "getAccounts did not return a result."; | 419 << "getAccounts did not return a result."; |
419 } | 420 } |
420 const base::ListValue* callback_arguments = func->GetResultList(); | 421 const base::ListValue* callback_arguments = func->GetResultList(); |
421 if (!callback_arguments) | 422 if (!callback_arguments) |
422 return GenerateFailureResult(accounts, NULL) << "NULL result"; | 423 return GenerateFailureResult(accounts, NULL) << "NULL result"; |
423 | 424 |
424 if (callback_arguments->GetSize() != 1) { | 425 if (callback_arguments->GetSize() != 1) { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 std::vector<std::string> only_primary; | 526 std::vector<std::string> only_primary; |
526 only_primary.push_back("1"); | 527 only_primary.push_back("1"); |
527 EXPECT_TRUE(ExpectGetAccounts(only_primary)); | 528 EXPECT_TRUE(ExpectGetAccounts(only_primary)); |
528 } | 529 } |
529 | 530 |
530 class IdentityGetProfileUserInfoFunctionTest : public ExtensionBrowserTest { | 531 class IdentityGetProfileUserInfoFunctionTest : public ExtensionBrowserTest { |
531 protected: | 532 protected: |
532 scoped_ptr<api::identity::ProfileUserInfo> RunGetProfileUserInfo() { | 533 scoped_ptr<api::identity::ProfileUserInfo> RunGetProfileUserInfo() { |
533 scoped_refptr<IdentityGetProfileUserInfoFunction> func( | 534 scoped_refptr<IdentityGetProfileUserInfoFunction> func( |
534 new IdentityGetProfileUserInfoFunction); | 535 new IdentityGetProfileUserInfoFunction); |
535 func->set_extension(utils::CreateEmptyExtension(kExtensionId).get()); | 536 func->set_extension(test_util::CreateEmptyExtension(kExtensionId).get()); |
536 scoped_ptr<base::Value> value( | 537 scoped_ptr<base::Value> value( |
537 utils::RunFunctionAndReturnSingleResult(func.get(), "[]", browser())); | 538 utils::RunFunctionAndReturnSingleResult(func.get(), "[]", browser())); |
538 return api::identity::ProfileUserInfo::FromValue(*value.get()); | 539 return api::identity::ProfileUserInfo::FromValue(*value.get()); |
539 } | 540 } |
540 | 541 |
541 scoped_ptr<api::identity::ProfileUserInfo> RunGetProfileUserInfoWithEmail() { | 542 scoped_ptr<api::identity::ProfileUserInfo> RunGetProfileUserInfoWithEmail() { |
542 scoped_refptr<IdentityGetProfileUserInfoFunction> func( | 543 scoped_refptr<IdentityGetProfileUserInfoFunction> func( |
543 new IdentityGetProfileUserInfoFunction); | 544 new IdentityGetProfileUserInfoFunction); |
544 func->set_extension(CreateExtensionWithEmailPermission()); | 545 func->set_extension(CreateExtensionWithEmailPermission()); |
545 scoped_ptr<base::Value> value( | 546 scoped_ptr<base::Value> value( |
(...skipping 1041 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1587 EXPECT_TRUE(ContainsKey(token_key->scopes, "email")); | 1588 EXPECT_TRUE(ContainsKey(token_key->scopes, "email")); |
1588 EXPECT_TRUE(ContainsKey(token_key->scopes, "foo")); | 1589 EXPECT_TRUE(ContainsKey(token_key->scopes, "foo")); |
1589 EXPECT_TRUE(ContainsKey(token_key->scopes, "bar")); | 1590 EXPECT_TRUE(ContainsKey(token_key->scopes, "bar")); |
1590 } | 1591 } |
1591 | 1592 |
1592 class RemoveCachedAuthTokenFunctionTest : public ExtensionBrowserTest { | 1593 class RemoveCachedAuthTokenFunctionTest : public ExtensionBrowserTest { |
1593 protected: | 1594 protected: |
1594 bool InvalidateDefaultToken() { | 1595 bool InvalidateDefaultToken() { |
1595 scoped_refptr<IdentityRemoveCachedAuthTokenFunction> func( | 1596 scoped_refptr<IdentityRemoveCachedAuthTokenFunction> func( |
1596 new IdentityRemoveCachedAuthTokenFunction); | 1597 new IdentityRemoveCachedAuthTokenFunction); |
1597 func->set_extension(utils::CreateEmptyExtension(kExtensionId).get()); | 1598 func->set_extension(test_util::CreateEmptyExtension(kExtensionId).get()); |
1598 return utils::RunFunction( | 1599 return utils::RunFunction( |
1599 func.get(), | 1600 func.get(), |
1600 std::string("[{\"token\": \"") + kAccessToken + "\"}]", | 1601 std::string("[{\"token\": \"") + kAccessToken + "\"}]", |
1601 browser(), | 1602 browser(), |
1602 extension_function_test_utils::NONE); | 1603 extension_function_test_utils::NONE); |
1603 } | 1604 } |
1604 | 1605 |
1605 IdentityAPI* id_api() { | 1606 IdentityAPI* id_api() { |
1606 return IdentityAPI::GetFactoryInstance()->Get(browser()->profile()); | 1607 return IdentityAPI::GetFactoryInstance()->Get(browser()->profile()); |
1607 } | 1608 } |
1608 | 1609 |
1609 void SetCachedToken(IdentityTokenCacheValue& token_data) { | 1610 void SetCachedToken(IdentityTokenCacheValue& token_data) { |
1610 ExtensionTokenKey key(crx_file::id_util::GenerateId(kExtensionId), | 1611 ExtensionTokenKey key( |
1611 "test@example.com", | 1612 kExtensionId, "test@example.com", std::set<std::string>()); |
1612 std::set<std::string>()); | |
1613 id_api()->SetCachedToken(key, token_data); | 1613 id_api()->SetCachedToken(key, token_data); |
1614 } | 1614 } |
1615 | 1615 |
1616 const IdentityTokenCacheValue& GetCachedToken() { | 1616 const IdentityTokenCacheValue& GetCachedToken() { |
1617 return id_api()->GetCachedToken( | 1617 return id_api()->GetCachedToken(ExtensionTokenKey( |
1618 ExtensionTokenKey(crx_file::id_util::GenerateId(kExtensionId), | 1618 kExtensionId, "test@example.com", std::set<std::string>())); |
1619 "test@example.com", | |
1620 std::set<std::string>())); | |
1621 } | 1619 } |
1622 }; | 1620 }; |
1623 | 1621 |
1624 IN_PROC_BROWSER_TEST_F(RemoveCachedAuthTokenFunctionTest, NotFound) { | 1622 IN_PROC_BROWSER_TEST_F(RemoveCachedAuthTokenFunctionTest, NotFound) { |
1625 EXPECT_TRUE(InvalidateDefaultToken()); | 1623 EXPECT_TRUE(InvalidateDefaultToken()); |
1626 EXPECT_EQ(IdentityTokenCacheValue::CACHE_STATUS_NOTFOUND, | 1624 EXPECT_EQ(IdentityTokenCacheValue::CACHE_STATUS_NOTFOUND, |
1627 GetCachedToken().status()); | 1625 GetCachedToken().status()); |
1628 } | 1626 } |
1629 | 1627 |
1630 IN_PROC_BROWSER_TEST_F(RemoveCachedAuthTokenFunctionTest, Advice) { | 1628 IN_PROC_BROWSER_TEST_F(RemoveCachedAuthTokenFunctionTest, Advice) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1670 net::SpawnedTestServer https_server( | 1668 net::SpawnedTestServer https_server( |
1671 net::SpawnedTestServer::TYPE_HTTPS, | 1669 net::SpawnedTestServer::TYPE_HTTPS, |
1672 net::SpawnedTestServer::kLocalhost, | 1670 net::SpawnedTestServer::kLocalhost, |
1673 base::FilePath(FILE_PATH_LITERAL( | 1671 base::FilePath(FILE_PATH_LITERAL( |
1674 "chrome/test/data/extensions/api_test/identity"))); | 1672 "chrome/test/data/extensions/api_test/identity"))); |
1675 ASSERT_TRUE(https_server.Start()); | 1673 ASSERT_TRUE(https_server.Start()); |
1676 GURL auth_url(https_server.GetURL("files/interaction_required.html")); | 1674 GURL auth_url(https_server.GetURL("files/interaction_required.html")); |
1677 | 1675 |
1678 scoped_refptr<IdentityLaunchWebAuthFlowFunction> function( | 1676 scoped_refptr<IdentityLaunchWebAuthFlowFunction> function( |
1679 new IdentityLaunchWebAuthFlowFunction()); | 1677 new IdentityLaunchWebAuthFlowFunction()); |
1680 scoped_refptr<Extension> empty_extension( | 1678 scoped_refptr<Extension> empty_extension(test_util::CreateEmptyExtension()); |
1681 utils::CreateEmptyExtension()); | |
1682 function->set_extension(empty_extension.get()); | 1679 function->set_extension(empty_extension.get()); |
1683 | 1680 |
1684 WaitForGURLAndCloseWindow popup_observer(auth_url); | 1681 WaitForGURLAndCloseWindow popup_observer(auth_url); |
1685 | 1682 |
1686 std::string args = "[{\"interactive\": true, \"url\": \"" + | 1683 std::string args = "[{\"interactive\": true, \"url\": \"" + |
1687 auth_url.spec() + "\"}]"; | 1684 auth_url.spec() + "\"}]"; |
1688 RunFunctionAsync(function.get(), args); | 1685 RunFunctionAsync(function.get(), args); |
1689 | 1686 |
1690 popup_observer.Wait(); | 1687 popup_observer.Wait(); |
1691 popup_observer.CloseEmbedderWebContents(); | 1688 popup_observer.CloseEmbedderWebContents(); |
1692 | 1689 |
1693 EXPECT_EQ(std::string(errors::kUserRejected), WaitForError(function.get())); | 1690 EXPECT_EQ(std::string(errors::kUserRejected), WaitForError(function.get())); |
1694 } | 1691 } |
1695 | 1692 |
1696 IN_PROC_BROWSER_TEST_F(LaunchWebAuthFlowFunctionTest, InteractionRequired) { | 1693 IN_PROC_BROWSER_TEST_F(LaunchWebAuthFlowFunctionTest, InteractionRequired) { |
1697 net::SpawnedTestServer https_server( | 1694 net::SpawnedTestServer https_server( |
1698 net::SpawnedTestServer::TYPE_HTTPS, | 1695 net::SpawnedTestServer::TYPE_HTTPS, |
1699 net::SpawnedTestServer::kLocalhost, | 1696 net::SpawnedTestServer::kLocalhost, |
1700 base::FilePath(FILE_PATH_LITERAL( | 1697 base::FilePath(FILE_PATH_LITERAL( |
1701 "chrome/test/data/extensions/api_test/identity"))); | 1698 "chrome/test/data/extensions/api_test/identity"))); |
1702 ASSERT_TRUE(https_server.Start()); | 1699 ASSERT_TRUE(https_server.Start()); |
1703 GURL auth_url(https_server.GetURL("files/interaction_required.html")); | 1700 GURL auth_url(https_server.GetURL("files/interaction_required.html")); |
1704 | 1701 |
1705 scoped_refptr<IdentityLaunchWebAuthFlowFunction> function( | 1702 scoped_refptr<IdentityLaunchWebAuthFlowFunction> function( |
1706 new IdentityLaunchWebAuthFlowFunction()); | 1703 new IdentityLaunchWebAuthFlowFunction()); |
1707 scoped_refptr<Extension> empty_extension( | 1704 scoped_refptr<Extension> empty_extension(test_util::CreateEmptyExtension()); |
1708 utils::CreateEmptyExtension()); | |
1709 function->set_extension(empty_extension.get()); | 1705 function->set_extension(empty_extension.get()); |
1710 | 1706 |
1711 std::string args = "[{\"interactive\": false, \"url\": \"" + | 1707 std::string args = "[{\"interactive\": false, \"url\": \"" + |
1712 auth_url.spec() + "\"}]"; | 1708 auth_url.spec() + "\"}]"; |
1713 std::string error = | 1709 std::string error = |
1714 utils::RunFunctionAndReturnError(function.get(), args, browser()); | 1710 utils::RunFunctionAndReturnError(function.get(), args, browser()); |
1715 | 1711 |
1716 EXPECT_EQ(std::string(errors::kInteractionRequired), error); | 1712 EXPECT_EQ(std::string(errors::kInteractionRequired), error); |
1717 } | 1713 } |
1718 | 1714 |
1719 IN_PROC_BROWSER_TEST_F(LaunchWebAuthFlowFunctionTest, LoadFailed) { | 1715 IN_PROC_BROWSER_TEST_F(LaunchWebAuthFlowFunctionTest, LoadFailed) { |
1720 net::SpawnedTestServer https_server( | 1716 net::SpawnedTestServer https_server( |
1721 net::SpawnedTestServer::TYPE_HTTPS, | 1717 net::SpawnedTestServer::TYPE_HTTPS, |
1722 net::SpawnedTestServer::kLocalhost, | 1718 net::SpawnedTestServer::kLocalhost, |
1723 base::FilePath(FILE_PATH_LITERAL( | 1719 base::FilePath(FILE_PATH_LITERAL( |
1724 "chrome/test/data/extensions/api_test/identity"))); | 1720 "chrome/test/data/extensions/api_test/identity"))); |
1725 ASSERT_TRUE(https_server.Start()); | 1721 ASSERT_TRUE(https_server.Start()); |
1726 GURL auth_url(https_server.GetURL("files/five_hundred.html")); | 1722 GURL auth_url(https_server.GetURL("files/five_hundred.html")); |
1727 | 1723 |
1728 scoped_refptr<IdentityLaunchWebAuthFlowFunction> function( | 1724 scoped_refptr<IdentityLaunchWebAuthFlowFunction> function( |
1729 new IdentityLaunchWebAuthFlowFunction()); | 1725 new IdentityLaunchWebAuthFlowFunction()); |
1730 scoped_refptr<Extension> empty_extension( | 1726 scoped_refptr<Extension> empty_extension(test_util::CreateEmptyExtension()); |
1731 utils::CreateEmptyExtension()); | |
1732 function->set_extension(empty_extension.get()); | 1727 function->set_extension(empty_extension.get()); |
1733 | 1728 |
1734 std::string args = "[{\"interactive\": true, \"url\": \"" + | 1729 std::string args = "[{\"interactive\": true, \"url\": \"" + |
1735 auth_url.spec() + "\"}]"; | 1730 auth_url.spec() + "\"}]"; |
1736 std::string error = | 1731 std::string error = |
1737 utils::RunFunctionAndReturnError(function.get(), args, browser()); | 1732 utils::RunFunctionAndReturnError(function.get(), args, browser()); |
1738 | 1733 |
1739 EXPECT_EQ(std::string(errors::kPageLoadFailure), error); | 1734 EXPECT_EQ(std::string(errors::kPageLoadFailure), error); |
1740 } | 1735 } |
1741 | 1736 |
1742 IN_PROC_BROWSER_TEST_F(LaunchWebAuthFlowFunctionTest, NonInteractiveSuccess) { | 1737 IN_PROC_BROWSER_TEST_F(LaunchWebAuthFlowFunctionTest, NonInteractiveSuccess) { |
1743 #if defined(OS_WIN) && defined(USE_ASH) | 1738 #if defined(OS_WIN) && defined(USE_ASH) |
1744 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 1739 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
1745 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 1740 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
1746 return; | 1741 return; |
1747 #endif | 1742 #endif |
1748 | 1743 |
1749 scoped_refptr<IdentityLaunchWebAuthFlowFunction> function( | 1744 scoped_refptr<IdentityLaunchWebAuthFlowFunction> function( |
1750 new IdentityLaunchWebAuthFlowFunction()); | 1745 new IdentityLaunchWebAuthFlowFunction()); |
1751 scoped_refptr<Extension> empty_extension( | 1746 scoped_refptr<Extension> empty_extension(test_util::CreateEmptyExtension()); |
1752 utils::CreateEmptyExtension()); | |
1753 function->set_extension(empty_extension.get()); | 1747 function->set_extension(empty_extension.get()); |
1754 | 1748 |
1755 function->InitFinalRedirectURLPrefixForTest("abcdefghij"); | 1749 function->InitFinalRedirectURLPrefixForTest("abcdefghij"); |
1756 scoped_ptr<base::Value> value(utils::RunFunctionAndReturnSingleResult( | 1750 scoped_ptr<base::Value> value(utils::RunFunctionAndReturnSingleResult( |
1757 function.get(), | 1751 function.get(), |
1758 "[{\"interactive\": false," | 1752 "[{\"interactive\": false," |
1759 "\"url\": \"https://abcdefghij.chromiumapp.org/callback#test\"}]", | 1753 "\"url\": \"https://abcdefghij.chromiumapp.org/callback#test\"}]", |
1760 browser())); | 1754 browser())); |
1761 | 1755 |
1762 std::string url; | 1756 std::string url; |
1763 EXPECT_TRUE(value->GetAsString(&url)); | 1757 EXPECT_TRUE(value->GetAsString(&url)); |
1764 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"), | 1758 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"), |
1765 url); | 1759 url); |
1766 } | 1760 } |
1767 | 1761 |
1768 IN_PROC_BROWSER_TEST_F( | 1762 IN_PROC_BROWSER_TEST_F( |
1769 LaunchWebAuthFlowFunctionTest, InteractiveFirstNavigationSuccess) { | 1763 LaunchWebAuthFlowFunctionTest, InteractiveFirstNavigationSuccess) { |
1770 #if defined(OS_WIN) && defined(USE_ASH) | 1764 #if defined(OS_WIN) && defined(USE_ASH) |
1771 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 1765 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
1772 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 1766 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
1773 return; | 1767 return; |
1774 #endif | 1768 #endif |
1775 | 1769 |
1776 scoped_refptr<IdentityLaunchWebAuthFlowFunction> function( | 1770 scoped_refptr<IdentityLaunchWebAuthFlowFunction> function( |
1777 new IdentityLaunchWebAuthFlowFunction()); | 1771 new IdentityLaunchWebAuthFlowFunction()); |
1778 scoped_refptr<Extension> empty_extension( | 1772 scoped_refptr<Extension> empty_extension(test_util::CreateEmptyExtension()); |
1779 utils::CreateEmptyExtension()); | |
1780 function->set_extension(empty_extension.get()); | 1773 function->set_extension(empty_extension.get()); |
1781 | 1774 |
1782 function->InitFinalRedirectURLPrefixForTest("abcdefghij"); | 1775 function->InitFinalRedirectURLPrefixForTest("abcdefghij"); |
1783 scoped_ptr<base::Value> value(utils::RunFunctionAndReturnSingleResult( | 1776 scoped_ptr<base::Value> value(utils::RunFunctionAndReturnSingleResult( |
1784 function.get(), | 1777 function.get(), |
1785 "[{\"interactive\": true," | 1778 "[{\"interactive\": true," |
1786 "\"url\": \"https://abcdefghij.chromiumapp.org/callback#test\"}]", | 1779 "\"url\": \"https://abcdefghij.chromiumapp.org/callback#test\"}]", |
1787 browser())); | 1780 browser())); |
1788 | 1781 |
1789 std::string url; | 1782 std::string url; |
1790 EXPECT_TRUE(value->GetAsString(&url)); | 1783 EXPECT_TRUE(value->GetAsString(&url)); |
1791 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"), | 1784 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"), |
1792 url); | 1785 url); |
1793 } | 1786 } |
1794 | 1787 |
1795 IN_PROC_BROWSER_TEST_F(LaunchWebAuthFlowFunctionTest, | 1788 IN_PROC_BROWSER_TEST_F(LaunchWebAuthFlowFunctionTest, |
1796 DISABLED_InteractiveSecondNavigationSuccess) { | 1789 DISABLED_InteractiveSecondNavigationSuccess) { |
1797 net::SpawnedTestServer https_server( | 1790 net::SpawnedTestServer https_server( |
1798 net::SpawnedTestServer::TYPE_HTTPS, | 1791 net::SpawnedTestServer::TYPE_HTTPS, |
1799 net::SpawnedTestServer::kLocalhost, | 1792 net::SpawnedTestServer::kLocalhost, |
1800 base::FilePath(FILE_PATH_LITERAL( | 1793 base::FilePath(FILE_PATH_LITERAL( |
1801 "chrome/test/data/extensions/api_test/identity"))); | 1794 "chrome/test/data/extensions/api_test/identity"))); |
1802 ASSERT_TRUE(https_server.Start()); | 1795 ASSERT_TRUE(https_server.Start()); |
1803 GURL auth_url(https_server.GetURL("files/redirect_to_chromiumapp.html")); | 1796 GURL auth_url(https_server.GetURL("files/redirect_to_chromiumapp.html")); |
1804 | 1797 |
1805 scoped_refptr<IdentityLaunchWebAuthFlowFunction> function( | 1798 scoped_refptr<IdentityLaunchWebAuthFlowFunction> function( |
1806 new IdentityLaunchWebAuthFlowFunction()); | 1799 new IdentityLaunchWebAuthFlowFunction()); |
1807 scoped_refptr<Extension> empty_extension( | 1800 scoped_refptr<Extension> empty_extension(test_util::CreateEmptyExtension()); |
1808 utils::CreateEmptyExtension()); | |
1809 function->set_extension(empty_extension.get()); | 1801 function->set_extension(empty_extension.get()); |
1810 | 1802 |
1811 function->InitFinalRedirectURLPrefixForTest("abcdefghij"); | 1803 function->InitFinalRedirectURLPrefixForTest("abcdefghij"); |
1812 std::string args = "[{\"interactive\": true, \"url\": \"" + | 1804 std::string args = "[{\"interactive\": true, \"url\": \"" + |
1813 auth_url.spec() + "\"}]"; | 1805 auth_url.spec() + "\"}]"; |
1814 scoped_ptr<base::Value> value( | 1806 scoped_ptr<base::Value> value( |
1815 utils::RunFunctionAndReturnSingleResult(function.get(), args, browser())); | 1807 utils::RunFunctionAndReturnSingleResult(function.get(), args, browser())); |
1816 | 1808 |
1817 std::string url; | 1809 std::string url; |
1818 EXPECT_TRUE(value->GetAsString(&url)); | 1810 EXPECT_TRUE(value->GetAsString(&url)); |
1819 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"), | 1811 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"), |
1820 url); | 1812 url); |
1821 } | 1813 } |
1822 | 1814 |
1823 } // namespace extensions | 1815 } // namespace extensions |
1824 | 1816 |
1825 // Tests the chrome.identity API implemented by custom JS bindings . | 1817 // Tests the chrome.identity API implemented by custom JS bindings . |
1826 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeIdentityJsBindings) { | 1818 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeIdentityJsBindings) { |
1827 ASSERT_TRUE(RunExtensionTest("identity/js_bindings")) << message_; | 1819 ASSERT_TRUE(RunExtensionTest("identity/js_bindings")) << message_; |
1828 } | 1820 } |
OLD | NEW |